From aa3a7799dc07697d5ae72effcbae2c4cd9652f5c Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:58:17 +0000 Subject: [PATCH] fix: Suppress Sentry errors from third-party ad scripts --- src/router.tsx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/router.tsx b/src/router.tsx index 56988a9c..a4ac4415 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -58,6 +58,59 @@ export function getRouter() { // Session Replay replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur. + // Filter out known third-party errors from ad scripts + beforeSend(event, hint) { + // Check if the error originated from third-party ad scripts + const frames = event.exception?.values?.[0]?.stacktrace?.frames + const errorMessage = event.exception?.values?.[0]?.value || '' + const originalException = hint.originalException + + // Filter out errors from Publift Fuse ad viewability scripts + if (frames) { + const hasThirdPartyAdScript = frames.some((frame) => { + const filename = frame.filename || '' + return ( + filename.includes('/nobid/blocking_script.js') || + filename.includes('/media/native/') || + filename.includes('fuse.js') || + filename.includes('fuseplatform.net') + ) + }) + + // Filter race condition errors from ad scripts + if (hasThirdPartyAdScript) { + const isRaceConditionError = + errorMessage.includes('is not a function') || + errorMessage.includes('null is not an object') || + errorMessage.includes('contextWindow.parent') + + if (isRaceConditionError) { + return null // Drop the error + } + } + } + + // Also check the error message directly for ad script errors + if ( + originalException && + typeof originalException === 'object' && + 'message' in originalException + ) { + const message = String(originalException.message) + if ( + (message.includes('is not a function') || + message.includes('null is not an object') || + message.includes('contextWindow.parent')) && + (message.includes('blocking_script') || + message.includes('fuse') || + message.includes('fuseplatform')) + ) { + return null // Drop the error + } + } + + return event + }, }) }