mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #4139 from MetaMask/sentry-enhancements
Sentry enhancements
This commit is contained in:
commit
5736a1f46d
@ -23,23 +23,16 @@ function setupRaven(opts) {
|
|||||||
release,
|
release,
|
||||||
transport: function(opts) {
|
transport: function(opts) {
|
||||||
const report = opts.data
|
const report = opts.data
|
||||||
// simplify certain complex error messages
|
try {
|
||||||
if (report.exception && report.exception.values) {
|
// handle error-like non-error exceptions
|
||||||
report.exception.values.forEach(item => {
|
nonErrorException(report)
|
||||||
let errorMessage = item.value
|
// simplify certain complex error messages (e.g. Ethjs)
|
||||||
// simplify ethjs error messages
|
simplifyErrorMessages(report)
|
||||||
errorMessage = extractEthjsErrorMessage(errorMessage)
|
// modify report urls
|
||||||
// simplify 'Transaction Failed: known transaction'
|
rewriteReportUrls(report)
|
||||||
if (errorMessage.indexOf('Transaction Failed: known transaction') === 0) {
|
} catch (err) {
|
||||||
// cut the hash from the error message
|
console.warn(err)
|
||||||
errorMessage = 'Transaction Failed: known transaction'
|
|
||||||
}
|
|
||||||
// finalize
|
|
||||||
item.value = errorMessage
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
// modify report urls
|
|
||||||
rewriteReportUrls(report)
|
|
||||||
// make request normally
|
// make request normally
|
||||||
client._makeRequest(opts)
|
client._makeRequest(opts)
|
||||||
},
|
},
|
||||||
@ -49,6 +42,31 @@ function setupRaven(opts) {
|
|||||||
return Raven
|
return Raven
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nonErrorException(report) {
|
||||||
|
// handle errors that lost their error-ness in serialization
|
||||||
|
if (report.message.includes('Non-Error exception captured with keys: message')) {
|
||||||
|
if (!(report.extra && report.extra.__serialized__)) return
|
||||||
|
report.message = `Non-Error Exception: ${report.extra.__serialized__.message}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function simplifyErrorMessages(report) {
|
||||||
|
if (report.exception && report.exception.values) {
|
||||||
|
report.exception.values.forEach(item => {
|
||||||
|
let errorMessage = item.value
|
||||||
|
// simplify ethjs error messages
|
||||||
|
errorMessage = extractEthjsErrorMessage(errorMessage)
|
||||||
|
// simplify 'Transaction Failed: known transaction'
|
||||||
|
if (errorMessage.indexOf('Transaction Failed: known transaction') === 0) {
|
||||||
|
// cut the hash from the error message
|
||||||
|
errorMessage = 'Transaction Failed: known transaction'
|
||||||
|
}
|
||||||
|
// finalize
|
||||||
|
item.value = errorMessage
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function rewriteReportUrls(report) {
|
function rewriteReportUrls(report) {
|
||||||
// update request url
|
// update request url
|
||||||
report.request.url = toMetamaskUrl(report.request.url)
|
report.request.url = toMetamaskUrl(report.request.url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user