diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-03-08 09:16:35 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-03-08 09:16:35 +0800 |
commit | 8adb03074c6315b4bdcffdd22abca2c84c7a6985 (patch) | |
tree | 28ef1c54f5287206f89db5276df3a82bba00ae78 /app/scripts/lib | |
parent | 62febac87659ddf78a34dd0dac1ee8a38d8c8e77 (diff) | |
parent | 303801d2768a264a27a51916e5debf778739ee0c (diff) | |
download | tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.tar tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.tar.gz tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.tar.bz2 tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.tar.lz tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.tar.xz tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.tar.zst tangerine-wallet-browser-8adb03074c6315b4bdcffdd22abca2c84c7a6985.zip |
Merge branch 'master' into retry-tx-refractor
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/reportFailedTxToSentry.js | 38 | ||||
-rw-r--r-- | app/scripts/lib/setupRaven.js | 26 |
2 files changed, 64 insertions, 0 deletions
diff --git a/app/scripts/lib/reportFailedTxToSentry.js b/app/scripts/lib/reportFailedTxToSentry.js new file mode 100644 index 000000000..ee73f6845 --- /dev/null +++ b/app/scripts/lib/reportFailedTxToSentry.js @@ -0,0 +1,38 @@ +const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload ' +const errorLabelPrefix = 'Error: ' + +module.exports = reportFailedTxToSentry + +// +// utility for formatting failed transaction messages +// for sending to sentry +// + +function reportFailedTxToSentry({ raven, txMeta }) { + const errorMessage = extractErrorMessage(txMeta.err.message) + raven.captureMessage(errorMessage, { + // "extra" key is required by Sentry + extra: txMeta, + }) +} + +// +// ethjs-rpc provides overly verbose error messages +// if we detect this type of message, we extract the important part +// Below is an example input and output +// +// Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced +// +// Transaction Failed: replacement transaction underpriced +// + +function extractErrorMessage(errorMessage) { + const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug) + if (isEthjsRpcError) { + const payloadAndError = errorMessage.slice(ethJsRpcSlug.length) + const originalError = payloadAndError.slice(payloadAndError.indexOf(errorLabelPrefix) + errorLabelPrefix.length) + return `Transaction Failed: ${originalError}` + } else { + return `Transaction Failed: ${errorMessage}` + } +} diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js new file mode 100644 index 000000000..42e48cb90 --- /dev/null +++ b/app/scripts/lib/setupRaven.js @@ -0,0 +1,26 @@ +const Raven = require('../vendor/raven.min.js') +const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' +const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' +const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' + +module.exports = setupRaven + +// Setup raven / sentry remote error reporting +function setupRaven(opts) { + const { release } = opts + let ravenTarget + + if (METAMASK_DEBUG) { + console.log('Setting up Sentry Remote Error Reporting: DEV') + ravenTarget = DEV + } else { + console.log('Setting up Sentry Remote Error Reporting: PROD') + ravenTarget = PROD + } + + Raven.config(ravenTarget, { + release, + }).install() + + return Raven +} |