tracker: rm idlecb

This commit is contained in:
nick-delirium 2025-02-28 17:28:52 +01:00
parent 13ae208462
commit a35d0d06f2
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 30 additions and 32 deletions

View file

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

View file

@ -92,38 +92,36 @@ export default class BatchWriter {
}
writeMessage(message: Message) {
requestIdleCb(() => {
// @ts-ignore
if (message[0] === 'q_end') {
this.finaliseBatch()
return this.onOfflineEnd()
}
if (message[0] === Messages.Type.Timestamp) {
this.timestamp = message[1] // .timestamp
}
if (message[0] === Messages.Type.SetPageLocation) {
this.url = message[1] // .url
}
if (this.writeWithSize(message)) {
return
}
// buffer overflow, send already written data first then try again
// @ts-ignore
if (message[0] === 'q_end') {
this.finaliseBatch()
if (this.writeWithSize(message)) {
return
}
// buffer is too small. Creating one with maximal capacity for this message only
this.encoder = new MessageEncoder(this.beaconSizeLimit)
this.prepare()
if (!this.writeWithSize(message)) {
console.warn('OpenReplay: beacon size overflow. Skipping large message.', message, this)
} else {
this.finaliseBatch()
}
// reset encoder to normal size
this.encoder = new MessageEncoder(this.beaconSize)
this.prepare()
})
return this.onOfflineEnd()
}
if (message[0] === Messages.Type.Timestamp) {
this.timestamp = message[1] // .timestamp
}
if (message[0] === Messages.Type.SetPageLocation) {
this.url = message[1] // .url
}
if (this.writeWithSize(message)) {
return
}
// buffer overflow, send already written data first then try again
this.finaliseBatch()
if (this.writeWithSize(message)) {
return
}
// buffer is too small. Creating one with maximal capacity for this message only
this.encoder = new MessageEncoder(this.beaconSizeLimit)
this.prepare()
if (!this.writeWithSize(message)) {
console.warn('OpenReplay: beacon size overflow. Skipping large message.', message, this)
} else {
this.finaliseBatch()
}
// reset encoder to normal size
this.encoder = new MessageEncoder(this.beaconSize)
this.prepare()
}
finaliseBatch() {