This repository was archived by the owner on Feb 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,7 @@ class Analytics {
219
219
const hasReachedQueueSize = this . queue . reduce ( ( acc , item ) => acc + JSON . stringify ( item ) . length , 0 ) >= this . maxQueueSize
220
220
if ( hasReachedFlushAt || hasReachedQueueSize ) {
221
221
this . flush ( callback )
222
+ return
222
223
}
223
224
224
225
if ( this . flushInterval && ! this . timer ) {
Original file line number Diff line number Diff line change @@ -267,6 +267,22 @@ test('enqueue - don\'t reset an existing timer', async t => {
267
267
t . true ( client . flush . calledOnce )
268
268
} )
269
269
270
+ test ( 'enqueue - prevent flushing through time interval when already flushed by flushAt' , async t => {
271
+ const client = createClient ( { flushAt : 2 , flushInterval : 10 } )
272
+ client . flushed = false
273
+ spy ( client , 'flush' )
274
+
275
+ client . enqueue ( 'type' , { } )
276
+ t . true ( client . flush . calledOnce )
277
+
278
+ client . enqueue ( 'type' , { } )
279
+ client . enqueue ( 'type' , { } )
280
+ t . true ( client . flush . calledTwice )
281
+
282
+ await delay ( 10 )
283
+ t . true ( client . flush . calledTwice )
284
+ } )
285
+
270
286
test ( 'enqueue - extend context' , t => {
271
287
const client = createClient ( )
272
288
You can’t perform that action at this time.
0 commit comments