@splitsoftware/splitio-commons 1.10.1-rc.4 → 1.11.0

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 (41) hide show
  1. package/CHANGES.txt +1 -1
  2. package/cjs/evaluator/index.js +4 -1
  3. package/cjs/storages/KeyBuilder.js +1 -1
  4. package/cjs/storages/inRedis/SplitsCacheInRedis.js +2 -3
  5. package/cjs/storages/pluggable/SplitsCachePluggable.js +2 -3
  6. package/esm/evaluator/index.js +4 -1
  7. package/esm/storages/KeyBuilder.js +1 -1
  8. package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -3
  9. package/esm/storages/pluggable/SplitsCachePluggable.js +2 -3
  10. package/package.json +1 -1
  11. package/src/evaluator/index.ts +5 -2
  12. package/src/storages/KeyBuilder.ts +1 -1
  13. package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
  14. package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
  15. package/types/myLogger.d.ts +5 -0
  16. package/types/sdkClient/types.d.ts +18 -0
  17. package/types/storages/inMemory/CountsCacheInMemory.d.ts +20 -0
  18. package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +20 -0
  19. package/types/storages/inRedis/CountsCacheInRedis.d.ts +9 -0
  20. package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +9 -0
  21. package/types/storages/metadataBuilder.d.ts +3 -0
  22. package/types/sync/offline/LocalhostFromFile.d.ts +2 -0
  23. package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -0
  24. package/types/sync/offline/updaters/splitChangesUpdater.d.ts +0 -0
  25. package/types/sync/submitters/eventsSyncTask.d.ts +8 -0
  26. package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +5 -0
  27. package/types/sync/submitters/impressionCountsSyncTask.d.ts +13 -0
  28. package/types/sync/submitters/impressionsSyncTask.d.ts +14 -0
  29. package/types/sync/submitters/metricsSyncTask.d.ts +12 -0
  30. package/types/sync/submitters/submitterSyncTask.d.ts +10 -0
  31. package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +5 -0
  32. package/types/sync/syncTaskComposite.d.ts +5 -0
  33. package/types/trackers/filter/bloomFilter.d.ts +10 -0
  34. package/types/trackers/filter/dictionaryFilter.d.ts +8 -0
  35. package/types/trackers/filter/types.d.ts +5 -0
  36. package/types/utils/timeTracker/index.d.ts +70 -0
  37. package/types/sdkClient/identity.d.ts +0 -6
  38. package/types/utils/inputValidation/sdkKey.d.ts +0 -7
  39. /package/types/storages/inMemory/{UniqueKeysCacheInMemory.d.ts → uniqueKeysCacheInMemory.d.ts} +0 -0
  40. /package/types/storages/inMemory/{UniqueKeysCacheInMemoryCS.d.ts → uniqueKeysCacheInMemoryCS.d.ts} +0 -0
  41. /package/types/storages/inRedis/{UniqueKeysCacheInRedis.d.ts → uniqueKeysCacheInRedis.d.ts} +0 -0
package/CHANGES.txt CHANGED
@@ -1,4 +1,4 @@
1
- 1.11.0 (November XX, 2023)
1
+ 1.11.0 (November 3, 2023)
2
2
  - Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
3
3
  - Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
4
4
  - getTreatmentsByFlagSet and getTreatmentsByFlagSets
@@ -68,7 +68,10 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage) {
68
68
  }
69
69
  // evaluate related features
70
70
  return (0, thenable_1.thenable)(storedFlagNames) ?
71
- storedFlagNames.then(function (splitNames) { return evaluateFeatures(log, key, (0, sets_1.setToArray)(splitNames), attributes, storage); }) :
71
+ storedFlagNames.then(function (splitNames) { return evaluateFeatures(log, key, (0, sets_1.setToArray)(splitNames), attributes, storage); })
72
+ .catch(function () {
73
+ return {};
74
+ }) :
72
75
  evaluateFeatures(log, key, (0, sets_1.setToArray)(storedFlagNames), attributes, storage);
73
76
  }
74
77
  exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
@@ -17,7 +17,7 @@ var KeyBuilder = /** @class */ (function () {
17
17
  return this.prefix + ".trafficType." + trafficType;
18
18
  };
19
19
  KeyBuilder.prototype.buildFlagSetKey = function (flagSet) {
20
- return this.prefix + ".flagset." + flagSet;
20
+ return this.prefix + ".flagSet." + flagSet;
21
21
  };
22
22
  KeyBuilder.prototype.buildSplitKey = function (splitName) {
23
23
  return this.prefix + ".split." + splitName;
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
5
5
  var lang_1 = require("../../utils/lang");
6
6
  var constants_1 = require("./constants");
7
7
  var AbstractSplitsCacheAsync_1 = require("../AbstractSplitsCacheAsync");
8
- var sets_1 = require("../../utils/lang/sets");
9
8
  /**
10
9
  * Discard errors for an answer of multiple operations.
11
10
  */
@@ -179,8 +178,8 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
179
178
  * @todo this is a no-op method to be implemented
180
179
  */
181
180
  SplitsCacheInRedis.prototype.getNamesByFlagSets = function () {
182
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
183
- return new Promise(function (flagSets) { return new sets_1._Set([]); });
181
+ this.log.error(constants_1.LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with Redis storage yet.');
182
+ return Promise.reject();
184
183
  };
185
184
  /**
186
185
  * Check traffic type existence.
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
5
5
  var lang_1 = require("../../utils/lang");
6
6
  var constants_1 = require("./constants");
7
7
  var AbstractSplitsCacheAsync_1 = require("../AbstractSplitsCacheAsync");
8
- var sets_1 = require("../../utils/lang/sets");
9
8
  /**
10
9
  * ISplitsCacheAsync implementation for pluggable storages.
11
10
  */
@@ -153,8 +152,8 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
153
152
  * @todo this is a no-op method to be implemented
154
153
  */
155
154
  SplitsCachePluggable.prototype.getNamesByFlagSets = function () {
156
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
157
- return new Promise(function (flagSets) { return new sets_1._Set([]); });
155
+ this.log.error(constants_1.LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.');
156
+ return Promise.reject();
158
157
  };
159
158
  /**
160
159
  * Check traffic type existence.
@@ -62,7 +62,10 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
62
62
  }
63
63
  // evaluate related features
64
64
  return thenable(storedFlagNames) ?
65
- storedFlagNames.then(function (splitNames) { return evaluateFeatures(log, key, setToArray(splitNames), attributes, storage); }) :
65
+ storedFlagNames.then(function (splitNames) { return evaluateFeatures(log, key, setToArray(splitNames), attributes, storage); })
66
+ .catch(function () {
67
+ return {};
68
+ }) :
66
69
  evaluateFeatures(log, key, setToArray(storedFlagNames), attributes, storage);
67
70
  }
68
71
  function getEvaluation(log, splitJSON, key, attributes, storage) {
@@ -13,7 +13,7 @@ var KeyBuilder = /** @class */ (function () {
13
13
  return this.prefix + ".trafficType." + trafficType;
14
14
  };
15
15
  KeyBuilder.prototype.buildFlagSetKey = function (flagSet) {
16
- return this.prefix + ".flagset." + flagSet;
16
+ return this.prefix + ".flagSet." + flagSet;
17
17
  };
18
18
  KeyBuilder.prototype.buildSplitKey = function (splitName) {
19
19
  return this.prefix + ".split." + splitName;
@@ -2,7 +2,6 @@ import { __extends } from "tslib";
2
2
  import { isFiniteNumber, isNaNNumber } from '../../utils/lang';
3
3
  import { LOG_PREFIX } from './constants';
4
4
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
5
- import { _Set } from '../../utils/lang/sets';
6
5
  /**
7
6
  * Discard errors for an answer of multiple operations.
8
7
  */
@@ -176,8 +175,8 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
176
175
  * @todo this is a no-op method to be implemented
177
176
  */
178
177
  SplitsCacheInRedis.prototype.getNamesByFlagSets = function () {
179
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
180
- return new Promise(function (flagSets) { return new _Set([]); });
178
+ this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with Redis storage yet.');
179
+ return Promise.reject();
181
180
  };
182
181
  /**
183
182
  * Check traffic type existence.
@@ -2,7 +2,6 @@ import { __extends } from "tslib";
2
2
  import { isFiniteNumber, isNaNNumber } from '../../utils/lang';
3
3
  import { LOG_PREFIX } from './constants';
4
4
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
5
- import { _Set } from '../../utils/lang/sets';
6
5
  /**
7
6
  * ISplitsCacheAsync implementation for pluggable storages.
8
7
  */
@@ -150,8 +149,8 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
150
149
  * @todo this is a no-op method to be implemented
151
150
  */
152
151
  SplitsCachePluggable.prototype.getNamesByFlagSets = function () {
153
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
154
- return new Promise(function (flagSets) { return new _Set([]); });
152
+ this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.');
153
+ return Promise.reject();
155
154
  };
156
155
  /**
157
156
  * Check traffic type existence.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.10.1-rc.4",
3
+ "version": "1.11.0",
4
4
  "description": "Split Javascript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -94,7 +94,7 @@ export function evaluateFeaturesByFlagSets(
94
94
  flagSets: string[],
95
95
  attributes: SplitIO.Attributes | undefined,
96
96
  storage: IStorageSync | IStorageAsync,
97
- ): MaybeThenable<Record<string,IEvaluationResult>> {
97
+ ): MaybeThenable<Record<string, IEvaluationResult>> {
98
98
  let storedFlagNames: MaybeThenable<ISet<string>>;
99
99
 
100
100
  // get features by flag sets
@@ -107,7 +107,10 @@ export function evaluateFeaturesByFlagSets(
107
107
 
108
108
  // evaluate related features
109
109
  return thenable(storedFlagNames) ?
110
- storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) :
110
+ storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage))
111
+ .catch(() => {
112
+ return {};
113
+ }) :
111
114
  evaluateFeatures(log, key, setToArray(storedFlagNames), attributes, storage);
112
115
  }
113
116
 
@@ -21,7 +21,7 @@ export class KeyBuilder {
21
21
  }
22
22
 
23
23
  buildFlagSetKey(flagSet: string) {
24
- return `${this.prefix}.flagset.${flagSet}`;
24
+ return `${this.prefix}.flagSet.${flagSet}`;
25
25
  }
26
26
 
27
27
  buildSplitKey(splitName: string) {
@@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types';
5
5
  import { LOG_PREFIX } from './constants';
6
6
  import { ISplit } from '../../dtos/types';
7
7
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
8
- import { ISet, _Set } from '../../utils/lang/sets';
8
+ import { ISet } from '../../utils/lang/sets';
9
9
 
10
10
  /**
11
11
  * Discard errors for an answer of multiple operations.
@@ -196,8 +196,8 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
196
196
  * @todo this is a no-op method to be implemented
197
197
  */
198
198
  getNamesByFlagSets(): Promise<ISet<string>> {
199
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
200
- return new Promise(flagSets => new _Set([]));
199
+ this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with Redis storage yet.');
200
+ return Promise.reject();
201
201
  }
202
202
 
203
203
  /**
@@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types';
5
5
  import { ISplit } from '../../dtos/types';
6
6
  import { LOG_PREFIX } from './constants';
7
7
  import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
8
- import { ISet, _Set } from '../../utils/lang/sets';
8
+ import { ISet } from '../../utils/lang/sets';
9
9
 
10
10
  /**
11
11
  * ISplitsCacheAsync implementation for pluggable storages.
@@ -162,8 +162,8 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync {
162
162
  * @todo this is a no-op method to be implemented
163
163
  */
164
164
  getNamesByFlagSets(): Promise<ISet<string>> {
165
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
166
- return new Promise(flagSets => new _Set([]));
165
+ this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.');
166
+ return Promise.reject();
167
167
  }
168
168
 
169
169
  /**
@@ -0,0 +1,5 @@
1
+ export declare const myLogger: {
2
+ log: (msg: any) => void;
3
+ logCsv: (msg: any) => void;
4
+ logToFile: (file: any, msg: any) => void;
5
+ };
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ import { IMetadata } from '../dtos/types';
2
+ import { ISettings } from '../types';
3
+ export declare function metadataBuilder(settings: Pick<ISettings, 'version' | 'runtime'>): IMetadata;
@@ -0,0 +1,2 @@
1
+ import { SplitIO } from '../../types';
2
+ export declare function LocalhostFromFile(): SplitIO.LocalhostFactory;
@@ -0,0 +1,2 @@
1
+ import { ISplitsParser } from './types';
2
+ export declare function splitsParserFromFileFactory(): ISplitsParser;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,5 @@
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>;
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,10 @@
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>;
@@ -0,0 +1,5 @@
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>;
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,10 @@
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
+ }
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ export interface IFilter {
2
+ add(data: string): boolean;
3
+ contains(data: string): boolean;
4
+ clear(): void;
5
+ }
@@ -0,0 +1,70 @@
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 {};
@@ -1,6 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
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;