File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,13 @@ export class OdpEventManager implements IOdpEventManager {
153153
154154 this . queueSize = queueSize || defaultQueueSize ;
155155 this . batchSize = batchSize || DEFAULT_BATCH_SIZE ;
156- this . flushInterval = flushInterval || DEFAULT_FLUSH_INTERVAL_MSECS ;
156+ if ( flushInterval === 0 ) {
157+ // disable event batching
158+ this . batchSize = 1 ;
159+ this . flushInterval = 0 ;
160+ } else {
161+ this . flushInterval = flushInterval || DEFAULT_FLUSH_INTERVAL_MSECS ;
162+ }
157163
158164 this . state = STATE . STOPPED ;
159165 }
Original file line number Diff line number Diff line change @@ -444,6 +444,33 @@ describe('OdpManager', () => {
444444 expect ( browserOdpManager . eventManager . flushInterval ) . toBe ( 4000 ) ;
445445 } ) ;
446446
447+ it ( 'Default ODP event flush interval is used when odpOptions does not include eventFlushInterval' , ( ) => {
448+ const odpOptions : OdpOptions = { } ;
449+
450+ const browserOdpManager = new BrowserOdpManager ( {
451+ odpOptions,
452+ } ) ;
453+
454+ // @ts -ignore
455+ expect ( browserOdpManager . eventManager . flushInterval ) . toBe ( 1000 ) ;
456+ } ) ;
457+
458+ it ( 'ODP event batch size set to one when odpOptions.eventFlushInterval set to 0' , ( ) => {
459+ const odpOptions : OdpOptions = {
460+ eventFlushInterval : 0 ,
461+ } ;
462+
463+ const browserOdpManager = new BrowserOdpManager ( {
464+ odpOptions,
465+ } ) ;
466+
467+ // @ts -ignore
468+ expect ( browserOdpManager . eventManager . flushInterval ) . toBe ( 0 ) ;
469+
470+ // @ts -ignore
471+ expect ( browserOdpManager . eventManager . batchSize ) . toBe ( 1 ) ;
472+ } ) ;
473+
447474 it ( 'Custom odpOptions.eventBatchSize overrides default Event Manager batch size' , ( ) => {
448475 const odpOptions : OdpOptions = {
449476 eventBatchSize : 2 ,
You can’t perform that action at this time.
0 commit comments