@splitsoftware/splitio-commons 1.9.0 → 1.9.1

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 (40) hide show
  1. package/CHANGES.txt +5 -2
  2. package/cjs/integrations/ga/GaToSplit.js +1 -1
  3. package/cjs/listeners/browser.js +3 -13
  4. package/cjs/sync/streaming/parseUtils.js +1 -0
  5. package/esm/integrations/ga/GaToSplit.js +1 -1
  6. package/esm/listeners/browser.js +3 -13
  7. package/esm/sync/streaming/parseUtils.js +1 -0
  8. package/package.json +6 -6
  9. package/src/integrations/ga/GaToSplit.ts +1 -1
  10. package/src/listeners/browser.ts +3 -13
  11. package/src/storages/inMemory/TelemetryCacheInMemory.ts +1 -1
  12. package/src/storages/inRedis/RedisAdapter.ts +1 -1
  13. package/src/sync/streaming/parseUtils.ts +1 -0
  14. package/src/utils/redis/RedisMock.ts +1 -1
  15. package/types/listeners/browser.d.ts +0 -1
  16. package/types/sdkClient/identity.d.ts +6 -0
  17. package/types/utils/inputValidation/sdkKey.d.ts +7 -0
  18. package/types/sdkClient/types.d.ts +0 -18
  19. package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
  20. package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
  21. package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
  22. package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
  23. package/types/storages/metadataBuilder.d.ts +0 -3
  24. package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
  25. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
  26. package/types/sync/submitters/eventsSyncTask.d.ts +0 -8
  27. package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +0 -5
  28. package/types/sync/submitters/impressionCountsSyncTask.d.ts +0 -13
  29. package/types/sync/submitters/impressionsSyncTask.d.ts +0 -14
  30. package/types/sync/submitters/metricsSyncTask.d.ts +0 -12
  31. package/types/sync/submitters/submitterSyncTask.d.ts +0 -10
  32. package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +0 -5
  33. package/types/sync/syncTaskComposite.d.ts +0 -5
  34. package/types/trackers/filter/bloomFilter.d.ts +0 -10
  35. package/types/trackers/filter/dictionaryFilter.d.ts +0 -8
  36. package/types/trackers/filter/types.d.ts +0 -5
  37. package/types/utils/timeTracker/index.d.ts +0 -70
  38. /package/types/storages/inMemory/{uniqueKeysCacheInMemory.d.ts → UniqueKeysCacheInMemory.d.ts} +0 -0
  39. /package/types/storages/inMemory/{uniqueKeysCacheInMemoryCS.d.ts → UniqueKeysCacheInMemoryCS.d.ts} +0 -0
  40. /package/types/storages/inRedis/{uniqueKeysCacheInRedis.d.ts → UniqueKeysCacheInRedis.d.ts} +0 -0
package/CHANGES.txt CHANGED
@@ -1,10 +1,13 @@
1
+ 1.9.1 (September 21, 2023)
2
+ - Updated browser listener to avoid registering a handler for 'unload' DOM events, that can prevent browsers from being able to put pages in the back/forward cache for faster back and forward loads (Related to issue https://github.com/splitio/javascript-client/issues/759).
3
+
1
4
  1.9.0 (July 18, 2023)
2
5
  - Updated streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system.
3
6
 
4
7
  1.8.3 (June 29, 2023)
5
8
  - Updated some transitive dependencies for vulnerability fixes.
6
9
  - Updated SDK_READY_TIMED_OUT event to be emitted immediately when a connection error occurs using pluggable storage (i.e., when the wrapper `connect` promise is rejected) in consumer and partial consumer modes.
7
- - Bugfix - The `destroy` method has been updated to immediately flag the SDK client as destroyed, to prevent unexpected behaviours when `getTreatment` and `track` methods are called synchronously after `destroy` method is called.
10
+ - Bugfixing - The `destroy` method has been updated to immediately flag the SDK client as destroyed, to prevent unexpected behaviours when `getTreatment` and `track` methods are called synchronously after `destroy` method is called.
8
11
 
9
12
  1.8.2 (May 15, 2023)
10
13
  - Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and IntelliSense comments.
@@ -90,7 +93,7 @@
90
93
  - Integration with Auth service V2, connecting to the new channels and applying the received connection delay.
91
94
  - Implemented handling of the new MySegmentsV2 notification types (SegmentRemoval, KeyList, Bounded and Unbounded)
92
95
  - New control notification for environment scoped streaming reset.
93
- - Updated localhost mode to emit SDK_READY_FROM_CACHE event in Browser when using localStorage (Related to issue https://github.com/splitio/react-client/issues/34).
96
+ - Updated localhost mode to emit SDK_READY_FROM_CACHE event in browser when using localStorage (Related to issue https://github.com/splitio/react-client/issues/34).
94
97
  - Updated dependencies for vulnerability fixes.
95
98
 
96
99
  0.1.0 (March 30, 2021)
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GaToSplit = exports.fixEventTypeId = exports.validateEventData = exports.validateIdentities = exports.defaultPrefix = exports.defaultMapper = void 0;
4
- /* eslint-disable no-undef */
5
4
  var objectAssign_1 = require("../../utils/lang/objectAssign");
6
5
  var lang_1 = require("../../utils/lang");
7
6
  var inputValidation_1 = require("../../utils/inputValidation");
@@ -252,6 +251,7 @@ function GaToSplit(sdkOptions, params) {
252
251
  return SplitTracker;
253
252
  }());
254
253
  // Register the plugin, even if config is invalid, since, if not provided, it will block `ga` command queue.
254
+ // eslint-disable-next-line no-undef
255
255
  providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true, telemetryTracker);
256
256
  }
257
257
  exports.GaToSplit = GaToSplit;
@@ -9,8 +9,7 @@ var constants_2 = require("../logger/constants");
9
9
  var consent_1 = require("../consent");
10
10
  var VISIBILITYCHANGE_EVENT = 'visibilitychange';
11
11
  var PAGEHIDE_EVENT = 'pagehide';
12
- var UNLOAD_EVENT = 'unload';
13
- var EVENT_NAME = 'for unload page event.';
12
+ var EVENT_NAME = 'for visibilitychange and pagehide events.';
14
13
  /**
15
14
  * We'll listen for events over the window object.
16
15
  */
@@ -22,7 +21,6 @@ var BrowserSignalListener = /** @class */ (function () {
22
21
  this.serviceApi = serviceApi;
23
22
  this.flushData = this.flushData.bind(this);
24
23
  this.flushDataIfHidden = this.flushDataIfHidden.bind(this);
25
- this.stopSync = this.stopSync.bind(this);
26
24
  this.fromImpressionsCollector = impressionsSubmitter_1.fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled);
27
25
  }
28
26
  /**
@@ -36,11 +34,9 @@ var BrowserSignalListener = /** @class */ (function () {
36
34
  document.addEventListener(VISIBILITYCHANGE_EVENT, this.flushDataIfHidden);
37
35
  }
38
36
  if (typeof window !== 'undefined' && window.addEventListener) {
39
- // Some browsers like Safari does not fire the `visibilitychange` event when the page is being unloaded. So we also flush data in the `pagehide` event.
40
- // If both events are triggered, the last one will find the storage empty, so no duplicated data will be submitted.
37
+ // Some browsers, like Safari, does not fire the `visibilitychange` event when the page is being unloaded. Therefore, we also flush data in the `pagehide` event.
38
+ // If both events are triggered, the latter will find the storage empty, so no duplicate data will be submitted.
41
39
  window.addEventListener(PAGEHIDE_EVENT, this.flushData);
42
- // Stop streaming on 'unload' event. Used instead of 'beforeunload', because 'unload' is not a cancelable event, so no other listeners can stop the event from occurring.
43
- window.addEventListener(UNLOAD_EVENT, this.stopSync);
44
40
  }
45
41
  };
46
42
  /**
@@ -54,14 +50,8 @@ var BrowserSignalListener = /** @class */ (function () {
54
50
  }
55
51
  if (typeof window !== 'undefined' && window.removeEventListener) {
56
52
  window.removeEventListener(PAGEHIDE_EVENT, this.flushData);
57
- window.removeEventListener(UNLOAD_EVENT, this.stopSync);
58
53
  }
59
54
  };
60
- BrowserSignalListener.prototype.stopSync = function () {
61
- // Close streaming connection
62
- if (this.syncManager && this.syncManager.pushManager)
63
- this.syncManager.pushManager.stop();
64
- };
65
55
  /**
66
56
  * flushData method.
67
57
  * Called when pagehide event is triggered. It flushed remaining impressions and events to the backend,
@@ -10,6 +10,7 @@ function Uint8ArrayToString(myUint8Arr) {
10
10
  }
11
11
  function StringToUint8Array(myString) {
12
12
  var charCodes = myString.split('').map(function (e) { return e.charCodeAt(0); });
13
+ // eslint-disable-next-line compat/compat
13
14
  return new Uint8Array(charCodes);
14
15
  }
15
16
  /**
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import { objectAssign } from '../../utils/lang/objectAssign';
3
2
  import { isString, isFiniteNumber, uniqAsStrings } from '../../utils/lang';
4
3
  import { validateEvent, validateEventValue, validateEventProperties, validateKey, validateTrafficType } from '../../utils/inputValidation';
@@ -246,5 +245,6 @@ export function GaToSplit(sdkOptions, params) {
246
245
  return SplitTracker;
247
246
  }());
248
247
  // Register the plugin, even if config is invalid, since, if not provided, it will block `ga` command queue.
248
+ // eslint-disable-next-line no-undef
249
249
  providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true, telemetryTracker);
250
250
  }
@@ -6,8 +6,7 @@ import { CLEANUP_REGISTERING, CLEANUP_DEREGISTERING } from '../logger/constants'
6
6
  import { isConsentGranted } from '../consent';
7
7
  var VISIBILITYCHANGE_EVENT = 'visibilitychange';
8
8
  var PAGEHIDE_EVENT = 'pagehide';
9
- var UNLOAD_EVENT = 'unload';
10
- var EVENT_NAME = 'for unload page event.';
9
+ var EVENT_NAME = 'for visibilitychange and pagehide events.';
11
10
  /**
12
11
  * We'll listen for events over the window object.
13
12
  */
@@ -19,7 +18,6 @@ var BrowserSignalListener = /** @class */ (function () {
19
18
  this.serviceApi = serviceApi;
20
19
  this.flushData = this.flushData.bind(this);
21
20
  this.flushDataIfHidden = this.flushDataIfHidden.bind(this);
22
- this.stopSync = this.stopSync.bind(this);
23
21
  this.fromImpressionsCollector = fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled);
24
22
  }
25
23
  /**
@@ -33,11 +31,9 @@ var BrowserSignalListener = /** @class */ (function () {
33
31
  document.addEventListener(VISIBILITYCHANGE_EVENT, this.flushDataIfHidden);
34
32
  }
35
33
  if (typeof window !== 'undefined' && window.addEventListener) {
36
- // Some browsers like Safari does not fire the `visibilitychange` event when the page is being unloaded. So we also flush data in the `pagehide` event.
37
- // If both events are triggered, the last one will find the storage empty, so no duplicated data will be submitted.
34
+ // Some browsers, like Safari, does not fire the `visibilitychange` event when the page is being unloaded. Therefore, we also flush data in the `pagehide` event.
35
+ // If both events are triggered, the latter will find the storage empty, so no duplicate data will be submitted.
38
36
  window.addEventListener(PAGEHIDE_EVENT, this.flushData);
39
- // Stop streaming on 'unload' event. Used instead of 'beforeunload', because 'unload' is not a cancelable event, so no other listeners can stop the event from occurring.
40
- window.addEventListener(UNLOAD_EVENT, this.stopSync);
41
37
  }
42
38
  };
43
39
  /**
@@ -51,14 +47,8 @@ var BrowserSignalListener = /** @class */ (function () {
51
47
  }
52
48
  if (typeof window !== 'undefined' && window.removeEventListener) {
53
49
  window.removeEventListener(PAGEHIDE_EVENT, this.flushData);
54
- window.removeEventListener(UNLOAD_EVENT, this.stopSync);
55
50
  }
56
51
  };
57
- BrowserSignalListener.prototype.stopSync = function () {
58
- // Close streaming connection
59
- if (this.syncManager && this.syncManager.pushManager)
60
- this.syncManager.pushManager.stop();
61
- };
62
52
  /**
63
53
  * flushData method.
64
54
  * Called when pagehide event is triggered. It flushed remaining impressions and events to the backend,
@@ -7,6 +7,7 @@ function Uint8ArrayToString(myUint8Arr) {
7
7
  }
8
8
  function StringToUint8Array(myString) {
9
9
  var charCodes = myString.split('').map(function (e) { return e.charCodeAt(0); });
10
+ // eslint-disable-next-line compat/compat
10
11
  return new Uint8Array(charCodes);
11
12
  }
12
13
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "Split Javascript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -22,7 +22,7 @@
22
22
  "build": "npm run build:cjs && npm run build:esm",
23
23
  "build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types",
24
24
  "build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs",
25
- "test": "jest",
25
+ "test": "jest --runInBand",
26
26
  "test:coverage": "jest --coverage",
27
27
  "all": "npm run check && npm run build && npm run test",
28
28
  "publish:rc": "npm run check && npm run test && npm run build && npm publish --tag rc",
@@ -60,12 +60,12 @@
60
60
  "@types/ioredis": "^4.28.0",
61
61
  "@types/jest": "^27.0.0",
62
62
  "@types/lodash": "^4.14.162",
63
- "@typescript-eslint/eslint-plugin": "^4.2.0",
64
- "@typescript-eslint/parser": "^4.2.0",
63
+ "@typescript-eslint/eslint-plugin": "^6.6.0",
64
+ "@typescript-eslint/parser": "^6.6.0",
65
65
  "cross-env": "^7.0.2",
66
66
  "csv-streamify": "^4.0.0",
67
- "eslint": "^7.32.0",
68
- "eslint-plugin-compat": "3.7.0",
67
+ "eslint": "^8.48.0",
68
+ "eslint-plugin-compat": "^4.2.0",
69
69
  "eslint-plugin-import": "^2.25.3",
70
70
  "fetch-mock": "^9.11.0",
71
71
  "ioredis": "^4.28.0",
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-undef */
2
1
  import { objectAssign } from '../../utils/lang/objectAssign';
3
2
  import { isString, isFiniteNumber, uniqAsStrings } from '../../utils/lang';
4
3
  import {
@@ -295,5 +294,6 @@ export function GaToSplit(sdkOptions: GoogleAnalyticsToSplitOptions, params: IIn
295
294
  }
296
295
 
297
296
  // Register the plugin, even if config is invalid, since, if not provided, it will block `ga` command queue.
297
+ // eslint-disable-next-line no-undef
298
298
  providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true, telemetryTracker);
299
299
  }
@@ -15,8 +15,7 @@ import { isConsentGranted } from '../consent';
15
15
 
16
16
  const VISIBILITYCHANGE_EVENT = 'visibilitychange';
17
17
  const PAGEHIDE_EVENT = 'pagehide';
18
- const UNLOAD_EVENT = 'unload';
19
- const EVENT_NAME = 'for unload page event.';
18
+ const EVENT_NAME = 'for visibilitychange and pagehide events.';
20
19
 
21
20
  /**
22
21
  * We'll listen for events over the window object.
@@ -33,7 +32,6 @@ export class BrowserSignalListener implements ISignalListener {
33
32
  ) {
34
33
  this.flushData = this.flushData.bind(this);
35
34
  this.flushDataIfHidden = this.flushDataIfHidden.bind(this);
36
- this.stopSync = this.stopSync.bind(this);
37
35
  this.fromImpressionsCollector = fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled);
38
36
  }
39
37
 
@@ -48,11 +46,9 @@ export class BrowserSignalListener implements ISignalListener {
48
46
  document.addEventListener(VISIBILITYCHANGE_EVENT, this.flushDataIfHidden);
49
47
  }
50
48
  if (typeof window !== 'undefined' && window.addEventListener) {
51
- // Some browsers like Safari does not fire the `visibilitychange` event when the page is being unloaded. So we also flush data in the `pagehide` event.
52
- // If both events are triggered, the last one will find the storage empty, so no duplicated data will be submitted.
49
+ // Some browsers, like Safari, does not fire the `visibilitychange` event when the page is being unloaded. Therefore, we also flush data in the `pagehide` event.
50
+ // If both events are triggered, the latter will find the storage empty, so no duplicate data will be submitted.
53
51
  window.addEventListener(PAGEHIDE_EVENT, this.flushData);
54
- // Stop streaming on 'unload' event. Used instead of 'beforeunload', because 'unload' is not a cancelable event, so no other listeners can stop the event from occurring.
55
- window.addEventListener(UNLOAD_EVENT, this.stopSync);
56
52
  }
57
53
  }
58
54
 
@@ -67,15 +63,9 @@ export class BrowserSignalListener implements ISignalListener {
67
63
  }
68
64
  if (typeof window !== 'undefined' && window.removeEventListener) {
69
65
  window.removeEventListener(PAGEHIDE_EVENT, this.flushData);
70
- window.removeEventListener(UNLOAD_EVENT, this.stopSync);
71
66
  }
72
67
  }
73
68
 
74
- stopSync() {
75
- // Close streaming connection
76
- if (this.syncManager && this.syncManager.pushManager) this.syncManager.pushManager.stop();
77
- }
78
-
79
69
  /**
80
70
  * flushData method.
81
71
  * Called when pagehide event is triggered. It flushed remaining impressions and events to the backend,
@@ -181,7 +181,7 @@ export class TelemetryCacheInMemory implements ITelemetryCacheSync {
181
181
  this.e = false;
182
182
  }
183
183
 
184
- private streamingEvents: StreamingEvent[] = []
184
+ private streamingEvents: StreamingEvent[] = [];
185
185
 
186
186
  popStreamingEvents() {
187
187
  return this.streamingEvents.splice(0);
@@ -33,7 +33,7 @@ interface IRedisCommand {
33
33
  * Redis adapter on top of the library of choice (written with ioredis) for some extra control.
34
34
  */
35
35
  export class RedisAdapter extends ioredis {
36
- private readonly log: ILogger
36
+ private readonly log: ILogger;
37
37
  private _options: object;
38
38
  private _notReadyCommandsQueue?: IRedisCommand[];
39
39
  private _runningCommands: ISet<Promise<any>>;
@@ -11,6 +11,7 @@ function Uint8ArrayToString(myUint8Arr: Uint8Array) { // @ts-ignore
11
11
 
12
12
  function StringToUint8Array(myString: string) {
13
13
  const charCodes = myString.split('').map((e) => e.charCodeAt(0));
14
+ // eslint-disable-next-line compat/compat
14
15
  return new Uint8Array(charCodes);
15
16
  }
16
17
 
@@ -13,7 +13,7 @@ const PIPELINE_METHODS = ['rpush', 'hincrby'];
13
13
 
14
14
  export class RedisMock {
15
15
 
16
- private pipelineMethods: any = { exec: jest.fn(asyncFunction) }
16
+ private pipelineMethods: any = { exec: jest.fn(asyncFunction) };
17
17
 
18
18
  constructor() {
19
19
  IDENTITY_METHODS.forEach(method => {
@@ -23,7 +23,6 @@ export declare class BrowserSignalListener implements ISignalListener {
23
23
  * Called when client is destroyed, it removes event listeners.
24
24
  */
25
25
  stop(): void;
26
- stopSync(): void;
27
26
  /**
28
27
  * flushData method.
29
28
  * Called when pagehide event is triggered. It flushed remaining impressions and events to the backend,
@@ -0,0 +1,6 @@
1
+ import { SplitIO } from '../types';
2
+ export declare function buildInstanceId(key: SplitIO.SplitKey, trafficType?: string): string;
3
+ export declare function parseInstanceId(instanceId: string): {
4
+ key: SplitIO.SplitKey;
5
+ trafficType?: string;
6
+ };
@@ -0,0 +1,7 @@
1
+ import { ILogger } from '../../logger/types';
2
+ /** validates the given SDK key */
3
+ export declare function validateApiKey(log: ILogger, maybeSdkKey: any): string | false;
4
+ export declare const usedKeysMap: Record<string, number>;
5
+ /** validates the given SDK key and also warns if it is in use */
6
+ export declare function validateAndTrackApiKey(log: ILogger, maybeSdkKey: any): string | false;
7
+ export declare function releaseApiKey(sdkKey: string): void;
@@ -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,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,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,3 +0,0 @@
1
- import { IMetadata } from '../dtos/types';
2
- import { ISettings } from '../types';
3
- export declare function metadataBuilder(settings: Pick<ISettings, 'version' | 'runtime'>): IMetadata;
@@ -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 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,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 {};