Skip to content

Commit d429296

Browse files
authored
Fix: Improve Sentry ad script error suppression
1 parent abf8e7a commit d429296

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/router.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,42 @@ export function getRouter() {
7272

7373
// Check if this is an ad script error we want to suppress
7474
const frames = event.exception?.values?.[0]?.stacktrace?.frames || []
75-
const hasAdScriptFrame = frames.some((frame) => {
75+
76+
// More robust filename checking - check all frames for ad script patterns
77+
const hasAdScriptFrame = frames.length > 0 && frames.some((frame) => {
7678
const filename = frame.filename || ''
79+
// Normalize filename to handle both absolute URLs and relative paths
80+
const normalizedFilename = filename.toLowerCase()
7781
return (
78-
filename.includes('/media/native/') ||
79-
filename.includes('fuse.js') ||
80-
filename.includes('fuseplatform.net') ||
81-
filename.includes('/nobid/blocking_script.js')
82+
normalizedFilename.includes('/media/native/') ||
83+
normalizedFilename.includes('fuse.js') ||
84+
normalizedFilename.includes('fuseplatform.net') ||
85+
normalizedFilename.includes('/nobid/blocking_script.js') ||
86+
normalizedFilename.includes('blocking_script.js') ||
87+
// Check function name patterns from nobid script
88+
frame.function === 'BQ' ||
89+
frame.function === 'Navigation.<anonymous>'
8290
)
8391
})
8492

93+
// Check for specific error messages from ad scripts
8594
const hasExpectedErrorMessage =
8695
errorMessage.includes('contextWindow.parent') ||
8796
errorMessage.includes('null is not an object') ||
88-
errorMessage.includes('is not a function')
97+
errorMessage.includes('is not a function') ||
98+
// Specific nobid script errors
99+
errorMessage.includes('tG is not a function') ||
100+
errorMessage.includes('KShg7B3')
89101

90102
if (hasAdScriptFrame && hasExpectedErrorMessage) {
91103
// Suppress the error - log to console in debug mode
92104
console.debug(
93105
'Suppressed Publift Fuse/ad script error:',
94106
errorMessage,
107+
'Frame:',
95108
frames[0]?.filename,
109+
'Function:',
110+
frames[0]?.function,
96111
)
97112
return null // Don't send to Sentry
98113
}

0 commit comments

Comments
 (0)