parent
31175dcb24
commit
e3fda83ab2
@ -1,59 +1,49 @@ |
|||||||
const Raven = require('raven-js') |
const Sentry = require('@sentry/browser') |
||||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG |
const METAMASK_DEBUG = process.env.METAMASK_DEBUG |
||||||
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage') |
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage') |
||||||
const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' |
const SENTRY_DSN_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' |
||||||
const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' |
const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' |
||||||
|
|
||||||
module.exports = setupRaven |
module.exports = setupSentry |
||||||
|
|
||||||
// Setup raven / sentry remote error reporting
|
// Setup sentry remote error reporting
|
||||||
function setupRaven (opts) { |
function setupSentry (opts) { |
||||||
const { release } = opts |
const { release } = opts |
||||||
let ravenTarget |
let sentryTarget |
||||||
// detect brave
|
// detect brave
|
||||||
const isBrave = Boolean(window.chrome.ipcRenderer) |
const isBrave = Boolean(window.chrome.ipcRenderer) |
||||||
|
|
||||||
if (METAMASK_DEBUG) { |
if (METAMASK_DEBUG) { |
||||||
console.log('Setting up Sentry Remote Error Reporting: DEV') |
console.log('Setting up Sentry Remote Error Reporting: SENTRY_DSN_DEV') |
||||||
ravenTarget = DEV |
sentryTarget = SENTRY_DSN_DEV |
||||||
} else { |
} else { |
||||||
console.log('Setting up Sentry Remote Error Reporting: PROD') |
console.log('Setting up Sentry Remote Error Reporting: SENTRY_DSN_PROD') |
||||||
ravenTarget = PROD |
sentryTarget = SENTRY_DSN_PROD |
||||||
} |
} |
||||||
|
|
||||||
const client = Raven.config(ravenTarget, { |
Sentry.init({ |
||||||
|
dsn: sentryTarget, |
||||||
|
debug: METAMASK_DEBUG, |
||||||
release, |
release, |
||||||
transport: function (opts) { |
beforeSend: (report) => rewriteReport(report), |
||||||
const report = opts.data |
}) |
||||||
|
|
||||||
try { |
Sentry.configureScope(scope => { |
||||||
// mark browser as brave or not
|
scope.setExtra('isBrave', isBrave) |
||||||
report.extra.isBrave = isBrave |
|
||||||
// handle error-like non-error exceptions
|
|
||||||
rewriteErrorLikeExceptions(report) |
|
||||||
// simplify certain complex error messages (e.g. Ethjs)
|
|
||||||
simplifyErrorMessages(report) |
|
||||||
// modify report urls
|
|
||||||
rewriteReportUrls(report) |
|
||||||
} catch (err) { |
|
||||||
console.warn(err) |
|
||||||
} |
|
||||||
// make request normally
|
|
||||||
client._makeRequest(opts) |
|
||||||
}, |
|
||||||
}) |
}) |
||||||
client.install() |
|
||||||
|
|
||||||
return Raven |
function rewriteReport(report) { |
||||||
} |
try { |
||||||
|
// simplify certain complex error messages (e.g. Ethjs)
|
||||||
|
simplifyErrorMessages(report) |
||||||
|
// modify report urls
|
||||||
|
rewriteReportUrls(report) |
||||||
|
} catch (err) { |
||||||
|
console.warn(err) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
function rewriteErrorLikeExceptions (report) { |
return Sentry |
||||||
// handle errors that lost their error-ness in serialization (e.g. dnode)
|
|
||||||
rewriteErrorMessages(report, (errorMessage) => { |
|
||||||
if (!errorMessage.includes('Non-Error exception captured with keys:')) return errorMessage |
|
||||||
if (!(report.extra && report.extra.__serialized__ && report.extra.__serialized__.message)) return errorMessage |
|
||||||
return `Non-Error Exception: ${report.extra.__serialized__.message}` |
|
||||||
}) |
|
||||||
} |
} |
||||||
|
|
||||||
function simplifyErrorMessages (report) { |
function simplifyErrorMessages (report) { |
Loading…
Reference in new issue