mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
sentry - include app state in ui errors
This commit is contained in:
parent
e3fda83ab2
commit
73ec4e66cb
@ -8,7 +8,7 @@ module.exports = setupSentry
|
|||||||
|
|
||||||
// Setup sentry remote error reporting
|
// Setup sentry remote error reporting
|
||||||
function setupSentry (opts) {
|
function setupSentry (opts) {
|
||||||
const { release } = opts
|
const { release, getState } = opts
|
||||||
let sentryTarget
|
let sentryTarget
|
||||||
// detect brave
|
// detect brave
|
||||||
const isBrave = Boolean(window.chrome.ipcRenderer)
|
const isBrave = Boolean(window.chrome.ipcRenderer)
|
||||||
@ -38,9 +38,15 @@ function setupSentry (opts) {
|
|||||||
simplifyErrorMessages(report)
|
simplifyErrorMessages(report)
|
||||||
// modify report urls
|
// modify report urls
|
||||||
rewriteReportUrls(report)
|
rewriteReportUrls(report)
|
||||||
|
// append app state
|
||||||
|
if (getState) {
|
||||||
|
const appState = getState()
|
||||||
|
report.extra.appState = appState
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err)
|
console.warn(err)
|
||||||
}
|
}
|
||||||
|
return report
|
||||||
}
|
}
|
||||||
|
|
||||||
return Sentry
|
return Sentry
|
||||||
|
@ -21,7 +21,17 @@ async function start () {
|
|||||||
|
|
||||||
// setup sentry error reporting
|
// setup sentry error reporting
|
||||||
const release = global.platform.getVersion()
|
const release = global.platform.getVersion()
|
||||||
setupSentry({ release })
|
setupSentry({ release, getState })
|
||||||
|
// provide app state to append to error logs
|
||||||
|
function getState() {
|
||||||
|
// get app state
|
||||||
|
const state = window.getCleanAppState()
|
||||||
|
// remove unnecessary data
|
||||||
|
delete state.localeMessages
|
||||||
|
delete state.metamask.recentBlocks
|
||||||
|
// return state to be added to request
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
|
||||||
// inject css
|
// inject css
|
||||||
// const css = MetaMaskUiCss()
|
// const css = MetaMaskUiCss()
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -6183,9 +6183,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"clone": {
|
"clone": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
||||||
"integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs="
|
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18="
|
||||||
},
|
},
|
||||||
"clone-buffer": {
|
"clone-buffer": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
"browserify-derequire": "^0.9.4",
|
"browserify-derequire": "^0.9.4",
|
||||||
"browserify-unibabel": "^3.0.0",
|
"browserify-unibabel": "^3.0.0",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"clone": "^2.1.1",
|
"clone": "^2.1.2",
|
||||||
"copy-to-clipboard": "^3.0.8",
|
"copy-to-clipboard": "^3.0.8",
|
||||||
"css-loader": "^0.28.11",
|
"css-loader": "^0.28.11",
|
||||||
"currency-formatter": "^1.4.2",
|
"currency-formatter": "^1.4.2",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const clone = require('clone')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const copyToClipboard = require('copy-to-clipboard')
|
const copyToClipboard = require('copy-to-clipboard')
|
||||||
|
|
||||||
@ -52,19 +53,24 @@ function rootReducer (state, action) {
|
|||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.getCleanAppState = function () {
|
||||||
|
const state = clone(window.METAMASK_CACHED_LOG_STATE)
|
||||||
|
// append additional information
|
||||||
|
state.version = global.platform.getVersion()
|
||||||
|
state.browser = window.navigator.userAgent
|
||||||
|
// ensure seedWords are not included
|
||||||
|
if (state.metamask) delete state.metamask.seedWords
|
||||||
|
if (state.appState.currentView) delete state.appState.currentView.seedWords
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
|
||||||
window.logStateString = function (cb) {
|
window.logStateString = function (cb) {
|
||||||
const state = window.METAMASK_CACHED_LOG_STATE
|
const state = window.getCleanAppState()
|
||||||
const version = global.platform.getVersion()
|
global.platform.getPlatformInfo((err, platform) => {
|
||||||
const browser = window.navigator.userAgent
|
if (err) return cb(err)
|
||||||
return global.platform.getPlatformInfo((err, platform) => {
|
|
||||||
if (err) {
|
|
||||||
return cb(err)
|
|
||||||
}
|
|
||||||
state.version = version
|
|
||||||
state.platform = platform
|
state.platform = platform
|
||||||
state.browser = browser
|
|
||||||
const stateString = JSON.stringify(state, removeSeedWords, 2)
|
const stateString = JSON.stringify(state, removeSeedWords, 2)
|
||||||
return cb(null, stateString)
|
cb(null, stateString)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user