mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
sentry - replace raven-js with sentry/browser
This commit is contained in:
parent
31175dcb24
commit
e3fda83ab2
@ -23,7 +23,7 @@ const createStreamSink = require('./lib/createStreamSink')
|
||||
const NotificationManager = require('./lib/notification-manager.js')
|
||||
const MetamaskController = require('./metamask-controller')
|
||||
const rawFirstTimeState = require('./first-time-state')
|
||||
const setupRaven = require('./lib/setupRaven')
|
||||
const setupSentry = require('./lib/setupSentry')
|
||||
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry')
|
||||
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics')
|
||||
const EdgeEncryptor = require('./edge-encryptor')
|
||||
@ -50,7 +50,7 @@ global.METAMASK_NOTIFIER = notificationManager
|
||||
|
||||
// setup sentry error reporting
|
||||
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
|
||||
// Internet Explorer 6-11
|
||||
@ -197,14 +197,14 @@ async function loadStateFromPersistence () {
|
||||
// we were able to recover (though it might be old)
|
||||
versionedData = diskStoreState
|
||||
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: { vaultStructure },
|
||||
})
|
||||
} else {
|
||||
// unable to recover, clear state
|
||||
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) => {
|
||||
// get vault structure without secrets
|
||||
const vaultStructure = getObjStructure(versionedData)
|
||||
raven.captureException(err, {
|
||||
sentry.captureException(err, {
|
||||
// "extra" key is required by Sentry
|
||||
extra: { vaultStructure },
|
||||
})
|
||||
@ -279,7 +279,7 @@ function setupController (initState, initLangCode) {
|
||||
if (status !== 'failed') return
|
||||
const txMeta = controller.txController.txStateManager.getTx(txId)
|
||||
try {
|
||||
reportFailedTxToSentry({ raven, txMeta })
|
||||
reportFailedTxToSentry({ sentry, txMeta })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ module.exports = reportFailedTxToSentry
|
||||
// for sending to sentry
|
||||
//
|
||||
|
||||
function reportFailedTxToSentry ({ raven, txMeta }) {
|
||||
function reportFailedTxToSentry ({ sentry, txMeta }) {
|
||||
const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
|
||||
raven.captureMessage(errorMessage, {
|
||||
sentry.captureMessage(errorMessage, {
|
||||
// "extra" key is required by Sentry
|
||||
extra: { txMeta },
|
||||
})
|
||||
|
@ -1,59 +1,49 @@
|
||||
const Raven = require('raven-js')
|
||||
const Sentry = require('@sentry/browser')
|
||||
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
|
||||
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage')
|
||||
const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
|
||||
const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
|
||||
const SENTRY_DSN_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
|
||||
const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
|
||||
|
||||
module.exports = setupRaven
|
||||
module.exports = setupSentry
|
||||
|
||||
// Setup raven / sentry remote error reporting
|
||||
function setupRaven (opts) {
|
||||
// Setup sentry remote error reporting
|
||||
function setupSentry (opts) {
|
||||
const { release } = opts
|
||||
let ravenTarget
|
||||
let sentryTarget
|
||||
// detect brave
|
||||
const isBrave = Boolean(window.chrome.ipcRenderer)
|
||||
|
||||
if (METAMASK_DEBUG) {
|
||||
console.log('Setting up Sentry Remote Error Reporting: DEV')
|
||||
ravenTarget = DEV
|
||||
console.log('Setting up Sentry Remote Error Reporting: SENTRY_DSN_DEV')
|
||||
sentryTarget = SENTRY_DSN_DEV
|
||||
} else {
|
||||
console.log('Setting up Sentry Remote Error Reporting: PROD')
|
||||
ravenTarget = PROD
|
||||
console.log('Setting up Sentry Remote Error Reporting: SENTRY_DSN_PROD')
|
||||
sentryTarget = SENTRY_DSN_PROD
|
||||
}
|
||||
|
||||
const client = Raven.config(ravenTarget, {
|
||||
Sentry.init({
|
||||
dsn: sentryTarget,
|
||||
debug: METAMASK_DEBUG,
|
||||
release,
|
||||
transport: function (opts) {
|
||||
const report = opts.data
|
||||
|
||||
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)
|
||||
simplifyErrorMessages(report)
|
||||
// modify report urls
|
||||
rewriteReportUrls(report)
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
}
|
||||
// make request normally
|
||||
client._makeRequest(opts)
|
||||
},
|
||||
beforeSend: (report) => rewriteReport(report),
|
||||
})
|
||||
client.install()
|
||||
|
||||
return Raven
|
||||
}
|
||||
|
||||
function rewriteErrorLikeExceptions (report) {
|
||||
// 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}`
|
||||
Sentry.configureScope(scope => {
|
||||
scope.setExtra('isBrave', isBrave)
|
||||
})
|
||||
|
||||
function rewriteReport(report) {
|
||||
try {
|
||||
// simplify certain complex error messages (e.g. Ethjs)
|
||||
simplifyErrorMessages(report)
|
||||
// modify report urls
|
||||
rewriteReportUrls(report)
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
}
|
||||
}
|
||||
|
||||
return Sentry
|
||||
}
|
||||
|
||||
function simplifyErrorMessages (report) {
|
@ -9,7 +9,7 @@ const extension = require('extensionizer')
|
||||
const ExtensionPlatform = require('./platforms/extension')
|
||||
const NotificationManager = require('./lib/notification-manager')
|
||||
const notificationManager = new NotificationManager()
|
||||
const setupRaven = require('./lib/setupRaven')
|
||||
const setupSentry = require('./lib/setupSentry')
|
||||
const log = require('loglevel')
|
||||
|
||||
start().catch(log.error)
|
||||
@ -21,7 +21,7 @@ async function start () {
|
||||
|
||||
// setup sentry error reporting
|
||||
const release = global.platform.getVersion()
|
||||
setupRaven({ release })
|
||||
setupSentry({ release })
|
||||
|
||||
// inject css
|
||||
// const css = MetaMaskUiCss()
|
||||
|
57
package-lock.json
generated
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": {
|
||||
"version": "1.30.3",
|
||||
"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": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
|
||||
@ -27118,11 +27170,6 @@
|
||||
"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": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz",
|
||||
|
@ -82,6 +82,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@material-ui/core": "1.0.0",
|
||||
"@sentry/browser": "^4.1.1",
|
||||
"@zxing/library": "^0.8.0",
|
||||
"abi-decoder": "^1.0.9",
|
||||
"asmcrypto.js": "0.22.0",
|
||||
@ -186,7 +187,6 @@
|
||||
"pumpify": "^1.3.4",
|
||||
"qrcode-npm": "0.0.3",
|
||||
"ramda": "^0.24.1",
|
||||
"raven-js": "^3.27.0",
|
||||
"react": "^15.6.2",
|
||||
"react-addons-css-transition-group": "^15.6.0",
|
||||
"react-dom": "^15.6.2",
|
||||
|
Loading…
Reference in New Issue
Block a user