From d3025a9270b214b185af79fde1085e0231a8b682 Mon Sep 17 00:00:00 2001 From: Andrey Sokolov Date: Thu, 27 Apr 2023 19:04:50 +0400 Subject: [PATCH] fix: do not overwrite flushIntervalMillis=0 with default value (10 seconds) --- packages/analytics-core/src/config.ts | 2 +- packages/analytics-core/test/config.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/analytics-core/src/config.ts b/packages/analytics-core/src/config.ts index b882cd7e5..e2a3e86d0 100644 --- a/packages/analytics-core/src/config.ts +++ b/packages/analytics-core/src/config.ts @@ -58,7 +58,7 @@ export class Config implements IConfig { constructor(options: Options) { const defaultConfig = getDefaultConfig(); this.apiKey = options.apiKey; - this.flushIntervalMillis = options.flushIntervalMillis || defaultConfig.flushIntervalMillis; + this.flushIntervalMillis = options.flushIntervalMillis ?? defaultConfig.flushIntervalMillis; this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries; this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize; this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider; diff --git a/packages/analytics-core/test/config.test.ts b/packages/analytics-core/test/config.test.ts index 3e2563968..8becab36f 100644 --- a/packages/analytics-core/test/config.test.ts +++ b/packages/analytics-core/test/config.test.ts @@ -109,4 +109,15 @@ describe('config', () => { }); }); }); + + test('should not overwrite flushIntervalMillis=0 with default value', () => { + const defaultConfig = useDefaultConfig(); + const config = new Config({ + apiKey: API_KEY, + storageProvider: defaultConfig.storageProvider, + transportProvider: defaultConfig.transportProvider, + flushIntervalMillis: 0, + }); + expect(config.flushIntervalMillis).toEqual(0); + }); });