Skip to content

Commit f855247

Browse files
committed
Improve sentry reporting
1 parent d10ea43 commit f855247

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 0.5.6 - 2017-11-11
6+
* Report auto update errors to sentry
7+
* Switch to a shared thread sentry for easier importing to unrelated modules
8+
59
## 0.5.5 - 2017-11-11
610
* Add sentry
711
* Expose auto-update events to player

main/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var isDev = require('electron-is-dev')
2+
var sentry
23
if (!isDev) {
3-
require('../sentry')('main')
4+
sentry = require('../sentry')
45
}
56
var { app, ipcMain } = require('electron')
67
var Config = require('electron-store')
@@ -246,8 +247,8 @@ app.on('ready', function appReady () {
246247
}
247248

248249
autoUpdater.on('error', (err) => {
249-
console.log(err)
250250
broadcast('au:error', err)
251+
if (sentry) sentry.captureException(err)
251252
})
252253

253254
autoUpdater.on('checking-for-update', () => {

renderer/audio.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>🎵</h1>
1313
<audio id="needle"></audio>
1414
<script>
1515
var isDev = require('electron-is-dev')
16-
if (!isDev) require('../sentry.js')('audio')
16+
if (!isDev) require('../sentry.js')
1717
require('./audio/index.js')
1818
</script>
1919
</body>

renderer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<main id="app"></main>
99
<script>
1010
var isDev = require('electron-is-dev')
11-
if (!isDev) window.raven = require('../sentry.js')('player')
11+
if (!isDev) window.raven = require('../sentry.js')
1212
if (isDev || process.env.DEV_SERVER) {
1313
var bundle = document.createElement('script')
1414
bundle.src = 'http://localhost:9966/bundle.js'

sentry.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ var RAVEN_C = '243594'
88
var MAIN_THREAD = 'browser'
99
var RENDERER = 'renderer'
1010

11-
function getopts (processtype, name) {
11+
function getopts (processtype) {
1212
return {
1313
captureUnhandledRejections: true,
14-
name: name || 'Hyperamp',
14+
name: 'Hyperamp',
1515
release: require('./package.json').version,
1616
extra: {
1717
platform: os.platform(),
@@ -26,37 +26,34 @@ function getopts (processtype, name) {
2626
}
2727
}
2828

29-
function setup (name) {
30-
// process.type === 'browser' : main thread
31-
// process.type === 'renderer' : electron window
32-
var raven = process.type === MAIN_THREAD ? require('raven') : require('raven-js')
33-
var url = process.type === MAIN_THREAD ? `https://${RAVEN_A}:${RAVEN_B}@sentry.io/${RAVEN_C}` : `https://${RAVEN_A}@sentry.io/${RAVEN_C}`
29+
// process.type === 'browser' : main thread
30+
// process.type === 'renderer' : electron window
31+
var raven = process.type === MAIN_THREAD ? require('raven') : require('raven-js')
32+
var url = process.type === MAIN_THREAD ? `https://${RAVEN_A}:${RAVEN_B}@sentry.io/${RAVEN_C}` : `https://${RAVEN_A}@sentry.io/${RAVEN_C}`
3433

35-
if (process.type === MAIN_THREAD) {
34+
if (process.type === MAIN_THREAD) {
3635
// Main thread stuff only
37-
process.on('uncaughtException', (err) => {
38-
const dialog = require('electron').dialog
36+
process.on('uncaughtException', (err) => {
37+
const dialog = require('electron').dialog
3938

40-
dialog.showMessageBox({
41-
title: 'An error occurred',
42-
message: `Sorry for the trouble, but an error has occurred in Hyperamp and we don't know how to recover from it.
39+
dialog.showMessageBox({
40+
title: 'An error occurred',
41+
message: `Sorry for the trouble, but an error has occurred in Hyperamp and we don't know how to recover from it.
4342
4443
If you are connected to the internet, this has been reported anonymously to the project maintainers - they will work on a fix.
4544
4645
The app may now quit - you can safely reopen it.`,
47-
detail: err.stack,
48-
buttons: ['OK']
49-
})
46+
detail: err.stack,
47+
buttons: ['OK']
5048
})
51-
}
49+
})
50+
}
5251

53-
if (process.type === RENDERER) {
52+
if (process.type === RENDERER) {
5453
// Renderer stuff only
55-
}
56-
57-
var sentry = raven.config(url, getopts(process.type), name).install()
58-
console.log('Sentry installed')
59-
return sentry
6054
}
6155

62-
module.exports = setup
56+
var sentry = raven.config(url, getopts(process.type)).install()
57+
console.log('Sentry installed')
58+
59+
module.exports = sentry

0 commit comments

Comments
 (0)