feat(tracker): method to force send all remaining messages

This commit is contained in:
nick-delirium 2023-07-10 11:18:13 +02:00
parent efd562321e
commit be55064786
4 changed files with 16 additions and 0 deletions

View file

@ -28,6 +28,7 @@ export type ToWorkerData =
| Array<Message>
| { type: 'compressed'; batch: Uint8Array }
| { type: 'uncompressed'; batch: Uint8Array }
| 'forceFlushBatch'
type Failure = {
type: 'failure'

View file

@ -662,6 +662,10 @@ export default class App {
}
}
forceFlushBatch() {
this.worker?.postMessage('forceFlushBatch')
}
getTabId() {
return this.session.getTabId()
}

View file

@ -242,6 +242,13 @@ export default class API {
return this.app.session.getSessionHash()
}
forceFlushBatch() {
if (this.app === null) {
return
}
this.app.forceFlushBatch()
}
getSessionToken(): string | null | undefined {
if (this.app === null) {
return null

View file

@ -86,6 +86,10 @@ self.onmessage = ({ data }: { data: ToWorkerData }): any => {
reset()
return (workerStatus = WorkerStatus.Stopped)
}
if (data === 'forceFlushBatch') {
finalize()
return
}
if (Array.isArray(data)) {
if (writer !== null) {