tracker: skip check for tracker contexts array in restart

This commit is contained in:
nick-delirium 2024-11-14 16:35:43 +01:00
parent d2a5f42e37
commit 9678c86a13
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
3 changed files with 32 additions and 28 deletions

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package",
"version": "15.0.0",
"version": "15.0.1-3",
"keywords": [
"logging",
"replay"

View file

@ -506,34 +506,38 @@ export default class App {
return console.error('Couldnt connect to event.source for child iframe tracking')
}
const id = await this.checkNodeId(event.source)
if (id && !this.trackedFrames.includes(data.context)) {
try {
this.trackedFrames.push(data.context)
await this.waitStarted()
const token = this.session.getSessionToken()
const order = this.trackedFrames.findIndex((f) => f === data.context) + 1
if (order === 0) {
this.debug.error(
'Couldnt get order number for iframe',
data.context,
this.trackedFrames,
)
}
const iframeData = {
line: proto.iframeId,
id,
token,
// since indexes go from 0 we +1
frameOrderNumber: order,
}
this.debug.log('Got child frame signal; nodeId', id, event.source, iframeData)
// @ts-ignore
event.source?.postMessage(iframeData, '*')
} catch (e) {
console.error(e)
}
} else {
if (!id) {
this.debug.log('Couldnt get node id for iframe', event.source)
return
}
try {
if (this.trackedFrames.includes(data.context)) {
this.debug.log('Trying to observe already added iframe; ignore if its a restart')
} else {
this.trackedFrames.push(data.context)
}
await this.waitStarted()
const token = this.session.getSessionToken()
const order = this.trackedFrames.findIndex((f) => f === data.context) + 1
if (order === 0) {
this.debug.error(
'Couldnt get order number for iframe',
data.context,
this.trackedFrames,
)
}
const iframeData = {
line: proto.iframeId,
id,
token,
// since indexes go from 0 we +1
frameOrderNumber: order,
}
this.debug.log('Got child frame signal; nodeId', id, event.source, iframeData)
// @ts-ignore
event.source?.postMessage(iframeData, '*')
} catch (e) {
console.error(e)
}
}
void signalId()