Skip to content
Merged
Show file tree
Hide file tree
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
44 changes: 0 additions & 44 deletions src/components/Gam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,6 @@ export function GamOnPageChange() {

export const GamScripts = () => (
<>
<script
dangerouslySetInnerHTML={{
__html: `
// Add global error handler to suppress Publift Fuse cross-origin errors
// These errors occur in iOS Safari due to strict Same-Origin Policy enforcement
// when the ad viewability script tries to access parent window properties
// Also suppress race condition errors during navigation
(function() {
var originalErrorHandler = window.onerror;
window.onerror = function(message, source, lineno, colno, error) {
// Check if this is a Publift Fuse cross-origin error
if (
source && (
source.includes('/media/native/') ||
source.includes('fuse.js') ||
source.includes('fuseplatform.net') ||
source.includes('/nobid/blocking_script.js')
) && (
(message && typeof message === 'string' && (
message.includes('contextWindow.parent') ||
message.includes('null is not an object') ||
message.includes('is not a function')
)) ||
(error && error.message && (
error.message.includes('contextWindow.parent') ||
error.message.includes('null is not an object') ||
error.message.includes('is not a function')
))
)
) {
// Suppress the error - log to console in debug mode
console.debug('Suppressed Publift Fuse cross-origin error:', message, source);
return true; // Prevent default error handling
}
// Call original error handler for other errors
if (originalErrorHandler) {
return originalErrorHandler.apply(this, arguments);
}
return false;
};
})();
`,
}}
/>
<script
async
src="https://cdn.fuseplatform.net/publift/tags/2/4019/fuse.js"
Expand Down
41 changes: 41 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,47 @@ 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.
beforeSend(event, hint) {
// Filter out Publift Fuse and ad script errors that are expected
// These errors occur in iOS Safari and during navigation due to strict Same-Origin Policy
// and race conditions with ad script initialization
const error = hint.originalException
const errorMessage =
typeof error === 'string'
? error
: error instanceof Error
? error.message
: ''

// Check if this is an ad script error we want to suppress
const frames = event.exception?.values?.[0]?.stacktrace?.frames || []
const hasAdScriptFrame = frames.some((frame) => {
const filename = frame.filename || ''
return (
filename.includes('/media/native/') ||
filename.includes('fuse.js') ||
filename.includes('fuseplatform.net') ||
filename.includes('/nobid/blocking_script.js')
)
})

const hasExpectedErrorMessage =
errorMessage.includes('contextWindow.parent') ||
errorMessage.includes('null is not an object') ||
errorMessage.includes('is not a function')

if (hasAdScriptFrame && hasExpectedErrorMessage) {
// Suppress the error - log to console in debug mode
console.debug(
'Suppressed Publift Fuse/ad script error:',
errorMessage,
frames[0]?.filename,
)
return null // Don't send to Sentry
}

return event
},
})
}

Expand Down