Skip to content

Commit e3f3bee

Browse files
authored
fix: fixes buffering for legacy destinations (#1067)
1 parent fd09fbc commit e3f3bee

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/three-turkeys-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': patch
3+
---
4+
5+
fix: fixes buffering for legacy destinations

packages/browser/src/plugins/ajs-destination/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class LegacyDestination implements InternalPluginWithAddMiddleware {
192192
return (
193193
// page events can't be buffered because of destinations that automatically add page views
194194
ctx.event.type !== 'page' &&
195-
(isOffline() || this._ready === false || this._initialized === false)
195+
(isOffline() || this._ready !== true || this._initialized !== true)
196196
)
197197
}
198198

@@ -313,6 +313,11 @@ export class LegacyDestination implements InternalPluginWithAddMiddleware {
313313

314314
// eslint-disable-next-line @typescript-eslint/no-misused-promises
315315
setTimeout(async () => {
316+
if (isOffline() || this._ready !== true || this._initialized !== true) {
317+
this.scheduleFlush()
318+
return
319+
}
320+
316321
this.flushing = true
317322
this.buffer = await flushQueue(this, this.buffer)
318323
this.flushing = false

0 commit comments

Comments
 (0)