@splitsoftware/splitio-commons 1.6.2-rc.5 → 1.6.2-rc.6

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 (178) hide show
  1. package/cjs/consent/sdkUserConsent.js +2 -2
  2. package/cjs/evaluator/index.js +10 -11
  3. package/cjs/integrations/ga/GaToSplit.js +8 -5
  4. package/cjs/listeners/browser.js +1 -2
  5. package/cjs/logger/constants.js +1 -2
  6. package/cjs/sdkFactory/index.js +7 -25
  7. package/cjs/sdkManager/index.js +3 -11
  8. package/cjs/services/splitApi.js +0 -20
  9. package/cjs/storages/AbstractSplitsCacheAsync.js +7 -9
  10. package/cjs/storages/AbstractSplitsCacheSync.js +7 -9
  11. package/cjs/storages/KeyBuilderSS.js +0 -6
  12. package/cjs/storages/dataLoader.js +1 -1
  13. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +5 -6
  14. package/cjs/storages/inLocalStorage/index.js +0 -4
  15. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -12
  16. package/cjs/storages/inMemory/InMemoryStorage.js +1 -5
  17. package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -5
  18. package/cjs/storages/inMemory/SplitsCacheInMemory.js +7 -10
  19. package/cjs/storages/inRedis/SplitsCacheInRedis.js +15 -9
  20. package/cjs/storages/inRedis/constants.js +1 -4
  21. package/cjs/storages/inRedis/index.js +1 -15
  22. package/cjs/storages/pluggable/SplitsCachePluggable.js +14 -9
  23. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
  24. package/cjs/sync/polling/updaters/splitChangesUpdater.js +1 -1
  25. package/cjs/sync/submitters/submitterManager.js +0 -3
  26. package/cjs/sync/submitters/telemetrySubmitter.js +0 -1
  27. package/cjs/trackers/impressionsTracker.js +41 -22
  28. package/cjs/trackers/telemetryTracker.js +6 -0
  29. package/cjs/utils/constants/index.js +2 -4
  30. package/cjs/utils/settingsValidation/impressionsMode.js +2 -2
  31. package/cjs/utils/settingsValidation/index.js +0 -3
  32. package/esm/consent/sdkUserConsent.js +2 -2
  33. package/esm/evaluator/index.js +10 -11
  34. package/esm/integrations/ga/GaToSplit.js +8 -5
  35. package/esm/listeners/browser.js +2 -3
  36. package/esm/logger/constants.js +0 -1
  37. package/esm/sdkFactory/index.js +7 -25
  38. package/esm/sdkManager/index.js +3 -11
  39. package/esm/services/splitApi.js +0 -20
  40. package/esm/storages/AbstractSplitsCacheAsync.js +7 -9
  41. package/esm/storages/AbstractSplitsCacheSync.js +7 -9
  42. package/esm/storages/KeyBuilderSS.js +0 -6
  43. package/esm/storages/dataLoader.js +1 -1
  44. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +5 -6
  45. package/esm/storages/inLocalStorage/index.js +1 -5
  46. package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -12
  47. package/esm/storages/inMemory/InMemoryStorage.js +2 -6
  48. package/esm/storages/inMemory/InMemoryStorageCS.js +2 -6
  49. package/esm/storages/inMemory/SplitsCacheInMemory.js +7 -10
  50. package/esm/storages/inRedis/SplitsCacheInRedis.js +15 -9
  51. package/esm/storages/inRedis/constants.js +0 -3
  52. package/esm/storages/inRedis/index.js +2 -16
  53. package/esm/storages/pluggable/SplitsCachePluggable.js +14 -9
  54. package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
  55. package/esm/sync/polling/updaters/splitChangesUpdater.js +1 -1
  56. package/esm/sync/submitters/submitterManager.js +0 -3
  57. package/esm/sync/submitters/telemetrySubmitter.js +1 -2
  58. package/esm/trackers/impressionsTracker.js +41 -22
  59. package/esm/trackers/telemetryTracker.js +6 -0
  60. package/esm/utils/constants/index.js +0 -2
  61. package/esm/utils/settingsValidation/impressionsMode.js +3 -3
  62. package/esm/utils/settingsValidation/index.js +0 -3
  63. package/package.json +1 -1
  64. package/src/consent/sdkUserConsent.ts +2 -2
  65. package/src/evaluator/index.ts +8 -9
  66. package/src/integrations/ga/GaToSplit.ts +9 -5
  67. package/src/integrations/types.ts +2 -1
  68. package/src/listeners/browser.ts +2 -3
  69. package/src/logger/.DS_Store +0 -0
  70. package/src/logger/constants.ts +0 -1
  71. package/src/sdkFactory/index.ts +7 -28
  72. package/src/sdkFactory/types.ts +4 -7
  73. package/src/sdkManager/index.ts +3 -12
  74. package/src/services/splitApi.ts +0 -22
  75. package/src/services/types.ts +0 -6
  76. package/src/storages/AbstractSplitsCacheAsync.ts +13 -14
  77. package/src/storages/AbstractSplitsCacheSync.ts +14 -16
  78. package/src/storages/KeyBuilderSS.ts +0 -8
  79. package/src/storages/dataLoader.ts +1 -1
  80. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +8 -10
  81. package/src/storages/inLocalStorage/index.ts +1 -4
  82. package/src/storages/inMemory/ImpressionCountsCacheInMemory.ts +1 -16
  83. package/src/storages/inMemory/InMemoryStorage.ts +2 -5
  84. package/src/storages/inMemory/InMemoryStorageCS.ts +2 -6
  85. package/src/storages/inMemory/SplitsCacheInMemory.ts +10 -14
  86. package/src/storages/inRedis/SplitsCacheInRedis.ts +21 -17
  87. package/src/storages/inRedis/constants.ts +0 -3
  88. package/src/storages/inRedis/index.ts +3 -12
  89. package/src/storages/pluggable/SplitsCachePluggable.ts +20 -17
  90. package/src/storages/types.ts +21 -40
  91. package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +5 -6
  92. package/src/sync/polling/updaters/splitChangesUpdater.ts +2 -2
  93. package/src/sync/submitters/submitterManager.ts +0 -2
  94. package/src/sync/submitters/telemetrySubmitter.ts +3 -4
  95. package/src/sync/submitters/types.ts +1 -20
  96. package/src/trackers/impressionsTracker.ts +48 -27
  97. package/src/trackers/telemetryTracker.ts +7 -2
  98. package/src/trackers/types.ts +4 -26
  99. package/src/types.ts +1 -3
  100. package/src/utils/constants/index.ts +0 -2
  101. package/src/utils/settingsValidation/impressionsMode.ts +3 -3
  102. package/src/utils/settingsValidation/index.ts +0 -4
  103. package/types/integrations/types.d.ts +2 -1
  104. package/types/logger/constants.d.ts +0 -1
  105. package/types/sdkFactory/types.d.ts +2 -4
  106. package/types/services/types.d.ts +0 -4
  107. package/types/storages/AbstractSplitsCacheAsync.d.ts +6 -5
  108. package/types/storages/AbstractSplitsCacheSync.d.ts +5 -5
  109. package/types/storages/KeyBuilderSS.d.ts +0 -2
  110. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +3 -3
  111. package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +1 -5
  112. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +3 -2
  113. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +6 -5
  114. package/types/storages/inRedis/constants.d.ts +0 -3
  115. package/types/storages/pluggable/SplitsCachePluggable.d.ts +6 -5
  116. package/types/storages/types.d.ts +18 -28
  117. package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -1
  118. package/types/sync/submitters/types.d.ts +1 -18
  119. package/types/trackers/impressionsTracker.d.ts +6 -4
  120. package/types/trackers/types.d.ts +4 -21
  121. package/types/types.d.ts +1 -3
  122. package/types/utils/constants/index.d.ts +0 -2
  123. package/types/utils/settingsValidation/index.d.ts +0 -1
  124. package/cjs/storages/inMemory/uniqueKeysCacheInMemory.js +0 -73
  125. package/cjs/storages/inMemory/uniqueKeysCacheInMemoryCS.js +0 -78
  126. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +0 -46
  127. package/cjs/storages/inRedis/uniqueKeysCacheInRedis.js +0 -55
  128. package/cjs/sync/submitters/uniqueKeysSubmitter.js +0 -26
  129. package/cjs/trackers/strategy/strategyDebug.js +0 -25
  130. package/cjs/trackers/strategy/strategyNone.js +0 -29
  131. package/cjs/trackers/strategy/strategyOptimized.js +0 -34
  132. package/cjs/trackers/uniqueKeysTracker.js +0 -31
  133. package/esm/storages/inMemory/uniqueKeysCacheInMemory.js +0 -70
  134. package/esm/storages/inMemory/uniqueKeysCacheInMemoryCS.js +0 -75
  135. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +0 -43
  136. package/esm/storages/inRedis/uniqueKeysCacheInRedis.js +0 -52
  137. package/esm/sync/submitters/uniqueKeysSubmitter.js +0 -22
  138. package/esm/trackers/strategy/strategyDebug.js +0 -21
  139. package/esm/trackers/strategy/strategyNone.js +0 -25
  140. package/esm/trackers/strategy/strategyOptimized.js +0 -30
  141. package/esm/trackers/uniqueKeysTracker.js +0 -27
  142. package/src/storages/inMemory/uniqueKeysCacheInMemory.ts +0 -82
  143. package/src/storages/inMemory/uniqueKeysCacheInMemoryCS.ts +0 -88
  144. package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +0 -48
  145. package/src/storages/inRedis/uniqueKeysCacheInRedis.ts +0 -61
  146. package/src/sync/submitters/uniqueKeysSubmitter.ts +0 -35
  147. package/src/trackers/strategy/strategyDebug.ts +0 -28
  148. package/src/trackers/strategy/strategyNone.ts +0 -34
  149. package/src/trackers/strategy/strategyOptimized.ts +0 -42
  150. package/src/trackers/uniqueKeysTracker.ts +0 -37
  151. package/types/sdkClient/types.d.ts +0 -18
  152. package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
  153. package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
  154. package/types/storages/inMemory/uniqueKeysCacheInMemory.d.ts +0 -35
  155. package/types/storages/inMemory/uniqueKeysCacheInMemoryCS.d.ts +0 -37
  156. package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
  157. package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +0 -13
  158. package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
  159. package/types/storages/inRedis/uniqueKeysCacheInRedis.d.ts +0 -14
  160. package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
  161. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
  162. package/types/sync/submitters/eventsSyncTask.d.ts +0 -8
  163. package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +0 -5
  164. package/types/sync/submitters/impressionCountsSyncTask.d.ts +0 -13
  165. package/types/sync/submitters/impressionsSyncTask.d.ts +0 -14
  166. package/types/sync/submitters/metricsSyncTask.d.ts +0 -12
  167. package/types/sync/submitters/submitterSyncTask.d.ts +0 -10
  168. package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -5
  169. package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +0 -5
  170. package/types/sync/syncTaskComposite.d.ts +0 -5
  171. package/types/trackers/filter/bloomFilter.d.ts +0 -10
  172. package/types/trackers/filter/dictionaryFilter.d.ts +0 -8
  173. package/types/trackers/filter/types.d.ts +0 -5
  174. package/types/trackers/strategy/strategyDebug.d.ts +0 -9
  175. package/types/trackers/strategy/strategyNone.d.ts +0 -10
  176. package/types/trackers/strategy/strategyOptimized.d.ts +0 -11
  177. package/types/trackers/uniqueKeysTracker.d.ts +0 -13
  178. package/types/utils/timeTracker/index.d.ts +0 -70
@@ -1,35 +0,0 @@
1
- import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
2
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
3
- import { submitterFactory } from './submitter';
4
-
5
- const DATA_NAME = 'uniqueKeys';
6
-
7
- /**
8
- * Submitter that periodically posts impression counts
9
- */
10
- export function uniqueKeysSubmitterFactory(params: ISdkFactoryContextSync) {
11
-
12
- const {
13
- settings: { log, scheduler: { uniqueKeysRefreshRate }, core: {key}},
14
- splitApi: { postUniqueKeysBulkCs, postUniqueKeysBulkSs },
15
- storage: { uniqueKeys }
16
- } = params;
17
-
18
- const isClientSide = key !== undefined;
19
- const postUniqueKeysBulk = isClientSide ? postUniqueKeysBulkCs : postUniqueKeysBulkSs;
20
-
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;
34
- }
35
-
@@ -1,28 +0,0 @@
1
- import { ImpressionDTO } from '../../types';
2
- import { IImpressionObserver } from '../impressionObserver/types';
3
- import { IStrategy } from '../types';
4
-
5
- /**
6
- * Debug strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
7
- *
8
- * @param impressionsObserver impression observer. Previous time (pt property) is included in impression instances
9
- * @returns IStrategyResult
10
- */
11
- export function strategyDebugFactory(
12
- impressionsObserver: IImpressionObserver
13
- ): IStrategy {
14
-
15
- return {
16
- process(impressions: ImpressionDTO[]) {
17
- impressions.forEach((impression) => {
18
- // Adds previous time if it is enabled
19
- impression.pt = impressionsObserver.testAndSet(impression);
20
- });
21
- return {
22
- impressionsToStore: impressions,
23
- impressionsToListener: impressions,
24
- deduped: 0
25
- };
26
- }
27
- };
28
- }
@@ -1,34 +0,0 @@
1
- import { IImpressionCountsCacheSync } from '../../storages/types';
2
- import { ImpressionDTO } from '../../types';
3
- import { IStrategy, IUniqueKeysTracker } from '../types';
4
-
5
- /**
6
- * None strategy for impressions tracker.
7
- *
8
- * @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
9
- * @param uniqueKeysTracker unique keys tracker in charge of tracking the unique keys per split.
10
- * @returns IStrategyResult
11
- */
12
- export function strategyNoneFactory(
13
- impressionsCounter: IImpressionCountsCacheSync,
14
- uniqueKeysTracker: IUniqueKeysTracker
15
- ): IStrategy {
16
-
17
- return {
18
- process(impressions: ImpressionDTO[]) {
19
- impressions.forEach((impression) => {
20
- const now = Date.now();
21
- // Increments impression counter per featureName
22
- impressionsCounter.track(impression.feature, now, 1);
23
- // Keep track by unique key
24
- uniqueKeysTracker.track(impression.keyName, impression.feature);
25
- });
26
-
27
- return {
28
- impressionsToStore: [],
29
- impressionsToListener: impressions,
30
- deduped: 0
31
- };
32
- }
33
- };
34
- }
@@ -1,42 +0,0 @@
1
- import { IImpressionCountsCacheSync } from '../../storages/types';
2
- import { ImpressionDTO } from '../../types';
3
- import { truncateTimeFrame } from '../../utils/time';
4
- import { IImpressionObserver } from '../impressionObserver/types';
5
- import { IStrategy } from '../types';
6
-
7
- /**
8
- * Optimized strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
9
- *
10
- * @param impressionsObserver impression observer. previous time (pt property) is included in impression instances
11
- * @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
12
- * @returns IStrategyResult
13
- */
14
- export function strategyOptimizedFactory(
15
- impressionsObserver: IImpressionObserver,
16
- impressionsCounter: IImpressionCountsCacheSync,
17
- ): IStrategy {
18
-
19
- return {
20
- process(impressions: ImpressionDTO[]) {
21
- const impressionsToStore: ImpressionDTO[] = [];
22
- impressions.forEach((impression) => {
23
- impression.pt = impressionsObserver.testAndSet(impression);
24
-
25
- const now = Date.now();
26
-
27
- // Increments impression counter per featureName
28
- impressionsCounter.track(impression.feature, now, 1);
29
-
30
- // Checks if the impression should be added in queue to be sent
31
- if (!impression.pt || impression.pt < truncateTimeFrame(now)) {
32
- impressionsToStore.push(impression);
33
- }
34
- });
35
- return {
36
- impressionsToStore: impressionsToStore,
37
- impressionsToListener: impressions,
38
- deduped: impressions.length - impressionsToStore.length
39
- };
40
- }
41
- };
42
- }
@@ -1,37 +0,0 @@
1
- import { LOG_PREFIX_UNIQUE_KEYS_TRACKER } from '../logger/constants';
2
- import { ILogger } from '../logger/types';
3
- import { IUniqueKeysCacheBase } from '../storages/types';
4
- import { IFilterAdapter, IUniqueKeysTracker } from './types';
5
-
6
- const noopFilterAdapter = {
7
- add() {return true;},
8
- contains() {return true;},
9
- clear() {}
10
- };
11
-
12
- /**
13
- * Trackes uniques keys
14
- * Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
15
- * or schedule to be sent; if not it will be added in an internal cache and sent in the next post.
16
- *
17
- * @param log Logger instance
18
- * @param filterAdapter filter adapter
19
- * @param uniqueKeysCache cache to save unique keys
20
- */
21
- export function uniqueKeysTrackerFactory(
22
- log: ILogger,
23
- uniqueKeysCache: IUniqueKeysCacheBase,
24
- filterAdapter: IFilterAdapter = noopFilterAdapter,
25
- ): IUniqueKeysTracker {
26
-
27
- return {
28
- track(key: string, featureName: string): void {
29
- if (!filterAdapter.add(key, featureName)) {
30
- log.debug(`${LOG_PREFIX_UNIQUE_KEYS_TRACKER}The feature ${featureName} and key ${key} exist in the filter`);
31
- return;
32
- }
33
- uniqueKeysCache.track(key, featureName);
34
- }
35
- };
36
-
37
- }
@@ -1,18 +0,0 @@
1
- import { ISignalListener } from '../listeners/types';
2
- import { ISdkReadinessManager } from '../readiness/types';
3
- import { IStorageAsync, IStorageSync } from '../storages/types';
4
- import { ISyncManager } from '../sync/types';
5
- import { IEventTracker, IImpressionsTracker } from '../trackers/types';
6
- import { ISettings } from '../types';
7
- export interface IClientFactoryParams {
8
- storage: IStorageSync | IStorageAsync;
9
- sdkReadinessManager: ISdkReadinessManager;
10
- settings: ISettings;
11
- impressionsTracker: IImpressionsTracker;
12
- eventTracker: IEventTracker;
13
- }
14
- export interface ISdkClientFactoryParams extends IClientFactoryParams {
15
- signalListener?: ISignalListener;
16
- syncManager?: ISyncManager;
17
- sharedClient?: boolean;
18
- }
@@ -1,20 +0,0 @@
1
- import { ICountsCacheSync } from '../types';
2
- export declare class CountsCacheInMemory implements ICountsCacheSync {
3
- private counters;
4
- /**
5
- * Add counts.
6
- */
7
- track(metricName: string): boolean;
8
- /**
9
- * Clear the collector
10
- */
11
- clear(): void;
12
- /**
13
- * Get the collected data, used as payload for posting.
14
- */
15
- state(): Record<string, number>;
16
- /**
17
- * Check if the cache is empty.
18
- */
19
- isEmpty(): boolean;
20
- }
@@ -1,20 +0,0 @@
1
- import { ILatenciesCacheSync } from '../types';
2
- export declare class LatenciesCacheInMemory implements ILatenciesCacheSync {
3
- private counters;
4
- /**
5
- * Add latencies.
6
- */
7
- track(metricName: string, latency: number): boolean;
8
- /**
9
- * Clear the collector
10
- */
11
- clear(): void;
12
- /**
13
- * Get the collected data, used as payload for posting.
14
- */
15
- state(): Record<string, number[]>;
16
- /**
17
- * Check if the cache is empty.
18
- */
19
- isEmpty(): boolean;
20
- }
@@ -1,35 +0,0 @@
1
- import { IUniqueKeysCacheBase } from '../types';
2
- import { ISet } from '../../utils/lang/sets';
3
- import { UniqueKeysPayloadSs } from '../../sync/submitters/types';
4
- export declare class UniqueKeysCacheInMemory implements IUniqueKeysCacheBase {
5
- protected onFullQueue?: () => void;
6
- private readonly maxStorage;
7
- private uniqueTrackerSize;
8
- protected uniqueKeysTracker: {
9
- [keys: string]: ISet<string>;
10
- };
11
- constructor(uniqueKeysQueueSize?: number);
12
- setOnFullQueueCb(cb: () => void): void;
13
- /**
14
- * Store unique keys in sequential order
15
- * key: string = feature name.
16
- * value: Set<string> = set of unique keys.
17
- */
18
- track(key: string, featureName: string): void;
19
- /**
20
- * Clear the data stored on the cache.
21
- */
22
- clear(): void;
23
- /**
24
- * Pop the collected data, used as payload for posting.
25
- */
26
- pop(): UniqueKeysPayloadSs;
27
- /**
28
- * Check if the cache is empty.
29
- */
30
- isEmpty(): boolean;
31
- /**
32
- * Converts `uniqueKeys` data from cache into request payload for SS.
33
- */
34
- private fromUniqueKeysCollector;
35
- }
@@ -1,37 +0,0 @@
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,9 +0,0 @@
1
- import { ICountsCacheAsync } from '../types';
2
- import { KeyBuilderSS } from '../KeyBuilderSS';
3
- import { Redis } from 'ioredis';
4
- export declare class CountsCacheInRedis implements ICountsCacheAsync {
5
- private readonly redis;
6
- private readonly keys;
7
- constructor(keys: KeyBuilderSS, redis: Redis);
8
- track(metricName: string): Promise<boolean>;
9
- }
@@ -1,13 +0,0 @@
1
- import { Redis } from 'ioredis';
2
- import { ILogger } from '../../logger/types';
3
- import { ImpressionCountsCacheInMemory } from '../inMemory/ImpressionCountsCacheInMemory';
4
- export declare class ImpressionCountsCacheInRedis extends ImpressionCountsCacheInMemory {
5
- private readonly log;
6
- private readonly key;
7
- private readonly redis;
8
- private handle;
9
- constructor(log: ILogger, key: string, redis: Redis, impressionCountsCacheSize?: number);
10
- postImpressionCountsInRedis(): Promise<boolean | import("ioredis").BooleanResponse | undefined>;
11
- start(refreshRate?: number): void;
12
- stop(): void;
13
- }
@@ -1,9 +0,0 @@
1
- import { ILatenciesCacheAsync } from '../types';
2
- import { KeyBuilderSS } from '../KeyBuilderSS';
3
- import { Redis } from 'ioredis';
4
- export declare class LatenciesCacheInRedis implements ILatenciesCacheAsync {
5
- private readonly redis;
6
- private readonly keys;
7
- constructor(keys: KeyBuilderSS, redis: Redis);
8
- track(metricName: string, latency: number): Promise<boolean>;
9
- }
@@ -1,14 +0,0 @@
1
- import { IUniqueKeysCacheBase } from '../types';
2
- import { Redis } from 'ioredis';
3
- import { UniqueKeysCacheInMemory } from '../inMemory/uniqueKeysCacheInMemory';
4
- import { ILogger } from '../../logger/types';
5
- export declare class UniqueKeysCacheInRedis extends UniqueKeysCacheInMemory implements IUniqueKeysCacheBase {
6
- private readonly log;
7
- private readonly key;
8
- private readonly redis;
9
- private handle;
10
- constructor(log: ILogger, key: string, redis: Redis, uniqueKeysQueueSize?: number);
11
- postUniqueKeysInRedis(): Promise<boolean | import("ioredis").BooleanResponse | undefined>;
12
- start(refreshRate?: number): void;
13
- stop(): void;
14
- }
@@ -1,2 +0,0 @@
1
- import { SplitIO } from '../../types';
2
- export declare function LocalhostFromFile(): SplitIO.LocalhostFactory;
@@ -1,2 +0,0 @@
1
- import { ISplitsParser } from './types';
2
- export declare function splitsParserFromFileFactory(): ISplitsParser;
@@ -1,8 +0,0 @@
1
- import { IEventsCacheSync } from '../../storages/types';
2
- import { IPostEventsBulk } from '../../services/types';
3
- import { ISyncTask, ITimeTracker } from '../types';
4
- import { ILogger } from '../../logger/types';
5
- /**
6
- * Sync task that periodically posts tracked events
7
- */
8
- export declare function eventsSyncTaskFactory(log: ILogger, postEventsBulk: IPostEventsBulk, eventsCache: IEventsCacheSync, eventsPushRate: number, eventsFirstPushWindow: number, latencyTracker?: ITimeTracker): ISyncTask;
@@ -1,5 +0,0 @@
1
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
- /**
3
- * Submitter that periodically posts impression counts
4
- */
5
- export declare function impressionCountsSubmitterInRedisFactory(params: ISdkFactoryContextSync): import("../types").ISyncTask<[], void>;
@@ -1,13 +0,0 @@
1
- import { ISyncTask, ITimeTracker } from '../types';
2
- import { IPostTestImpressionsCount } from '../../services/types';
3
- import { IImpressionCountsCacheSync } from '../../storages/types';
4
- import { ImpressionCountsPayload } from './types';
5
- import { ILogger } from '../../logger/types';
6
- /**
7
- * Converts `impressionCounts` data from cache into request payload.
8
- */
9
- export declare function fromImpressionCountsCollector(impressionsCount: Record<string, number>): ImpressionCountsPayload;
10
- /**
11
- * Sync task that periodically posts impression counts
12
- */
13
- export declare function impressionCountsSyncTaskFactory(log: ILogger, postTestImpressionsCount: IPostTestImpressionsCount, impressionCountsCache: IImpressionCountsCacheSync, latencyTracker?: ITimeTracker): ISyncTask;
@@ -1,14 +0,0 @@
1
- import { ISyncTask, ITimeTracker } from '../types';
2
- import { IPostTestImpressionsBulk } from '../../services/types';
3
- import { IImpressionsCacheSync } from '../../storages/types';
4
- import { ImpressionDTO } from '../../types';
5
- import { ImpressionsPayload } from './types';
6
- import { ILogger } from '../../logger/types';
7
- /**
8
- * Converts `impressions` data from cache into request payload.
9
- */
10
- export declare function fromImpressionsCollector(sendLabels: boolean, data: ImpressionDTO[]): ImpressionsPayload;
11
- /**
12
- * Sync task that periodically posts impressions data
13
- */
14
- export declare function impressionsSyncTaskFactory(log: ILogger, postTestImpressionsBulk: IPostTestImpressionsBulk, impressionsCache: IImpressionsCacheSync, impressionsRefreshRate: number, sendLabels?: boolean, latencyTracker?: ITimeTracker): ISyncTask;
@@ -1,12 +0,0 @@
1
- import { ICountsCacheSync, ILatenciesCacheSync } from '../../storages/types';
2
- import { IPostMetricsCounters, IPostMetricsTimes } from '../../services/types';
3
- import { ISyncTask, ITimeTracker } from '../types';
4
- import { ILogger } from '../../logger/types';
5
- /**
6
- * Sync task that periodically posts telemetry counts
7
- */
8
- export declare function countsSyncTaskFactory(log: ILogger, postMetricsCounters: IPostMetricsCounters, countsCache: ICountsCacheSync, metricsRefreshRate: number, latencyTracker?: ITimeTracker): ISyncTask;
9
- /**
10
- * Sync task that periodically posts telemetry latencies
11
- */
12
- export declare function latenciesSyncTaskFactory(log: ILogger, postMetricsLatencies: IPostMetricsTimes, latenciesCache: ILatenciesCacheSync, metricsRefreshRate: number, latencyTracker?: ITimeTracker): ISyncTask;
@@ -1,10 +0,0 @@
1
- import { ISyncTask, ITimeTracker } from '../types';
2
- import { IRecorderCacheProducerSync } from '../../storages/types';
3
- import { ILogger } from '../../logger/types';
4
- import { IResponse } from '../../services/types';
5
- /**
6
- * Base function to create submitter sync tasks, such as ImpressionsSyncTask and EventsSyncTask
7
- */
8
- export declare function submitterSyncTaskFactory<TState extends {
9
- length?: number;
10
- }>(log: ILogger, postClient: (body: string) => Promise<IResponse>, sourceCache: IRecorderCacheProducerSync<TState>, postRate: number, dataName: string, latencyTracker?: ITimeTracker, fromCacheToPayload?: (cacheData: TState) => any, maxRetries?: number, debugLogs?: boolean): ISyncTask<[], void>;
@@ -1,5 +0,0 @@
1
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
- /**
3
- * Submitter that periodically posts impression counts
4
- */
5
- export declare function uniqueKeysSubmitterFactory(params: ISdkFactoryContextSync): import("../types").ISyncTask<[], void>;
@@ -1,5 +0,0 @@
1
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
2
- /**
3
- * Submitter that periodically posts impression counts
4
- */
5
- export declare function uniqueKeysSubmitterInRedisFactory(params: ISdkFactoryContextSync): import("../types").ISyncTask<[], void>;
@@ -1,5 +0,0 @@
1
- import { ISyncTask } from './types';
2
- /**
3
- * Composite Sync Task: group of sync tasks that are treated as a single one.
4
- */
5
- export declare function syncTaskComposite(syncTasks: ISyncTask[]): ISyncTask;
@@ -1,10 +0,0 @@
1
- import { IFilter } from './types';
2
- export declare class BloomFilterImp implements IFilter {
3
- private spectedInsertions;
4
- private errorRate;
5
- private filter;
6
- constructor(spectedInsertions: number, errorRate: number);
7
- add(data: string): boolean;
8
- contains(data: string): boolean;
9
- clear(): void;
10
- }
@@ -1,8 +0,0 @@
1
- import { IFilter } from './types';
2
- export declare class DictionaryFilter implements IFilter {
3
- private filter;
4
- constructor();
5
- add(data: string): boolean;
6
- contains(data: string): boolean;
7
- clear(): void;
8
- }
@@ -1,5 +0,0 @@
1
- export interface IFilter {
2
- add(data: string): boolean;
3
- contains(data: string): boolean;
4
- clear(): void;
5
- }
@@ -1,9 +0,0 @@
1
- import { IImpressionObserver } from '../impressionObserver/types';
2
- import { IStrategy } from '../types';
3
- /**
4
- * Debug strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
5
- *
6
- * @param impressionsObserver impression observer. Previous time (pt property) is included in impression instances
7
- * @returns IStrategyResult
8
- */
9
- export declare function strategyDebugFactory(impressionsObserver: IImpressionObserver): IStrategy;
@@ -1,10 +0,0 @@
1
- import { IImpressionCountsCacheSync } from '../../storages/types';
2
- import { IStrategy, IUniqueKeysTracker } from '../types';
3
- /**
4
- * None strategy for impressions tracker.
5
- *
6
- * @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
7
- * @param uniqueKeysTracker unique keys tracker in charge of tracking the unique keys per split.
8
- * @returns IStrategyResult
9
- */
10
- export declare function strategyNoneFactory(impressionsCounter: IImpressionCountsCacheSync, uniqueKeysTracker: IUniqueKeysTracker): IStrategy;
@@ -1,11 +0,0 @@
1
- import { IImpressionCountsCacheSync } from '../../storages/types';
2
- import { IImpressionObserver } from '../impressionObserver/types';
3
- import { IStrategy } from '../types';
4
- /**
5
- * Optimized strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
6
- *
7
- * @param impressionsObserver impression observer. previous time (pt property) is included in impression instances
8
- * @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
9
- * @returns IStrategyResult
10
- */
11
- export declare function strategyOptimizedFactory(impressionsObserver: IImpressionObserver, impressionsCounter: IImpressionCountsCacheSync): IStrategy;
@@ -1,13 +0,0 @@
1
- import { ILogger } from '../logger/types';
2
- import { IUniqueKeysCacheBase } from '../storages/types';
3
- import { IFilterAdapter, IUniqueKeysTracker } from './types';
4
- /**
5
- * Trackes uniques keys
6
- * Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
7
- * or schedule to be sent; if not it will be added in an internal cache and sent in the next post.
8
- *
9
- * @param log Logger instance
10
- * @param filterAdapter filter adapter
11
- * @param uniqueKeysCache cache to save unique keys
12
- */
13
- export declare function uniqueKeysTrackerFactory(log: ILogger, uniqueKeysCache: IUniqueKeysCacheBase, filterAdapter?: IFilterAdapter): IUniqueKeysTracker;
@@ -1,70 +0,0 @@
1
- import { ILogger } from '../../logger/types';
2
- import { IResponse } from '../../services/types';
3
- interface MetricsCollector {
4
- countException(): void;
5
- count(status: number): void;
6
- latency(ms: number): void;
7
- ready(ms: number): void;
8
- getTreatment(ms: number): void;
9
- getTreatments(ms: number): void;
10
- getTreatmentWithConfig(ms: number): void;
11
- getTreatmentsWithConfig(ms: number): void;
12
- [method: string]: (ms: number) => void;
13
- }
14
- export declare const TrackerAPI: {
15
- /**
16
- * "Private" method, used to attach count/countException and stop callbacks to a promise.
17
- *
18
- * @param {ILogger} log - Logger.
19
- * @param {Promise} promise - The promise we want to attach the callbacks.
20
- * @param {string} task - The name of the task.
21
- * @param {number | string} modifier - (optional) The modifier for the task, if any.
22
- */
23
- __attachToPromise(log: ILogger, promise: Promise<IResponse>, task: string, collector: false | MetricsCollector, modifier?: string | number | undefined): Promise<IResponse>;
24
- /**
25
- * Starts tracking the time for a given task. All tasks tracked are considered "unique" because
26
- * there may be multiple SDK instances tracking a "generic" task, making any task non-generic.
27
- *
28
- * @param {ILogger} log - Logger.
29
- * @param {string} task - The task we are starting.
30
- * @param {Object} collectors - The collectors map.
31
- * @param {Promise} promise - (optional) The promise we are tracking.
32
- * @return {Function | Promise} The stop function for this specific task or the promise received with the callbacks registered.
33
- */
34
- start(log: ILogger, task: string, collectors?: Record<string, MetricsCollector> | undefined, promise?: Promise<IResponse> | undefined, now?: (() => number) | undefined): Promise<IResponse> | (() => number);
35
- /**
36
- * Setup the collector for a task that reports metrics.
37
- *
38
- * @param {string} task - The task name
39
- * @param {number | string} taskUniqueId - The unique identifier for this task
40
- * @param {Object} collectors - The collectors map.
41
- */
42
- setCollectorForTask(task: string, taskUniqueId: number | string, collectors: Record<string, MetricsCollector>): void;
43
- /**
44
- * Stops the tracking of a given task.
45
- *
46
- * @param {ILogger} log - Logger.
47
- * @param {string} task - The task we are starting.
48
- * @param {number | string} modifier - (optional) The modifier for that specific task.
49
- */
50
- stop(log: ILogger, task: string, modifier?: string | number | undefined): number | undefined;
51
- /**
52
- * The constants shortcut for the task names.
53
- */
54
- TaskNames: {
55
- SDK_READY: string;
56
- SDK_GET_TREATMENT: string;
57
- SDK_GET_TREATMENTS: string;
58
- SDK_GET_TREATMENT_WITH_CONFIG: string;
59
- SDK_GET_TREATMENTS_WITH_CONFIG: string;
60
- SPLITS_READY: string;
61
- SEGMENTS_READY: string;
62
- METRICS_PUSH: string;
63
- IMPRESSIONS_PUSH: string;
64
- EVENTS_PUSH: string;
65
- MY_SEGMENTS_FETCH: string;
66
- SEGMENTS_FETCH: string;
67
- SPLITS_FETCH: string;
68
- };
69
- };
70
- export {};