Skip to content

Commit 0ec1c38

Browse files
awaseemcharislam
andauthored
Fix: Update sentry to ignore events that are causing noise (supabase#40190)
* updated sentry client to support deny urls * Update apps/studio/instrumentation-client.ts Co-authored-by: Charis <[email protected]> * updated formatting * removed unneed extensions --------- Co-authored-by: Charis <[email protected]>
1 parent 4ae3a6e commit 0ec1c38

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

apps/studio/instrumentation-client.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,29 @@ function isHCaptchaRelatedError(event: Sentry.Event): boolean {
3434
// and has a specific pre_context comment that we can use for filtering.
3535
// Copied from docs app instrumentation-client.ts
3636
function isThirdPartyError(frames: Sentry.StackFrame[] | undefined) {
37-
if (!frames) return false
37+
if (!frames || frames.length === 0) return false
3838

3939
function isSentryFrame(frame: Sentry.StackFrame, index: number) {
40-
return index === 0 && frame.pre_context?.[0]?.includes('sentry.javascript')
40+
return index === 0 && frame.pre_context?.some((line) => line.includes('sentry.javascript'))
4141
}
4242

43-
return !frames.some((frame, index) => {
44-
// Check both abs_path and filename for paths starting with app:///_next.
43+
// Check if any frame is from our app (excluding Sentry's own frame)
44+
const hasAppFrame = frames.some((frame, index) => {
4545
const path = frame.abs_path || frame.filename
4646
return path?.startsWith('app:///_next') && !isSentryFrame(frame, index)
4747
})
48+
49+
// If no app frames found, it's a third-party error
50+
return !hasAppFrame
4851
}
4952

5053
Sentry.init({
5154
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5255
// Setting this option to true will print useful information to the console while you're setting up Sentry.
5356
debug: false,
57+
// [Ali] Filter out browser extensions and user scripts (FE-2094)
58+
// Using denyUrls to block known third-party script patterns
59+
denyUrls: [/userscript/i],
5460
beforeBreadcrumb(breadcrumb, _hint) {
5561
const cleanedBreadcrumb = { ...breadcrumb }
5662

@@ -95,7 +101,6 @@ Sentry.init({
95101
}
96102

97103
const frames = event.exception?.values?.[0].stacktrace?.frames || []
98-
99104
if (isThirdPartyError(frames)) {
100105
return null
101106
}

0 commit comments

Comments
 (0)