some debugging

This commit is contained in:
nick-delirium 2024-10-28 13:54:15 +01:00
parent 54e2fa6626
commit 3aae1aafc1
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
6 changed files with 16 additions and 9 deletions

View file

@ -1,3 +1,8 @@
## 14.0.13
- fixes for restart logic
- fixed top context check in case of crossdomain placement
## 14.0.11 & .12
- fix for node maintainer stability around `#document` nodes (mainly iframes field)

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package",
"version": "14.0.13-beta.3",
"version": "14.0.14-0",
"keywords": [
"logging",
"replay"

View file

@ -30,11 +30,4 @@ export default class IFrameObserver extends Observer {
this.app.send(CreateIFrameDocument(rootNodeId, docID))
})
}
disconnect() {
if (this.docId !== undefined) {
this.app.send(RemoveNode(this.docId))
}
super.disconnect()
}
}

View file

@ -95,6 +95,14 @@ function processOptions(obj: any): obj is Options {
return true
}
const canAccessTop = () => {
try {
return Boolean(window.top)
} catch {
return false
}
}
export default class API {
public featureFlags: FeatureFlags
@ -104,11 +112,12 @@ export default class API {
constructor(private readonly options: Options) {
this.crossdomainMode = Boolean(inIframe() && options.crossdomain?.enabled)
if (!IN_BROWSER || !processOptions(options)) {
console.error('OpenReplay: tracker called in a non-browser environment or with invalid options')
return
}
if (
(window as any).__OPENREPLAY__ ||
(!this.crossdomainMode && inIframe() && (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