Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
})
}

Expand Down
Loading