Skip to content
Merged
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
61 changes: 58 additions & 3 deletions src/components/Gam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,71 @@ declare global {

export function GamOnPageChange() {
if (typeof window === 'undefined' || !window.fusetag) return
window.fusetag.que.push(function () {
window.fusetag.pageInit()
})
try {
window.fusetag.que.push(function () {
try {
window.fusetag.pageInit()
} catch (error) {
// Suppress cross-origin errors from Publift Fuse ad viewability measurement
// These can occur on iOS Safari due to strict Same-Origin Policy enforcement
console.debug('Error during fusetag.pageInit():', error)
}
})
} catch (error) {
// Suppress cross-origin errors from Publift Fuse ad viewability measurement
console.debug('Error calling fusetag.que.push():', error)
}
}

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
(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')
) && (
(message && typeof message === 'string' && (
message.includes('contextWindow.parent') ||
message.includes('null is not an object')
)) ||
(error && error.message && (
error.message.includes('contextWindow.parent') ||
error.message.includes('null is not an object')
))
)
) {
// 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"
onError={(e) => {
// Suppress script loading errors from Publift Fuse
console.debug('Error loading fuse.js:', e)
}}
/>
<script
dangerouslySetInnerHTML={{
Expand Down
Loading