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
|
||||
function setupSentry (opts) {
|
||||
const { release } = opts
|
||||
const { release, getState } = opts
|
||||
let sentryTarget
|
||||
// detect brave
|
||||
const isBrave = Boolean(window.chrome.ipcRenderer)
|
||||
@ -38,9 +38,15 @@ function setupSentry (opts) {
|
||||
simplifyErrorMessages(report)
|
||||
// modify report urls
|
||||
rewriteReportUrls(report)
|
||||
// append app state
|
||||
if (getState) {
|
||||
const appState = getState()
|
||||
report.extra.appState = appState
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
}
|
||||
return report
|
||||
}
|
||||
|
||||
return Sentry
|
||||
|
@ -21,7 +21,17 @@ async function start () {
|
||||
|
||||
// setup sentry error reporting
|
||||
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
|
||||
// const css = MetaMaskUiCss()
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -6183,9 +6183,9 @@
|
||||
}
|
||||
},
|
||||
"clone": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
|
||||
"integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs="
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
||||
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18="
|
||||
},
|
||||
"clone-buffer": {
|
||||
"version": "1.0.0",
|
||||
|
@ -98,7 +98,7 @@
|
||||
"browserify-derequire": "^0.9.4",
|
||||
"browserify-unibabel": "^3.0.0",
|
||||
"classnames": "^2.2.5",
|
||||
"clone": "^2.1.1",
|
||||
"clone": "^2.1.2",
|
||||
"copy-to-clipboard": "^3.0.8",
|
||||
"css-loader": "^0.28.11",
|
||||
"currency-formatter": "^1.4.2",
|
||||
|
@ -1,3 +1,4 @@
|
||||
const clone = require('clone')
|
||||
const extend = require('xtend')
|
||||
const copyToClipboard = require('copy-to-clipboard')
|
||||
|
||||
@ -52,19 +53,24 @@ function rootReducer (state, action) {
|
||||
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) {
|
||||
const state = window.METAMASK_CACHED_LOG_STATE
|
||||
const version = global.platform.getVersion()
|
||||
const browser = window.navigator.userAgent
|
||||
return global.platform.getPlatformInfo((err, platform) => {
|
||||
if (err) {
|
||||
return cb(err)
|
||||
}
|
||||
state.version = version
|
||||
const state = window.getCleanAppState()
|
||||
global.platform.getPlatformInfo((err, platform) => {
|
||||
if (err) return cb(err)
|
||||
state.platform = platform
|
||||
state.browser = browser
|
||||
const stateString = JSON.stringify(state, removeSeedWords, 2)
|
||||
return cb(null, stateString)
|
||||
cb(null, stateString)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user