-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from hypermodules/sentry
Add sentry
- Loading branch information
Showing
5 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// modeled after https://github.com/codeforscience/sciencefair/blob/444bb75e0c73cc1e632ec833b98ba2d693668cde/app/client/lib/raven.js#L41 | ||
var os = require('os') | ||
|
||
var RAVEN_A = '3e06dec4e996422080e1853bdb663246' // eh.. can we get these out of source code? | ||
var RAVEN_B = '7e4004b4423044b3b19d2f4523748552' | ||
var RAVEN_C = '243594' | ||
|
||
var MAIN_THREAD = 'browser' | ||
var RENDERER = 'renderer' | ||
|
||
function getopts (processtype, name) { | ||
return { | ||
captureUnhandledRejections: true, | ||
name: name || 'Hyperamp', | ||
release: require('./package.json').version, | ||
extra: { | ||
platform: os.platform(), | ||
process: processtype, | ||
release: os.release(), | ||
arch: os.arch(), | ||
totalmem: os.totalmem() | ||
}, | ||
sendTimeout: 5, | ||
allowSecretKey: processtype === 'browser', | ||
debug: true | ||
} | ||
} | ||
|
||
function setup (name) { | ||
// process.type === 'browser' : main thread | ||
// process.type === 'renderer' : electron window | ||
var raven = process.type === MAIN_THREAD ? require('raven') : require('raven-js') | ||
var url = process.type === MAIN_THREAD ? `https://${RAVEN_A}:${RAVEN_B}@sentry.io/${RAVEN_C}` : `https://${RAVEN_A}@sentry.io/${RAVEN_C}` | ||
|
||
if (process.type === MAIN_THREAD) { | ||
// Main thread stuff only | ||
process.on('uncaughtException', (err) => { | ||
const dialog = require('electron').dialog | ||
|
||
dialog.showMessageBox({ | ||
title: 'An error occurred', | ||
message: `Sorry for the trouble, but an error has occurred in Hyperamp and we don't know how to recover from it. | ||
If you are connected to the internet, this has been reported anonymously to the project maintainers - they will work on a fix. | ||
The app may now quit - you can safely reopen it.`, | ||
detail: err.stack, | ||
buttons: ['OK'] | ||
}) | ||
}) | ||
} | ||
|
||
if (process.type === RENDERER) { | ||
// Renderer stuff only | ||
} | ||
|
||
var sentry = raven.config(url, getopts(process.type), name).install() | ||
console.log('Sentry installed') | ||
return sentry | ||
} | ||
|
||
module.exports = setup |