diff --git a/tracker/tracker/src/main/index.ts b/tracker/tracker/src/main/index.ts index 2d090aebf..9349c05ca 100644 --- a/tracker/tracker/src/main/index.ts +++ b/tracker/tracker/src/main/index.ts @@ -97,7 +97,7 @@ function processOptions(obj: any): obj is Options { const canAccessTop = () => { try { - return Boolean(window.top) + return Boolean(window.top?.document) } catch { return false } @@ -116,7 +116,7 @@ export default class API { } if ( (window as any).__OPENREPLAY__ || - (!this.crossdomainMode && inIframe() && canAccessTop() && (window.top as any)?.__OPENREPLAY__) + (!this.crossdomainMode && inIframe() && canAccessTop() && (window.top as any).__OPENREPLAY__) ) { console.error('OpenReplay: one tracker instance has been initialised already') return