@splitsoftware/splitio-commons 1.6.2-rc.1 → 1.6.2-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/cjs/sdkFactory/index.js +4 -3
  2. package/cjs/services/splitApi.js +2 -2
  3. package/cjs/storages/inLocalStorage/index.js +4 -0
  4. package/cjs/storages/inMemory/InMemoryStorage.js +5 -1
  5. package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -1
  6. package/cjs/storages/inMemory/uniqueKeysCacheInMemory.js +73 -0
  7. package/cjs/storages/inMemory/uniqueKeysCacheInMemoryCS.js +78 -0
  8. package/cjs/sync/submitters/telemetrySubmitter.js +1 -0
  9. package/cjs/sync/submitters/uniqueKeysSubmitter.js +14 -58
  10. package/cjs/trackers/strategy/strategyNone.js +1 -1
  11. package/cjs/trackers/uniqueKeysTracker.js +5 -43
  12. package/cjs/utils/constants/index.js +3 -2
  13. package/esm/sdkFactory/index.js +4 -3
  14. package/esm/services/splitApi.js +2 -2
  15. package/esm/storages/inLocalStorage/index.js +5 -1
  16. package/esm/storages/inMemory/InMemoryStorage.js +6 -2
  17. package/esm/storages/inMemory/InMemoryStorageCS.js +6 -2
  18. package/esm/storages/inMemory/uniqueKeysCacheInMemory.js +70 -0
  19. package/esm/storages/inMemory/uniqueKeysCacheInMemoryCS.js +75 -0
  20. package/esm/sync/submitters/telemetrySubmitter.js +2 -1
  21. package/esm/sync/submitters/uniqueKeysSubmitter.js +13 -55
  22. package/esm/trackers/strategy/strategyNone.js +1 -1
  23. package/esm/trackers/uniqueKeysTracker.js +5 -43
  24. package/esm/utils/constants/index.js +1 -0
  25. package/package.json +1 -1
  26. package/src/sdkFactory/index.ts +4 -3
  27. package/src/services/splitApi.ts +2 -2
  28. package/src/storages/inLocalStorage/index.ts +4 -1
  29. package/src/storages/inMemory/InMemoryStorage.ts +5 -2
  30. package/src/storages/inMemory/InMemoryStorageCS.ts +6 -2
  31. package/src/storages/inMemory/uniqueKeysCacheInMemory.ts +83 -0
  32. package/src/storages/inMemory/uniqueKeysCacheInMemoryCS.ts +89 -0
  33. package/src/storages/types.ts +9 -6
  34. package/src/sync/submitters/telemetrySubmitter.ts +4 -3
  35. package/src/sync/submitters/uniqueKeysSubmitter.ts +15 -59
  36. package/src/trackers/impressionsTracker.ts +0 -1
  37. package/src/trackers/strategy/strategyNone.ts +1 -1
  38. package/src/trackers/types.ts +3 -7
  39. package/src/trackers/uniqueKeysTracker.ts +6 -49
  40. package/src/types.ts +1 -0
  41. package/src/utils/constants/index.ts +1 -0
  42. package/types/storages/inMemory/uniqueKeysCacheInMemory.d.ts +32 -0
  43. package/types/storages/inMemory/uniqueKeysCacheInMemoryCS.d.ts +37 -0
  44. package/types/storages/types.d.ts +8 -11
  45. package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -14
  46. package/types/trackers/types.d.ts +3 -11
  47. package/types/trackers/uniqueKeysTracker.d.ts +3 -3
  48. package/types/types.d.ts +1 -0
  49. package/types/utils/constants/index.d.ts +1 -0
@@ -1,8 +1,7 @@
1
1
  import { MaybeThenable, IMetadata, ISplitFiltersValidation } from '../dtos/types';
2
2
  import { ILogger } from '../logger/types';
3
- import { EventDataType, HttpErrors, HttpLatencies, ImpressionDataType, LastSync, Method, MethodExceptions, MethodLatencies, OperationType, StoredEventWithMetadata, StoredImpressionWithMetadata, StreamingEvent } from '../sync/submitters/types';
3
+ import { EventDataType, HttpErrors, HttpLatencies, ImpressionDataType, LastSync, Method, MethodExceptions, MethodLatencies, OperationType, StoredEventWithMetadata, StoredImpressionWithMetadata, StreamingEvent, UniqueKeysPayloadCs, UniqueKeysPayloadSs } from '../sync/submitters/types';
4
4
  import { SplitIO, ImpressionDTO, SDKMode } from '../types';
5
- import { ISet } from '../utils/lang/sets';
6
5
 
7
6
  /**
8
7
  * Interface of a pluggable storage wrapper.
@@ -356,13 +355,16 @@ export interface IImpressionCountsCacheSync extends IRecorderCacheProducerSync<R
356
355
  pop(toMerge?: Record<string, number> ): Record<string, number> // pop cache data
357
356
  }
358
357
 
359
- export interface IUniqueKeysCacheBase extends IRecorderCacheProducerSync<{ [featureName: string]: ISet<string> }>{
358
+ export interface IUniqueKeysCacheBase {
360
359
  // Used by unique Keys tracker
361
- track(featureName: string, timeFrame: number, amount: number): void
360
+ track(key: string, value: string): void
362
361
 
363
362
  // Used by unique keys submitter in standalone and producer mode
364
363
  isEmpty(): boolean // check if cache is empty. Return true if the cache was just created or cleared.
365
- pop(toMerge?: { [featureName: string]: ISet<string> } ): { [featureName: string]: ISet<string> } // pop cache data
364
+ pop(): UniqueKeysPayloadSs | UniqueKeysPayloadCs // pop cache data
365
+ /* Registers callback for full queue */
366
+ setOnFullQueueCb(cb: () => void): void,
367
+ clear(): void
366
368
  }
367
369
 
368
370
  /**
@@ -493,10 +495,11 @@ export type DataLoader = (storage: IStorageSync, matchingKey: string) => void
493
495
  export interface IStorageFactoryParams {
494
496
  log: ILogger,
495
497
  impressionsQueueSize?: number,
498
+ uniqueKeysCacheSize?: number;
496
499
  eventsQueueSize?: number,
497
500
  optimize?: boolean /* whether create the `impressionCounts` cache (OPTIMIZED impression mode) or not (DEBUG impression mode) */,
498
501
  mode: SDKMode,
499
-
502
+ impressionsMode?: string,
500
503
  // ATM, only used by InLocalStorage
501
504
  matchingKey?: string, /* undefined on server-side SDKs */
502
505
  splitFiltersValidation?: ISplitFiltersValidation,
@@ -1,7 +1,7 @@
1
1
  import { ISegmentsCacheSync, ISplitsCacheSync, ITelemetryCacheSync } from '../../storages/types';
2
2
  import { submitterFactory, firstPushWindowDecorator } from './submitter';
3
3
  import { TelemetryUsageStatsPayload, TelemetryConfigStatsPayload, TelemetryConfigStats } from './types';
4
- import { QUEUED, DEDUPED, DROPPED, CONSUMER_MODE, CONSUMER_ENUM, STANDALONE_MODE, CONSUMER_PARTIAL_MODE, STANDALONE_ENUM, CONSUMER_PARTIAL_ENUM, OPTIMIZED, DEBUG, DEBUG_ENUM, OPTIMIZED_ENUM, CONSENT_GRANTED, CONSENT_DECLINED, CONSENT_UNKNOWN } from '../../utils/constants';
4
+ import { QUEUED, DEDUPED, DROPPED, CONSUMER_MODE, CONSUMER_ENUM, STANDALONE_MODE, CONSUMER_PARTIAL_MODE, STANDALONE_ENUM, CONSUMER_PARTIAL_ENUM, OPTIMIZED, DEBUG, NONE, DEBUG_ENUM, OPTIMIZED_ENUM, NONE_ENUM, CONSENT_GRANTED, CONSENT_DECLINED, CONSENT_UNKNOWN } from '../../utils/constants';
5
5
  import { SDK_READY, SDK_READY_FROM_CACHE } from '../../readiness/constants';
6
6
  import { ConsentStatus, ISettings, SDKMode } from '../../types';
7
7
  import { base } from '../../utils/settingsValidation';
@@ -52,8 +52,9 @@ const OPERATION_MODE_MAP = {
52
52
 
53
53
  const IMPRESSIONS_MODE_MAP = {
54
54
  [OPTIMIZED]: OPTIMIZED_ENUM,
55
- [DEBUG]: DEBUG_ENUM
56
- } as Record<ISettings['sync']['impressionsMode'], (0 | 1)>;
55
+ [DEBUG]: DEBUG_ENUM,
56
+ [NONE]: NONE_ENUM
57
+ } as Record<ISettings['sync']['impressionsMode'], (0 | 1 | 2)>;
57
58
 
58
59
  const USER_CONSENT_MAP = {
59
60
  [CONSENT_UNKNOWN]: 1,
@@ -1,63 +1,8 @@
1
+ import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
1
2
  import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
- import { ISet, setToArray } from '../../utils/lang/sets';
3
3
  import { submitterFactory } from './submitter';
4
- import { UniqueKeysPayloadCs, UniqueKeysPayloadSs } from './types';
5
4
 
6
- /**
7
- * Invert keys for feature to features for key
8
- */
9
- function invertUniqueKeys(uniqueKeys: { [featureName: string]: ISet<string> }): { [key: string]: string[] } {
10
- const featureNames = Object.keys(uniqueKeys);
11
- const inverted: { [key: string]: string[] } = {};
12
- for (let i = 0; i < featureNames.length; i++) {
13
- const featureName = featureNames[i];
14
- const featureKeys = setToArray(uniqueKeys[featureName]);
15
- for (let j = 0; j< featureKeys.length; j++) {
16
- const featureKey = featureKeys[j];
17
- if (!inverted[featureKey]) inverted[featureKey] = [];
18
- inverted[featureKey].push(featureName);
19
- }
20
- }
21
- return inverted;
22
- }
23
-
24
- /**
25
- * Converts `uniqueKeys` data from cache into request payload for CS.
26
- */
27
- export function fromUniqueKeysCollectorCs(uniqueKeys: { [featureName: string]: ISet<string> }): UniqueKeysPayloadCs {
28
- const payload = [];
29
- const featuresPerKey = invertUniqueKeys(uniqueKeys);
30
- const keys = Object.keys(featuresPerKey);
31
- for (let k = 0; k < keys.length; k++) {
32
- const key = keys[k];
33
- const uniqueKeysPayload = {
34
- k: key,
35
- fs: featuresPerKey[key]
36
- };
37
-
38
- payload.push(uniqueKeysPayload);
39
- }
40
- return { keys: payload };
41
- }
42
-
43
- /**
44
- * Converts `uniqueKeys` data from cache into request payload for SS.
45
- */
46
- export function fromUniqueKeysCollectorSs(uniqueKeys: { [featureName: string]: ISet<string> }): UniqueKeysPayloadSs {
47
- const payload = [];
48
- const featureNames = Object.keys(uniqueKeys);
49
- for (let i = 0; i < featureNames.length; i++) {
50
- const featureName = featureNames[i];
51
- const featureKeys = setToArray(uniqueKeys[featureName]);
52
- const uniqueKeysPayload = {
53
- f: featureName,
54
- ks: featureKeys
55
- };
56
-
57
- payload.push(uniqueKeysPayload);
58
- }
59
- return { keys: payload };
60
- }
5
+ const DATA_NAME = 'uniqueKeys';
61
6
 
62
7
  /**
63
8
  * Submitter that periodically posts impression counts
@@ -72,8 +17,19 @@ export function uniqueKeysSubmitterFactory(params: ISdkFactoryContextSync) {
72
17
 
73
18
  const isClientSide = key !== undefined;
74
19
  const postUniqueKeysBulk = isClientSide ? postUniqueKeysBulkCs : postUniqueKeysBulkSs;
75
- const fromUniqueKeysCollector = isClientSide ? fromUniqueKeysCollectorCs : fromUniqueKeysCollectorSs;
76
20
 
77
- return submitterFactory(log, postUniqueKeysBulk, uniqueKeys!, uniqueKeysRefreshRate, 'unique keys', fromUniqueKeysCollector);
21
+ const syncTask = submitterFactory(log, postUniqueKeysBulk, uniqueKeys!, uniqueKeysRefreshRate, 'unique keys');
22
+
23
+ // register unique keys submitter to be executed when uniqueKeys cache is full
24
+ uniqueKeys!.setOnFullQueueCb(() => {
25
+ if (syncTask.isRunning()) {
26
+ log.info(SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
27
+ syncTask.execute();
28
+ }
29
+ // If submitter is stopped (e.g., user consent declined or unknown, or app state offline), we don't send the data.
30
+ // Data will be sent when submitter is resumed.
31
+ });
32
+
33
+ return syncTask;
78
34
  }
79
35
 
@@ -30,7 +30,6 @@ export function impressionsTrackerFactory(
30
30
  if (settings.userConsent === CONSENT_DECLINED) return;
31
31
 
32
32
  const impressionsCount = impressions.length;
33
-
34
33
  const { impressionsToStore, impressionsToListener, deduped } = strategy.process(impressions);
35
34
 
36
35
  const impressionsToListenerCount = impressionsToListener.length;
@@ -21,7 +21,7 @@ export function strategyNoneFactory(
21
21
  // Increments impression counter per featureName
22
22
  impressionsCounter.track(impression.feature, now, 1);
23
23
  // Keep track by unique key
24
- uniqueKeysTracker.track(impression.feature, impression.keyName);
24
+ uniqueKeysTracker.track(impression.keyName, impression.feature);
25
25
  });
26
26
 
27
27
  return {
@@ -2,7 +2,6 @@ import { SplitIO, ImpressionDTO } from '../types';
2
2
  import { StreamingEventType, Method, OperationType } from '../sync/submitters/types';
3
3
  import { IEventsCacheBase } from '../storages/types';
4
4
  import { NetworkError } from '../services/types';
5
- import { ISet } from '../utils/lang/sets';
6
5
 
7
6
  /** Events tracker */
8
7
 
@@ -45,8 +44,8 @@ export interface ITelemetryTracker {
45
44
  }
46
45
 
47
46
  export interface IFilterAdapter {
48
- add(featureName: string, key: string): boolean;
49
- contains(featureName: string, key: string): boolean;
47
+ add(key: string, featureName: string): boolean;
48
+ contains(key: string, featureName: string): boolean;
50
49
  clear(): void;
51
50
  }
52
51
 
@@ -57,10 +56,7 @@ export interface IImpressionSenderAdapter {
57
56
 
58
57
  /** Unique keys tracker */
59
58
  export interface IUniqueKeysTracker {
60
- track(featureName: string, key: string): void;
61
- pop(toMerge?: { [featureName: string]: ISet<string> }): { [featureName: string]: ISet<string>; };
62
- clear(): void;
63
- isEmpty(): boolean;
59
+ track(key: string, featureName: string): void;
64
60
  }
65
61
 
66
62
  export interface IStrategyResult {
@@ -1,6 +1,6 @@
1
1
  import { LOG_PREFIX_UNIQUE_KEYS_TRACKER } from '../logger/constants';
2
2
  import { ILogger } from '../logger/types';
3
- import { ISet, _Set } from '../utils/lang/sets';
3
+ import { IUniqueKeysCacheBase } from '../storages/types';
4
4
  import { IFilterAdapter, IUniqueKeysTracker } from './types';
5
5
 
6
6
  const noopFilterAdapter = {
@@ -9,7 +9,6 @@ const noopFilterAdapter = {
9
9
  clear() {}
10
10
  };
11
11
 
12
- const DEFAULT_CACHE_SIZE = 30000;
13
12
  /**
14
13
  * Trackes uniques keys
15
14
  * Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
@@ -17,64 +16,22 @@ const DEFAULT_CACHE_SIZE = 30000;
17
16
  *
18
17
  * @param log Logger instance
19
18
  * @param filterAdapter filter adapter
20
- * @param cacheSize optional internal cache size
21
- * @param maxBulkSize optional max MTKs bulk size
19
+ * @param uniqueKeysCache cache to save unique keys
22
20
  */
23
21
  export function uniqueKeysTrackerFactory(
24
22
  log: ILogger,
23
+ uniqueKeysCache: IUniqueKeysCacheBase,
25
24
  filterAdapter: IFilterAdapter = noopFilterAdapter,
26
- cacheSize = DEFAULT_CACHE_SIZE,
27
- // @TODO
28
- // maxBulkSize: number = 5000,
29
25
  ): IUniqueKeysTracker {
30
26
 
31
- let uniqueKeysTracker: { [featureName: string]: ISet<string> } = {};
32
- let uniqueTrackerSize = 0;
33
-
34
27
  return {
35
- track(featureName: string, key: string): void {
36
- if (!filterAdapter.add(featureName, key)) {
28
+ track(key: string, featureName: string): void {
29
+ if (!filterAdapter.add(key, featureName)) {
37
30
  log.debug(`${LOG_PREFIX_UNIQUE_KEYS_TRACKER}The feature ${featureName} and key ${key} exist in the filter`);
38
31
  return;
39
32
  }
40
- if (!uniqueKeysTracker[featureName]) uniqueKeysTracker[featureName] = new _Set();
41
- const tracker = uniqueKeysTracker[featureName];
42
- if (!tracker.has(key)) {
43
- tracker.add(key);
44
- log.debug(`${LOG_PREFIX_UNIQUE_KEYS_TRACKER}Key ${key} added to feature ${featureName}`);
45
- uniqueTrackerSize++;
46
- }
47
-
48
- if (uniqueTrackerSize >= cacheSize) {
49
- log.warn(`${LOG_PREFIX_UNIQUE_KEYS_TRACKER}The UniqueKeysTracker size reached the maximum limit`);
50
- // @TODO trigger event to submitter to send mtk
51
- uniqueTrackerSize = 0;
52
- }
53
- },
54
-
55
- /**
56
- * Pop the collected data, used as payload for posting.
57
- */
58
- pop() {
59
- const data = uniqueKeysTracker;
60
- uniqueKeysTracker = {};
61
- return data;
62
- },
63
-
64
- /**
65
- * Clear the data stored on the cache.
66
- */
67
- clear() {
68
- uniqueKeysTracker = {};
69
- },
70
-
71
- /**
72
- * Check if the cache is empty.
73
- */
74
- isEmpty() {
75
- return Object.keys(uniqueKeysTracker).length === 0;
33
+ uniqueKeysCache.track(key, featureName);
76
34
  }
77
-
78
35
  };
79
36
 
80
37
  }
package/src/types.ts CHANGED
@@ -81,6 +81,7 @@ export interface ISettings {
81
81
  impressionsRefreshRate: number,
82
82
  impressionsQueueSize: number,
83
83
  uniqueKeysRefreshRate: number,
84
+ uniqueKeysCacheSize: number,
84
85
  /**
85
86
  * @deprecated
86
87
  */
@@ -50,6 +50,7 @@ export const CONSUMER_PARTIAL_ENUM = 2;
50
50
 
51
51
  export const OPTIMIZED_ENUM = 0;
52
52
  export const DEBUG_ENUM = 1;
53
+ export const NONE_ENUM = 2;
53
54
 
54
55
  export const SPLITS = 'sp';
55
56
  export const IMPRESSIONS = 'im';
@@ -0,0 +1,32 @@
1
+ import { IUniqueKeysCacheBase } from '../types';
2
+ import { UniqueKeysPayloadSs } from '../../sync/submitters/types';
3
+ export declare class UniqueKeysCacheInMemory implements IUniqueKeysCacheBase {
4
+ private onFullQueue?;
5
+ private readonly maxStorage;
6
+ private uniqueTrackerSize;
7
+ private uniqueKeysTracker;
8
+ constructor(uniqueKeysQueueSize?: number);
9
+ setOnFullQueueCb(cb: () => void): void;
10
+ /**
11
+ * Store unique keys in sequential order
12
+ * key: string = feature name.
13
+ * value: Set<string> = set of unique keys.
14
+ */
15
+ track(key: string, featureName: string): void;
16
+ /**
17
+ * Clear the data stored on the cache.
18
+ */
19
+ clear(): void;
20
+ /**
21
+ * Pop the collected data, used as payload for posting.
22
+ */
23
+ pop(): UniqueKeysPayloadSs;
24
+ /**
25
+ * Check if the cache is empty.
26
+ */
27
+ isEmpty(): boolean;
28
+ /**
29
+ * Converts `uniqueKeys` data from cache into request payload for SS.
30
+ */
31
+ private fromUniqueKeysCollector;
32
+ }
@@ -0,0 +1,37 @@
1
+ import { IUniqueKeysCacheBase } from '../types';
2
+ import { UniqueKeysPayloadCs } from '../../sync/submitters/types';
3
+ export declare class UniqueKeysCacheInMemoryCS implements IUniqueKeysCacheBase {
4
+ private onFullQueue?;
5
+ private readonly maxStorage;
6
+ private uniqueTrackerSize;
7
+ private uniqueKeysTracker;
8
+ /**
9
+ *
10
+ * @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
11
+ * Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
12
+ */
13
+ constructor(uniqueKeysQueueSize?: number);
14
+ setOnFullQueueCb(cb: () => void): void;
15
+ /**
16
+ * Store unique keys in sequential order
17
+ * key: string = key.
18
+ * value: HashSet<string> = set of split names.
19
+ */
20
+ track(key: string, featureName: string): void;
21
+ /**
22
+ * Clear the data stored on the cache.
23
+ */
24
+ clear(): void;
25
+ /**
26
+ * Pop the collected data, used as payload for posting.
27
+ */
28
+ pop(): UniqueKeysPayloadCs;
29
+ /**
30
+ * Check if the cache is empty.
31
+ */
32
+ isEmpty(): boolean;
33
+ /**
34
+ * Converts `uniqueKeys` data from cache into request payload.
35
+ */
36
+ private fromUniqueKeysCollector;
37
+ }
@@ -1,8 +1,7 @@
1
1
  import { MaybeThenable, IMetadata, ISplitFiltersValidation } from '../dtos/types';
2
2
  import { ILogger } from '../logger/types';
3
- import { EventDataType, HttpErrors, HttpLatencies, ImpressionDataType, LastSync, Method, MethodExceptions, MethodLatencies, OperationType, StoredEventWithMetadata, StoredImpressionWithMetadata, StreamingEvent } from '../sync/submitters/types';
3
+ import { EventDataType, HttpErrors, HttpLatencies, ImpressionDataType, LastSync, Method, MethodExceptions, MethodLatencies, OperationType, StoredEventWithMetadata, StoredImpressionWithMetadata, StreamingEvent, UniqueKeysPayloadCs, UniqueKeysPayloadSs } from '../sync/submitters/types';
4
4
  import { SplitIO, ImpressionDTO, SDKMode } from '../types';
5
- import { ISet } from '../utils/lang/sets';
6
5
  /**
7
6
  * Interface of a pluggable storage wrapper.
8
7
  */
@@ -298,16 +297,12 @@ export interface IImpressionCountsCacheSync extends IRecorderCacheProducerSync<R
298
297
  isEmpty(): boolean;
299
298
  pop(toMerge?: Record<string, number>): Record<string, number>;
300
299
  }
301
- export interface IUniqueKeysCacheBase extends IRecorderCacheProducerSync<{
302
- [featureName: string]: ISet<string>;
303
- }> {
304
- track(featureName: string, timeFrame: number, amount: number): void;
300
+ export interface IUniqueKeysCacheBase {
301
+ track(key: string, value: string): void;
305
302
  isEmpty(): boolean;
306
- pop(toMerge?: {
307
- [featureName: string]: ISet<string>;
308
- }): {
309
- [featureName: string]: ISet<string>;
310
- };
303
+ pop(): UniqueKeysPayloadSs | UniqueKeysPayloadCs;
304
+ setOnFullQueueCb(cb: () => void): void;
305
+ clear(): void;
311
306
  }
312
307
  /**
313
308
  * Telemetry storage interface for standalone and partial consumer modes.
@@ -398,9 +393,11 @@ export declare type DataLoader = (storage: IStorageSync, matchingKey: string) =>
398
393
  export interface IStorageFactoryParams {
399
394
  log: ILogger;
400
395
  impressionsQueueSize?: number;
396
+ uniqueKeysCacheSize?: number;
401
397
  eventsQueueSize?: number;
402
398
  optimize?: boolean;
403
399
  mode: SDKMode;
400
+ impressionsMode?: string;
404
401
  matchingKey?: string;
405
402
  splitFiltersValidation?: ISplitFiltersValidation;
406
403
  onReadyCb: (error?: any) => void;
@@ -1,18 +1,4 @@
1
1
  import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
- import { ISet } from '../../utils/lang/sets';
3
- import { UniqueKeysPayloadCs, UniqueKeysPayloadSs } from './types';
4
- /**
5
- * Converts `uniqueKeys` data from cache into request payload for CS.
6
- */
7
- export declare function fromUniqueKeysCollectorCs(uniqueKeys: {
8
- [featureName: string]: ISet<string>;
9
- }): UniqueKeysPayloadCs;
10
- /**
11
- * Converts `uniqueKeys` data from cache into request payload for SS.
12
- */
13
- export declare function fromUniqueKeysCollectorSs(uniqueKeys: {
14
- [featureName: string]: ISet<string>;
15
- }): UniqueKeysPayloadSs;
16
2
  /**
17
3
  * Submitter that periodically posts impression counts
18
4
  */
@@ -2,7 +2,6 @@ import { SplitIO, ImpressionDTO } from '../types';
2
2
  import { StreamingEventType, Method, OperationType } from '../sync/submitters/types';
3
3
  import { IEventsCacheBase } from '../storages/types';
4
4
  import { NetworkError } from '../services/types';
5
- import { ISet } from '../utils/lang/sets';
6
5
  /** Events tracker */
7
6
  export interface IEventsHandler {
8
7
  handleEvent(eventData: SplitIO.EventData): any;
@@ -36,8 +35,8 @@ export interface ITelemetryTracker {
36
35
  streamingEvent(e: StreamingEventType | AUTH_REJECTION, d?: number): void;
37
36
  }
38
37
  export interface IFilterAdapter {
39
- add(featureName: string, key: string): boolean;
40
- contains(featureName: string, key: string): boolean;
38
+ add(key: string, featureName: string): boolean;
39
+ contains(key: string, featureName: string): boolean;
41
40
  clear(): void;
42
41
  }
43
42
  export interface IImpressionSenderAdapter {
@@ -46,14 +45,7 @@ export interface IImpressionSenderAdapter {
46
45
  }
47
46
  /** Unique keys tracker */
48
47
  export interface IUniqueKeysTracker {
49
- track(featureName: string, key: string): void;
50
- pop(toMerge?: {
51
- [featureName: string]: ISet<string>;
52
- }): {
53
- [featureName: string]: ISet<string>;
54
- };
55
- clear(): void;
56
- isEmpty(): boolean;
48
+ track(key: string, featureName: string): void;
57
49
  }
58
50
  export interface IStrategyResult {
59
51
  impressionsToStore: ImpressionDTO[];
@@ -1,4 +1,5 @@
1
1
  import { ILogger } from '../logger/types';
2
+ import { IUniqueKeysCacheBase } from '../storages/types';
2
3
  import { IFilterAdapter, IUniqueKeysTracker } from './types';
3
4
  /**
4
5
  * Trackes uniques keys
@@ -7,7 +8,6 @@ import { IFilterAdapter, IUniqueKeysTracker } from './types';
7
8
  *
8
9
  * @param log Logger instance
9
10
  * @param filterAdapter filter adapter
10
- * @param cacheSize optional internal cache size
11
- * @param maxBulkSize optional max MTKs bulk size
11
+ * @param uniqueKeysCache cache to save unique keys
12
12
  */
13
- export declare function uniqueKeysTrackerFactory(log: ILogger, filterAdapter?: IFilterAdapter, cacheSize?: number): IUniqueKeysTracker;
13
+ export declare function uniqueKeysTrackerFactory(log: ILogger, uniqueKeysCache: IUniqueKeysCacheBase, filterAdapter?: IFilterAdapter): IUniqueKeysTracker;
package/types/types.d.ts CHANGED
@@ -75,6 +75,7 @@ export interface ISettings {
75
75
  impressionsRefreshRate: number;
76
76
  impressionsQueueSize: number;
77
77
  uniqueKeysRefreshRate: number;
78
+ uniqueKeysCacheSize: number;
78
79
  /**
79
80
  * @deprecated
80
81
  */
@@ -32,6 +32,7 @@ export declare const CONSUMER_ENUM = 1;
32
32
  export declare const CONSUMER_PARTIAL_ENUM = 2;
33
33
  export declare const OPTIMIZED_ENUM = 0;
34
34
  export declare const DEBUG_ENUM = 1;
35
+ export declare const NONE_ENUM = 2;
35
36
  export declare const SPLITS = "sp";
36
37
  export declare const IMPRESSIONS = "im";
37
38
  export declare const IMPRESSIONS_COUNT = "ic";