Skip to content

Commit 6636294

Browse files
fix: Suppress Publift Fuse cross-origin errors (#649)
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com> Co-authored-by: Tanner Linsley <[email protected]>
1 parent 4abe9d3 commit 6636294

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

src/components/Gam.tsx

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,71 @@ declare global {
3737

3838
export function GamOnPageChange() {
3939
if (typeof window === 'undefined' || !window.fusetag) return
40-
window.fusetag.que.push(function () {
41-
window.fusetag.pageInit()
42-
})
40+
try {
41+
window.fusetag.que.push(function () {
42+
try {
43+
window.fusetag.pageInit()
44+
} catch (error) {
45+
// Suppress cross-origin errors from Publift Fuse ad viewability measurement
46+
// These can occur on iOS Safari due to strict Same-Origin Policy enforcement
47+
console.debug('Error during fusetag.pageInit():', error)
48+
}
49+
})
50+
} catch (error) {
51+
// Suppress cross-origin errors from Publift Fuse ad viewability measurement
52+
console.debug('Error calling fusetag.que.push():', error)
53+
}
4354
}
4455

4556
export const GamScripts = () => (
4657
<>
58+
<script
59+
dangerouslySetInnerHTML={{
60+
__html: `
61+
// Add global error handler to suppress Publift Fuse cross-origin errors
62+
// These errors occur in iOS Safari due to strict Same-Origin Policy enforcement
63+
// when the ad viewability script tries to access parent window properties
64+
(function() {
65+
var originalErrorHandler = window.onerror;
66+
window.onerror = function(message, source, lineno, colno, error) {
67+
// Check if this is a Publift Fuse cross-origin error
68+
if (
69+
source && (
70+
source.includes('/media/native/') ||
71+
source.includes('fuse.js') ||
72+
source.includes('fuseplatform.net')
73+
) && (
74+
(message && typeof message === 'string' && (
75+
message.includes('contextWindow.parent') ||
76+
message.includes('null is not an object')
77+
)) ||
78+
(error && error.message && (
79+
error.message.includes('contextWindow.parent') ||
80+
error.message.includes('null is not an object')
81+
))
82+
)
83+
) {
84+
// Suppress the error - log to console in debug mode
85+
console.debug('Suppressed Publift Fuse cross-origin error:', message, source);
86+
return true; // Prevent default error handling
87+
}
88+
// Call original error handler for other errors
89+
if (originalErrorHandler) {
90+
return originalErrorHandler.apply(this, arguments);
91+
}
92+
return false;
93+
};
94+
})();
95+
`,
96+
}}
97+
/>
4798
<script
4899
async
49100
src="https://cdn.fuseplatform.net/publift/tags/2/4019/fuse.js"
101+
onError={(e) => {
102+
// Suppress script loading errors from Publift Fuse
103+
console.debug('Error loading fuse.js:', e)
104+
}}
50105
/>
51106
<script
52107
dangerouslySetInnerHTML={{

0 commit comments

Comments
 (0)