fix(OUT-3553): drop browser-extension noise from Sentry - #196
fix(OUT-3553): drop browser-extension noise from Sentry#196priosshrsth wants to merge 3 commits into
Conversation
A multichainWallet crypto wallet extension was leaking "Origin not allowed" errors into Sentry via console-log forwarding. The throw originates inside the extension's content script (its own origin allowlist check) and has nothing to do with our code. Add two filters in the client Sentry init: - `denyUrls` for chrome-/moz-/safari-extension:// so native exceptions originating in extension-owned code are dropped by stack frame. - `beforeSend` marker check that catches extension content scripts logging via console in our page context (no stack frame to filter on). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds two Sentry client-side filters to suppress browser-extension console errors from polluting the project's issue feed: a
Confidence Score: 4/5Safe to merge after fixing the breadcrumb One P1 defect: the breadcrumb path of src/instrumentation-client.ts — specifically line 28 ( Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Sentry captures event] --> B{denyUrls match?\nTop stack frame in\nextension:// URL?}
B -- Yes --> C[Drop event]
B -- No --> D{beforeSend:\nisBrowserExtensionNoise?}
D --> E[JSON.stringify probe\nmessage + exception\n+ extra + breadcrumbs]
E --> F{breadcrumbs exists?}
F -- No --> G[probe includes message/exception/extra only]
F -- Yes --> H['.slice -10' throws TypeError\n→ catch returns false\n⚠️ breadcrumb path broken]
G --> I{Any EXTENSION_NOISE_MARKERS\nin probe?}
H --> I
I -- Yes --> J[Return null → Drop event]
I -- No --> K[Return event → Send to Sentry]
Reviews (1): Last reviewed commit: "fix(OUT-3553): drop browser-extension no..." | Re-trigger Greptile |
| message: event.message, | ||
| exception: event.exception, | ||
| extra: event.extra, | ||
| breadcrumbs: event.breadcrumbs?.slice(-10), |
There was a problem hiding this comment.
Breadcrumbs are an object, not an array —
.slice() always throws
Sentry.ErrorEvent.breadcrumbs is typed as { values?: Breadcrumb[] } | undefined, not an array. Calling .slice(-10) on the wrapper object throws TypeError: event.breadcrumbs.slice is not a function, which the try/catch silently swallows, returning false. This means the breadcrumb path of the probe is always empty — any extension noise that only surfaces in breadcrumbs (e.g., a console.log breadcrumb containing multichainWallet) will not be filtered.
The fix is to access .values first:
| breadcrumbs: event.breadcrumbs?.slice(-10), | |
| breadcrumbs: event.breadcrumbs?.values?.slice(-10), |
| 'postMessageToContentScript', | ||
| 'chrome-extension://', | ||
| 'moz-extension://', | ||
| 'safari-web-extension://', |
There was a problem hiding this comment.
safari-extension:// missing from string markers
The denyUrls regex uses safari(-web)?-extension://, which matches both safari-extension:// and safari-web-extension://. The EXTENSION_NOISE_MARKERS list only includes safari-web-extension://, leaving safari-extension:// uncovered for the isBrowserExtensionNoise content-scan path. For consistency, add the plain variant:
| 'safari-web-extension://', | |
| 'safari-web-extension://', | |
| 'safari-extension://', |
`postMessageToContentScript` is a generic function name that could in theory collide with legit console output. `contentscriptFunctionCall` (the message `type` discriminator) and `multichainWallet` are specific enough to stand on their own. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the secondary markers and the breadcrumb probe; `multichainWallet` in the event payload is specific enough on its own, and `denyUrls` still handles extension-originated native exceptions by stack frame. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Changes
denyUrlslist in the client Sentry init forchrome-extension://,moz-extension://, andsafari(-web)?-extension://so any native exception whose top stack frame lives in extension-owned code is dropped.beforeSendmarker filter that drops events whose serialized message / exception / extra / recent breadcrumbs contain any of:multichainWallet,contentscriptFunctionCall,postMessageToContentScript, or the extension URL schemes. This catches extensions that inject content scripts into our page context and log errors viaconsole(no stack frame todenyUrlson).Root cause (OUT-3553)
The Sentry issue "Error: Origin not allowed" was being emitted from a visitor's crypto wallet browser extension. The Sentry event payload included:
This is the extension's own content script failing its own origin-allowlist check and logging via
console.error. BecauseenableLogs: trueis on in the client init, Sentry's console integration captures those logs and files them against our project. Nothing in our code triggers this, there is no user-facing impact, and there is no fix possible on the producer side (we don't control the extension).Testing Criteria
throw new Error('sentry-smoke-test')in the console and confirm it does appear in Sentry with stack + replay.Notes
EXTENSION_NOISE_MARKERS.Impact & Surface Area of Change
src/instrumentation-client.tsis touched. Behavior change is limited to the client Sentry pipeline: two extra short-circuits before events are sent.tracesSampleRate,enableLogs,sendDefaultPiiare all preserved.🤖 Generated with Claude Code