Skip to content
Open
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
37 changes: 37 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,43 @@ 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 ad-related errors from third-party scripts
beforeSend(event, hint) {
const error = hint.originalException
const errorMessage =
typeof error === 'string'
? error
: error instanceof Error
? error.message
: ''

// Check if the error is from ad-related scripts
const isAdRelatedScript = event.exception?.values?.some((exception) => {
return exception.stacktrace?.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')
)
})
})

// Check if the error message contains known ad-related error patterns
const hasAdRelatedErrorPattern =
errorMessage.includes('is not a function') ||
errorMessage.includes('contextWindow.parent') ||
errorMessage.includes('null is not an object')

// Filter out ad-related errors
if (isAdRelatedScript && hasAdRelatedErrorPattern) {
console.debug('Filtered ad-related error:', errorMessage)
return null // Drop the event
}

return event
},
})
}

Expand Down
Loading