From 4dc9f71946fb7e2b72b3f99726a699507c95ba26 Mon Sep 17 00:00:00 2001 From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:03:24 +0300 Subject: [PATCH] Merge pull request #9112 from overleaf/ii-sentry-extension-errors [web] Prevent logging of extension errors to Sentry GitOrigin-RevId: 42bc4ec045585586d2a6fe695cd55ef98adf2bf9 --- .../js/infrastructure/error-reporter.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/infrastructure/error-reporter.js b/services/web/frontend/js/infrastructure/error-reporter.js index e58f715398..75b4632b7b 100644 --- a/services/web/frontend/js/infrastructure/error-reporter.js +++ b/services/web/frontend/js/infrastructure/error-reporter.js @@ -40,6 +40,12 @@ function sentryReporter() { /Non-Error promise rejection captured with value: Object Not Found Matching Id/, ], + denyUrls: [ + // Chrome extensions + /extensions\//i, + /^chrome:\/\//i, + ], + beforeSend(event) { // Limit number of events sent to Sentry to 100 events "per page load", // (i.e. the cap will be reset if the page is reloaded). This prevent @@ -47,9 +53,16 @@ function sentryReporter() { eventCount++ if (eventCount > 100) { return null // Block the event from sending - } else { - return event } + + // Do not send events related to third party code (extensions) + if ( + event.extra?.arguments?.[0]?.type === 'UNSTABLE_editor:extensions' + ) { + return null // Block the event from sending + } + + return event }, })