Skip to content

Commit 5a2072c

Browse files
authored
Merge branch 'master' into jae/8690-config-timeout
2 parents 2b8119c + 790e154 commit 5a2072c

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

packages/optimizely-sdk/lib/core/odp/odp_event_manager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

packages/optimizely-sdk/tests/odpManager.browser.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,33 @@ describe('OdpManager', () => {
463463
expect(browserOdpManager.eventManager.flushInterval).toBe(4000);
464464
});
465465

466+
it('Default ODP event flush interval is used when odpOptions does not include eventFlushInterval', () => {
467+
const odpOptions: OdpOptions = {};
468+
469+
const browserOdpManager = new BrowserOdpManager({
470+
odpOptions,
471+
});
472+
473+
// @ts-ignore
474+
expect(browserOdpManager.eventManager.flushInterval).toBe(1000);
475+
});
476+
477+
it('ODP event batch size set to one when odpOptions.eventFlushInterval set to 0', () => {
478+
const odpOptions: OdpOptions = {
479+
eventFlushInterval: 0,
480+
};
481+
482+
const browserOdpManager = new BrowserOdpManager({
483+
odpOptions,
484+
});
485+
486+
// @ts-ignore
487+
expect(browserOdpManager.eventManager.flushInterval).toBe(0);
488+
489+
// @ts-ignore
490+
expect(browserOdpManager.eventManager.batchSize).toBe(1);
491+
});
492+
466493
it('Custom odpOptions.eventBatchSize overrides default Event Manager batch size', () => {
467494
const odpOptions: OdpOptions = {
468495
eventBatchSize: 2,

0 commit comments

Comments
 (0)