sentry - replace raven-js with sentry/browser

feature/default_network_editable
kumavis 6 years ago
parent 31175dcb24
commit e3fda83ab2
  1. 12
      app/scripts/background.js
  2. 4
      app/scripts/lib/reportFailedTxToSentry.js
  3. 56
      app/scripts/lib/setupSentry.js
  4. 4
      app/scripts/ui.js
  5. 57
      package-lock.json
  6. 2
      package.json

@ -23,7 +23,7 @@ const createStreamSink = require('./lib/createStreamSink')
const NotificationManager = require('./lib/notification-manager.js') const NotificationManager = require('./lib/notification-manager.js')
const MetamaskController = require('./metamask-controller') const MetamaskController = require('./metamask-controller')
const rawFirstTimeState = require('./first-time-state') const rawFirstTimeState = require('./first-time-state')
const setupRaven = require('./lib/setupRaven') const setupSentry = require('./lib/setupSentry')
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry') const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics') const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
const EdgeEncryptor = require('./edge-encryptor') const EdgeEncryptor = require('./edge-encryptor')
@ -50,7 +50,7 @@ global.METAMASK_NOTIFIER = notificationManager
// setup sentry error reporting // setup sentry error reporting
const release = platform.getVersion() const release = platform.getVersion()
const raven = setupRaven({ release }) const sentry = setupSentry({ release })
// browser check if it is Edge - https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser // browser check if it is Edge - https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
// Internet Explorer 6-11 // Internet Explorer 6-11
@ -197,14 +197,14 @@ async function loadStateFromPersistence () {
// we were able to recover (though it might be old) // we were able to recover (though it might be old)
versionedData = diskStoreState versionedData = diskStoreState
const vaultStructure = getObjStructure(versionedData) const vaultStructure = getObjStructure(versionedData)
raven.captureMessage('MetaMask - Empty vault found - recovered from diskStore', { sentry.captureMessage('MetaMask - Empty vault found - recovered from diskStore', {
// "extra" key is required by Sentry // "extra" key is required by Sentry
extra: { vaultStructure }, extra: { vaultStructure },
}) })
} else { } else {
// unable to recover, clear state // unable to recover, clear state
versionedData = migrator.generateInitialState(firstTimeState) versionedData = migrator.generateInitialState(firstTimeState)
raven.captureMessage('MetaMask - Empty vault found - unable to recover') sentry.captureMessage('MetaMask - Empty vault found - unable to recover')
} }
} }
@ -212,7 +212,7 @@ async function loadStateFromPersistence () {
migrator.on('error', (err) => { migrator.on('error', (err) => {
// get vault structure without secrets // get vault structure without secrets
const vaultStructure = getObjStructure(versionedData) const vaultStructure = getObjStructure(versionedData)
raven.captureException(err, { sentry.captureException(err, {
// "extra" key is required by Sentry // "extra" key is required by Sentry
extra: { vaultStructure }, extra: { vaultStructure },
}) })
@ -279,7 +279,7 @@ function setupController (initState, initLangCode) {
if (status !== 'failed') return if (status !== 'failed') return
const txMeta = controller.txController.txStateManager.getTx(txId) const txMeta = controller.txController.txStateManager.getTx(txId)
try { try {
reportFailedTxToSentry({ raven, txMeta }) reportFailedTxToSentry({ sentry, txMeta })
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }

@ -7,9 +7,9 @@ module.exports = reportFailedTxToSentry
// for sending to sentry // for sending to sentry
// //
function reportFailedTxToSentry ({ raven, txMeta }) { function reportFailedTxToSentry ({ sentry, txMeta }) {
const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message) const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
raven.captureMessage(errorMessage, { sentry.captureMessage(errorMessage, {
// "extra" key is required by Sentry // "extra" key is required by Sentry
extra: { txMeta }, extra: { txMeta },
}) })

@ -1,36 +1,39 @@
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 })
Sentry.configureScope(scope => {
scope.setExtra('isBrave', isBrave)
})
function rewriteReport(report) {
try { try {
// mark browser as brave or not
report.extra.isBrave = isBrave
// handle error-like non-error exceptions
rewriteErrorLikeExceptions(report)
// simplify certain complex error messages (e.g. Ethjs) // simplify certain complex error messages (e.g. Ethjs)
simplifyErrorMessages(report) simplifyErrorMessages(report)
// modify report urls // modify report urls
@ -38,22 +41,9 @@ function setupRaven (opts) {
} catch (err) { } catch (err) {
console.warn(err) console.warn(err)
} }
// make request normally }
client._makeRequest(opts)
},
})
client.install()
return Raven
}
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) {

@ -9,7 +9,7 @@ const extension = require('extensionizer')
const ExtensionPlatform = require('./platforms/extension') const ExtensionPlatform = require('./platforms/extension')
const NotificationManager = require('./lib/notification-manager') const NotificationManager = require('./lib/notification-manager')
const notificationManager = new NotificationManager() const notificationManager = new NotificationManager()
const setupRaven = require('./lib/setupRaven') const setupSentry = require('./lib/setupSentry')
const log = require('loglevel') const log = require('loglevel')
start().catch(log.error) start().catch(log.error)
@ -21,7 +21,7 @@ async function start () {
// setup sentry error reporting // setup sentry error reporting
const release = global.platform.getVersion() const release = global.platform.getVersion()
setupRaven({ release }) setupSentry({ release })
// inject css // inject css
// const css = MetaMaskUiCss() // const css = MetaMaskUiCss()

57
package-lock.json generated

@ -489,6 +489,16 @@
} }
} }
}, },
"@sentry/browser": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-4.1.1.tgz",
"integrity": "sha512-rmkGlTh0AL3Jf0DvF3BluChIyzPkkYpNgIwEHjxTUiLp6BQdgwakZuzBqSPJrEs+jMsKMoesOuJ/fAAG0K7+Ew==",
"requires": {
"@sentry/core": "4.1.1",
"@sentry/types": "4.1.0",
"@sentry/utils": "4.1.1"
}
},
"@sentry/cli": { "@sentry/cli": {
"version": "1.30.3", "version": "1.30.3",
"resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-1.30.3.tgz", "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-1.30.3.tgz",
@ -531,6 +541,48 @@
} }
} }
}, },
"@sentry/core": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@sentry/core/-/core-4.1.1.tgz",
"integrity": "sha512-QJExTxZ1ZA5P/To5gOwd3sowukXW0N/Q9nfu8biRDNa+YURn6ElLjO0fD6eIBqX1f3npo/kTiWZwFBc7LXEzSg==",
"requires": {
"@sentry/hub": "4.1.1",
"@sentry/minimal": "4.1.1",
"@sentry/types": "4.1.0",
"@sentry/utils": "4.1.1"
}
},
"@sentry/hub": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-4.1.1.tgz",
"integrity": "sha512-VmcZOgcbFjJzK1oQNwcFP/wgfoWQr24dFv1C0uwdXldNXx3mwyUVkomvklBHz90HwiahsI/gCc+ZmbC3ECQk2Q==",
"requires": {
"@sentry/types": "4.1.0",
"@sentry/utils": "4.1.1"
}
},
"@sentry/minimal": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-4.1.1.tgz",
"integrity": "sha512-xRKWA46OGnZinJyTljDUel53emPP9mb/XNi/kF6SBaVDOUXl7HAB8kP7Bn7eLBwOanxN8PbYoAzh/lIQXWTmDg==",
"requires": {
"@sentry/hub": "4.1.1",
"@sentry/types": "4.1.0"
}
},
"@sentry/types": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-4.1.0.tgz",
"integrity": "sha512-KY7B9wYs1NACHlYzG4OuP6k4uQJkyDPJppftjj3NJYShfwdDTO1I2Swkhhb5dJMEMMMpBJGxXmiqZ2mX5ErISQ=="
},
"@sentry/utils": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-4.1.1.tgz",
"integrity": "sha512-XMvGqAWATBrRkOF0lkt0Ij8of2mRmp4WeFTUAgiKzCekxfUBLBaTb4wTaFXz1cnnnjVTwcAq72qBRMhHwQ0IIg==",
"requires": {
"@sentry/types": "4.1.0"
}
},
"@sinonjs/formatio": { "@sinonjs/formatio": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
@ -27118,11 +27170,6 @@
"eve-raphael": "0.5.0" "eve-raphael": "0.5.0"
} }
}, },
"raven-js": {
"version": "3.27.0",
"resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.27.0.tgz",
"integrity": "sha512-vChdOL+yzecfnGA+B5EhEZkJ3kY3KlMzxEhShKh6Vdtooyl0yZfYNFQfYzgMf2v4pyQa+OTZ5esTxxgOOZDHqw=="
},
"raw-body": { "raw-body": {
"version": "2.3.2", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz",

@ -82,6 +82,7 @@
}, },
"dependencies": { "dependencies": {
"@material-ui/core": "1.0.0", "@material-ui/core": "1.0.0",
"@sentry/browser": "^4.1.1",
"@zxing/library": "^0.8.0", "@zxing/library": "^0.8.0",
"abi-decoder": "^1.0.9", "abi-decoder": "^1.0.9",
"asmcrypto.js": "0.22.0", "asmcrypto.js": "0.22.0",
@ -186,7 +187,6 @@
"pumpify": "^1.3.4", "pumpify": "^1.3.4",
"qrcode-npm": "0.0.3", "qrcode-npm": "0.0.3",
"ramda": "^0.24.1", "ramda": "^0.24.1",
"raven-js": "^3.27.0",
"react": "^15.6.2", "react": "^15.6.2",
"react-addons-css-transition-group": "^15.6.0", "react-addons-css-transition-group": "^15.6.0",
"react-dom": "^15.6.2", "react-dom": "^15.6.2",

Loading…
Cancel
Save