@@ -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
3636function 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
5053Sentry . 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 : [ / u s e r s c r i p t / 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