From d0cfe1adeb3b756bf45483f84e70f89f789ba851 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Tue, 1 Aug 2023 16:15:54 -0600 Subject: [PATCH 1/4] remove unused code to overwrite filenames for Sentry error reporting --- app/util/sentryUtils.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/util/sentryUtils.js b/app/util/sentryUtils.js index 9701c1083af..f5db117adc2 100644 --- a/app/util/sentryUtils.js +++ b/app/util/sentryUtils.js @@ -34,6 +34,7 @@ function rewriteBreadcrumb(breadcrumb) { if (breadcrumb.data?.from) { breadcrumb.data.from = getProtocolFromURL(breadcrumb.data.from); } + console.log('Breadcrumb', breadcrumb); return breadcrumb; } @@ -73,17 +74,8 @@ function simplifyErrorMessages(report) { function rewriteReportUrls(report) { // update request url - report.request.url = toMetamaskUrl(); - // update exception stack trace - if (report.exception && report.exception.values) { - report.exception.values.forEach((item) => { - if (item.stacktrace) { - item.stacktrace.frames.forEach((frame) => { - frame.filename = toMetamaskUrl(frame.filename); - }); - } - }); - } + console.log('rewriteReportUrls', report); + report.request.url = toMetamaskUrl(report.request.url); } function removeDeviceTimezone(report) { @@ -96,12 +88,19 @@ function removeDeviceName(report) { report.contexts.device.name = null; } -function toMetamaskUrl() { - const metamaskUrl = `metamask-mobile`; - return metamaskUrl; +function toMetamaskUrl(origUrl) { + const filePath = origUrl?.split(location.origin)[1]; + if (!filePath) { + return origUrl; + } + + const metamaskUrl = 'metamask-mobile'; + return metamaskUrl; } + function rewriteReport(report) { + console.log('start', report.exception.values[0].stacktrace.frames); try { // simplify certain complex error messages (e.g. Ethjs) simplifyErrorMessages(report); @@ -123,6 +122,8 @@ function rewriteReport(report) { throw err; } + console.log('Report', report.exception.values[0].stacktrace.frames); + return report; } From b5a9e1a73af2b2d2f9313afe43c8074257186a9e Mon Sep 17 00:00:00 2001 From: sethkfman Date: Tue, 1 Aug 2023 16:23:10 -0600 Subject: [PATCH 2/4] updated with comments and removed console.log --- app/util/sentryUtils.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/util/sentryUtils.js b/app/util/sentryUtils.js index f5db117adc2..a1556d425db 100644 --- a/app/util/sentryUtils.js +++ b/app/util/sentryUtils.js @@ -72,6 +72,11 @@ function simplifyErrorMessages(report) { }); } +/** + * This function updates the request URL in the error report. + * It will take the origin and if there is none the with will provide "metamask-mobile" + * @param {Object} report + */ function rewriteReportUrls(report) { // update request url console.log('rewriteReportUrls', report); @@ -98,9 +103,7 @@ function toMetamaskUrl(origUrl) { return metamaskUrl; } - function rewriteReport(report) { - console.log('start', report.exception.values[0].stacktrace.frames); try { // simplify certain complex error messages (e.g. Ethjs) simplifyErrorMessages(report); @@ -122,8 +125,6 @@ function rewriteReport(report) { throw err; } - console.log('Report', report.exception.values[0].stacktrace.frames); - return report; } From e357a3453300e2aaa790161224c2560274ab2016 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Wed, 2 Aug 2023 10:00:13 -0600 Subject: [PATCH 3/4] remove unused function that was initally implemented so extension could have a single bundle --- app/util/sentryUtils.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/app/util/sentryUtils.js b/app/util/sentryUtils.js index a1556d425db..5cf1f94e4bc 100644 --- a/app/util/sentryUtils.js +++ b/app/util/sentryUtils.js @@ -72,17 +72,6 @@ function simplifyErrorMessages(report) { }); } -/** - * This function updates the request URL in the error report. - * It will take the origin and if there is none the with will provide "metamask-mobile" - * @param {Object} report - */ -function rewriteReportUrls(report) { - // update request url - console.log('rewriteReportUrls', report); - report.request.url = toMetamaskUrl(report.request.url); -} - function removeDeviceTimezone(report) { if (report.contexts && report.contexts.device) report.contexts.device.timezone = null; @@ -93,16 +82,6 @@ function removeDeviceName(report) { report.contexts.device.name = null; } -function toMetamaskUrl(origUrl) { - const filePath = origUrl?.split(location.origin)[1]; - if (!filePath) { - return origUrl; - } - - const metamaskUrl = 'metamask-mobile'; - return metamaskUrl; -} - function rewriteReport(report) { try { // simplify certain complex error messages (e.g. Ethjs) @@ -114,8 +93,6 @@ function rewriteReport(report) { // but putting the code here as well gives public visibility to how we are handling // privacy with respect to sentry. sanitizeAddressesFromErrorMessages(report); - // modify report urls - rewriteReportUrls(report); // remove device timezone removeDeviceTimezone(report); // remove device name From 1c52a8405a48c20f0d965889e432f03cf9390a36 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Wed, 2 Aug 2023 16:10:45 -0600 Subject: [PATCH 4/4] remove console.log --- app/util/sentryUtils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/util/sentryUtils.js b/app/util/sentryUtils.js index 5cf1f94e4bc..cf9fb4c07d2 100644 --- a/app/util/sentryUtils.js +++ b/app/util/sentryUtils.js @@ -34,7 +34,6 @@ function rewriteBreadcrumb(breadcrumb) { if (breadcrumb.data?.from) { breadcrumb.data.from = getProtocolFromURL(breadcrumb.data.from); } - console.log('Breadcrumb', breadcrumb); return breadcrumb; }