@splitsoftware/splitio-commons 1.6.2-rc.12 → 1.6.2-rc.13
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.
- package/cjs/listeners/browser.js +9 -11
- package/cjs/sdkFactory/index.js +7 -24
- package/cjs/storages/inLocalStorage/index.js +14 -10
- package/cjs/storages/inMemory/InMemoryStorage.js +10 -7
- package/cjs/storages/inMemory/InMemoryStorageCS.js +10 -7
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +57 -34
- package/cjs/storages/inRedis/index.js +4 -2
- package/cjs/storages/pluggable/index.js +4 -2
- package/cjs/sync/submitters/submitterManager.js +1 -1
- package/cjs/sync/submitters/telemetrySubmitter.js +4 -40
- package/cjs/trackers/impressionObserver/utils.js +1 -17
- package/cjs/trackers/uniqueKeysTracker.js +1 -1
- package/cjs/utils/settingsValidation/index.js +7 -1
- package/esm/listeners/browser.js +9 -11
- package/esm/sdkFactory/index.js +7 -24
- package/esm/storages/inLocalStorage/index.js +15 -11
- package/esm/storages/inMemory/InMemoryStorage.js +10 -7
- package/esm/storages/inMemory/InMemoryStorageCS.js +10 -7
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +58 -35
- package/esm/storages/inRedis/index.js +4 -2
- package/esm/storages/pluggable/index.js +4 -2
- package/esm/sync/submitters/submitterManager.js +1 -1
- package/esm/sync/submitters/telemetrySubmitter.js +4 -39
- package/esm/trackers/impressionObserver/utils.js +1 -15
- package/esm/trackers/uniqueKeysTracker.js +1 -1
- package/esm/utils/settingsValidation/index.js +7 -1
- package/package.json +2 -1
- package/src/listeners/browser.ts +9 -13
- package/src/sdkClient/sdkClient.ts +1 -1
- package/src/sdkFactory/index.ts +7 -29
- package/src/sdkFactory/types.ts +2 -2
- package/src/storages/inLocalStorage/index.ts +16 -11
- package/src/storages/inMemory/InMemoryStorage.ts +11 -7
- package/src/storages/inMemory/InMemoryStorageCS.ts +11 -7
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +66 -33
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +1 -1
- package/src/storages/inRedis/index.ts +4 -1
- package/src/storages/pluggable/TelemetryCachePluggable.ts +1 -1
- package/src/storages/pluggable/index.ts +4 -2
- package/src/storages/types.ts +41 -60
- package/src/sync/submitters/submitter.ts +2 -2
- package/src/sync/submitters/submitterManager.ts +1 -1
- package/src/sync/submitters/telemetrySubmitter.ts +5 -41
- package/src/sync/submitters/types.ts +5 -5
- package/src/trackers/impressionObserver/utils.ts +1 -16
- package/src/trackers/strategy/strategyNone.ts +9 -9
- package/src/trackers/strategy/strategyOptimized.ts +9 -9
- package/src/trackers/uniqueKeysTracker.ts +6 -6
- package/src/utils/settingsValidation/index.ts +5 -1
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +19 -8
- package/types/storages/types.d.ts +31 -41
- package/types/sync/submitters/submitter.d.ts +2 -2
- package/types/sync/submitters/telemetrySubmitter.d.ts +2 -10
- package/types/sync/submitters/types.d.ts +6 -6
- package/types/trackers/impressionObserver/utils.d.ts +0 -8
- package/types/trackers/strategy/strategyNone.d.ts +2 -2
- package/types/trackers/strategy/strategyOptimized.d.ts +2 -2
- package/types/trackers/uniqueKeysTracker.d.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MaybeThenable,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { SplitIO, ImpressionDTO, SDKMode } from '../types';
|
|
1
|
+
import { MaybeThenable, ISplit } from '../dtos/types';
|
|
2
|
+
import { EventDataType, HttpErrors, HttpLatencies, ImpressionDataType, LastSync, Method, MethodExceptions, MethodLatencies, MultiMethodExceptions, MultiMethodLatencies, MultiConfigs, OperationType, StoredEventWithMetadata, StoredImpressionWithMetadata, StreamingEvent, UniqueKeysPayloadCs, UniqueKeysPayloadSs, TelemetryUsageStatsPayload } from '../sync/submitters/types';
|
|
3
|
+
import { SplitIO, ImpressionDTO, ISettings } from '../types';
|
|
5
4
|
/**
|
|
6
5
|
* Interface of a pluggable storage wrapper.
|
|
7
6
|
*/
|
|
@@ -264,48 +263,43 @@ export interface IImpressionsCacheBase {
|
|
|
264
263
|
export interface IEventsCacheBase {
|
|
265
264
|
track(data: SplitIO.EventData, size?: number): MaybeThenable<boolean>;
|
|
266
265
|
}
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
export interface IImpressionCountsCacheBase {
|
|
267
|
+
track(featureName: string, timeFrame: number, amount: number): void;
|
|
268
|
+
}
|
|
269
|
+
export interface IUniqueKeysCacheBase {
|
|
270
|
+
track(key: string, value: string): void;
|
|
271
|
+
}
|
|
272
|
+
/** Impressions and events cache for standalone and partial consumer modes (sync methods) */
|
|
273
|
+
export interface IRecorderCacheSync<T> {
|
|
269
274
|
isEmpty(): boolean;
|
|
270
275
|
clear(): void;
|
|
271
276
|
pop(toMerge?: T): T;
|
|
272
277
|
}
|
|
273
|
-
export interface IImpressionsCacheSync extends IImpressionsCacheBase,
|
|
278
|
+
export interface IImpressionsCacheSync extends IImpressionsCacheBase, IRecorderCacheSync<ImpressionDTO[]> {
|
|
274
279
|
track(data: ImpressionDTO[]): void;
|
|
275
280
|
setOnFullQueueCb(cb: () => void): void;
|
|
276
281
|
}
|
|
277
|
-
export interface IEventsCacheSync extends IEventsCacheBase,
|
|
282
|
+
export interface IEventsCacheSync extends IEventsCacheBase, IRecorderCacheSync<SplitIO.EventData[]> {
|
|
278
283
|
track(data: SplitIO.EventData, size?: number): boolean;
|
|
279
284
|
setOnFullQueueCb(cb: () => void): void;
|
|
280
285
|
}
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
export interface IImpressionCountsCacheSync extends IImpressionCountsCacheBase, IRecorderCacheSync<Record<string, number>> {
|
|
287
|
+
}
|
|
288
|
+
export interface IUniqueKeysCacheSync extends IUniqueKeysCacheBase, IRecorderCacheSync<UniqueKeysPayloadSs | UniqueKeysPayloadCs> {
|
|
289
|
+
setOnFullQueueCb(cb: () => void): void;
|
|
290
|
+
}
|
|
291
|
+
/** Impressions and events cache for consumer and producer modes (async methods) */
|
|
292
|
+
export interface IRecorderCacheAsync<T> {
|
|
283
293
|
count(): Promise<number>;
|
|
284
294
|
drop(count?: number): Promise<void>;
|
|
285
295
|
popNWithMetadata(count: number): Promise<T>;
|
|
286
296
|
}
|
|
287
|
-
export interface IImpressionsCacheAsync extends IImpressionsCacheBase,
|
|
297
|
+
export interface IImpressionsCacheAsync extends IImpressionsCacheBase, IRecorderCacheAsync<StoredImpressionWithMetadata[]> {
|
|
288
298
|
track(data: ImpressionDTO[]): Promise<void>;
|
|
289
299
|
}
|
|
290
|
-
export interface IEventsCacheAsync extends IEventsCacheBase,
|
|
300
|
+
export interface IEventsCacheAsync extends IEventsCacheBase, IRecorderCacheAsync<StoredEventWithMetadata[]> {
|
|
291
301
|
track(data: SplitIO.EventData, size?: number): Promise<boolean>;
|
|
292
302
|
}
|
|
293
|
-
/**
|
|
294
|
-
* Impression counts cache for impressions dedup in standalone and producer mode.
|
|
295
|
-
* Only in memory. Named `ImpressionsCounter` in spec.
|
|
296
|
-
*/
|
|
297
|
-
export interface IImpressionCountsCacheSync extends IRecorderCacheProducerSync<Record<string, number>> {
|
|
298
|
-
track(featureName: string, timeFrame: number, amount: number): void;
|
|
299
|
-
isEmpty(): boolean;
|
|
300
|
-
pop(toMerge?: Record<string, number>): Record<string, number>;
|
|
301
|
-
}
|
|
302
|
-
export interface IUniqueKeysCacheBase {
|
|
303
|
-
track(key: string, value: string): void;
|
|
304
|
-
isEmpty(): boolean;
|
|
305
|
-
pop(): UniqueKeysPayloadSs | UniqueKeysPayloadCs;
|
|
306
|
-
setOnFullQueueCb(cb: () => void): void;
|
|
307
|
-
clear(): void;
|
|
308
|
-
}
|
|
309
303
|
/**
|
|
310
304
|
* Telemetry storage interface for standalone and partial consumer modes.
|
|
311
305
|
* Methods are sync because data is stored in memory.
|
|
@@ -356,7 +350,7 @@ export interface ITelemetryEvaluationProducerSync {
|
|
|
356
350
|
}
|
|
357
351
|
export interface ITelemetryStorageProducerSync extends ITelemetryInitProducerSync, ITelemetryRuntimeProducerSync, ITelemetryEvaluationProducerSync {
|
|
358
352
|
}
|
|
359
|
-
export interface ITelemetryCacheSync extends ITelemetryStorageConsumerSync, ITelemetryStorageProducerSync {
|
|
353
|
+
export interface ITelemetryCacheSync extends ITelemetryStorageConsumerSync, ITelemetryStorageProducerSync, IRecorderCacheSync<TelemetryUsageStatsPayload> {
|
|
360
354
|
}
|
|
361
355
|
/**
|
|
362
356
|
* Telemetry storage interface for consumer mode.
|
|
@@ -377,7 +371,7 @@ export interface ITelemetryCacheAsync extends ITelemetryEvaluationProducerAsync,
|
|
|
377
371
|
/**
|
|
378
372
|
* Storages
|
|
379
373
|
*/
|
|
380
|
-
export interface IStorageBase<TSplitsCache extends ISplitsCacheBase, TSegmentsCache extends ISegmentsCacheBase, TImpressionsCache extends IImpressionsCacheBase, TImpressionsCountCache extends
|
|
374
|
+
export interface IStorageBase<TSplitsCache extends ISplitsCacheBase, TSegmentsCache extends ISegmentsCacheBase, TImpressionsCache extends IImpressionsCacheBase, TImpressionsCountCache extends IImpressionCountsCacheBase, TEventsCache extends IEventsCacheBase, TTelemetryCache extends ITelemetryCacheSync | ITelemetryCacheAsync, TUniqueKeysCache extends IUniqueKeysCacheBase> {
|
|
381
375
|
splits: TSplitsCache;
|
|
382
376
|
segments: TSegmentsCache;
|
|
383
377
|
impressions: TImpressionsCache;
|
|
@@ -388,23 +382,19 @@ export interface IStorageBase<TSplitsCache extends ISplitsCacheBase, TSegmentsCa
|
|
|
388
382
|
destroy(): void | Promise<void>;
|
|
389
383
|
shared?: (matchingKey: string, onReadyCb: (error?: any) => void) => this;
|
|
390
384
|
}
|
|
391
|
-
export interface IStorageSync extends IStorageBase<ISplitsCacheSync, ISegmentsCacheSync, IImpressionsCacheSync, IImpressionCountsCacheSync, IEventsCacheSync, ITelemetryCacheSync,
|
|
385
|
+
export interface IStorageSync extends IStorageBase<ISplitsCacheSync, ISegmentsCacheSync, IImpressionsCacheSync, IImpressionCountsCacheSync, IEventsCacheSync, ITelemetryCacheSync, IUniqueKeysCacheSync> {
|
|
392
386
|
}
|
|
393
|
-
export interface IStorageAsync extends IStorageBase<ISplitsCacheAsync, ISegmentsCacheAsync, IImpressionsCacheAsync | IImpressionsCacheSync,
|
|
387
|
+
export interface IStorageAsync extends IStorageBase<ISplitsCacheAsync, ISegmentsCacheAsync, IImpressionsCacheAsync | IImpressionsCacheSync, IImpressionCountsCacheBase, IEventsCacheAsync | IEventsCacheSync, ITelemetryCacheAsync | ITelemetryCacheSync, IUniqueKeysCacheBase> {
|
|
394
388
|
}
|
|
395
389
|
/** StorageFactory */
|
|
396
390
|
export declare type DataLoader = (storage: IStorageSync, matchingKey: string) => void;
|
|
397
391
|
export interface IStorageFactoryParams {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
impressionsMode?: string;
|
|
404
|
-
matchingKey?: string;
|
|
405
|
-
splitFiltersValidation?: ISplitFiltersValidation;
|
|
392
|
+
settings: ISettings;
|
|
393
|
+
/**
|
|
394
|
+
* Error-first callback invoked when the storage is ready to be used. An error means that the storage failed to connect and shouldn't be used.
|
|
395
|
+
* It is meant for emitting SDK_READY event in consumer mode, and waiting before using the storage in the synchronizer.
|
|
396
|
+
*/
|
|
406
397
|
onReadyCb: (error?: any) => void;
|
|
407
|
-
metadata: IMetadata;
|
|
408
398
|
}
|
|
409
399
|
export declare type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
|
|
410
400
|
export declare type IStorageSyncFactory = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ISyncTask } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { IRecorderCacheSync } from '../../storages/types';
|
|
3
3
|
import { ILogger } from '../../logger/types';
|
|
4
4
|
import { IResponse } from '../../services/types';
|
|
5
5
|
/**
|
|
6
6
|
* Base function to create submitters, such as ImpressionsSubmitter and EventsSubmitter
|
|
7
7
|
*/
|
|
8
|
-
export declare function submitterFactory<T>(log: ILogger, postClient: (body: string) => Promise<IResponse>, sourceCache:
|
|
8
|
+
export declare function submitterFactory<T>(log: ILogger, postClient: (body: string) => Promise<IResponse>, sourceCache: IRecorderCacheSync<T>, postRate: number, dataName: string, fromCacheToPayload?: (cacheData: T) => any, maxRetries?: number, debugLogs?: boolean): ISyncTask<[], void>;
|
|
9
9
|
/**
|
|
10
10
|
* Decorates a provided submitter with a first execution window
|
|
11
11
|
*/
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ITelemetryCacheSync } from '../../storages/types';
|
|
2
|
+
import { TelemetryConfigStatsPayload, TelemetryConfigStats } from './types';
|
|
3
3
|
import { ISettings, SDKMode } from '../../types';
|
|
4
4
|
import { ISdkFactoryContextSync } from '../../sdkFactory/types';
|
|
5
|
-
/**
|
|
6
|
-
* Converts data from telemetry cache into /metrics/usage request payload.
|
|
7
|
-
*/
|
|
8
|
-
export declare function telemetryCacheStatsAdapter(telemetry: ITelemetryCacheSync, splits?: ISplitsCacheSync, segments?: ISegmentsCacheSync): {
|
|
9
|
-
isEmpty(): boolean;
|
|
10
|
-
clear(): void;
|
|
11
|
-
pop(): TelemetryUsageStatsPayload;
|
|
12
|
-
};
|
|
13
5
|
export declare function getTelemetryConfigStats(mode: SDKMode, storageType: string): TelemetryConfigStats;
|
|
14
6
|
/**
|
|
15
7
|
* Converts data from telemetry cache and settings into /metrics/config request payload.
|
|
@@ -97,19 +97,19 @@ export declare type TOKEN = 'to';
|
|
|
97
97
|
export declare type SEGMENT = 'se';
|
|
98
98
|
export declare type MY_SEGMENT = 'ms';
|
|
99
99
|
export declare type OperationType = SPLITS | IMPRESSIONS | IMPRESSIONS_COUNT | EVENTS | TELEMETRY | TOKEN | SEGMENT | MY_SEGMENT;
|
|
100
|
-
export declare type LastSync = Record<OperationType, number | undefined
|
|
101
|
-
export declare type HttpErrors = Record<OperationType, {
|
|
100
|
+
export declare type LastSync = Partial<Record<OperationType, number | undefined>>;
|
|
101
|
+
export declare type HttpErrors = Partial<Record<OperationType, {
|
|
102
102
|
[statusCode: string]: number;
|
|
103
|
-
}
|
|
104
|
-
export declare type HttpLatencies = Record<OperationType, Array<number
|
|
103
|
+
}>>;
|
|
104
|
+
export declare type HttpLatencies = Partial<Record<OperationType, Array<number>>>;
|
|
105
105
|
export declare type TREATMENT = 't';
|
|
106
106
|
export declare type TREATMENTS = 'ts';
|
|
107
107
|
export declare type TREATMENT_WITH_CONFIG = 'tc';
|
|
108
108
|
export declare type TREATMENTS_WITH_CONFIG = 'tcs';
|
|
109
109
|
export declare type TRACK = 'tr';
|
|
110
110
|
export declare type Method = TREATMENT | TREATMENTS | TREATMENT_WITH_CONFIG | TREATMENTS_WITH_CONFIG | TRACK;
|
|
111
|
-
export declare type MethodLatencies = Record<Method, Array<number
|
|
112
|
-
export declare type MethodExceptions = Record<Method, number
|
|
111
|
+
export declare type MethodLatencies = Partial<Record<Method, Array<number>>>;
|
|
112
|
+
export declare type MethodExceptions = Partial<Record<Method, number>>;
|
|
113
113
|
export declare type CONNECTION_ESTABLISHED = 0;
|
|
114
114
|
export declare type OCCUPANCY_PRI = 10;
|
|
115
115
|
export declare type OCCUPANCY_SEC = 20;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { ISettings } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Checks if impressions previous time should be added or not.
|
|
4
|
-
*/
|
|
5
|
-
export declare function shouldAddPt(settings: ISettings): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Checks if it should dedupe impressions or not.
|
|
8
|
-
*/
|
|
9
|
-
export declare function shouldBeOptimized(settings: ISettings): boolean;
|
|
10
2
|
/**
|
|
11
3
|
* Storage is async if mode is consumer or partial consumer
|
|
12
4
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IImpressionCountsCacheBase } from '../../storages/types';
|
|
2
2
|
import { IStrategy, IUniqueKeysTracker } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* None strategy for impressions tracker.
|
|
@@ -7,4 +7,4 @@ import { IStrategy, IUniqueKeysTracker } from '../types';
|
|
|
7
7
|
* @param uniqueKeysTracker unique keys tracker in charge of tracking the unique keys per split.
|
|
8
8
|
* @returns IStrategyResult
|
|
9
9
|
*/
|
|
10
|
-
export declare function strategyNoneFactory(impressionsCounter:
|
|
10
|
+
export declare function strategyNoneFactory(impressionsCounter: IImpressionCountsCacheBase, uniqueKeysTracker: IUniqueKeysTracker): IStrategy;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IImpressionCountsCacheBase } from '../../storages/types';
|
|
2
2
|
import { IImpressionObserver } from '../impressionObserver/types';
|
|
3
3
|
import { IStrategy } from '../types';
|
|
4
4
|
/**
|
|
@@ -8,4 +8,4 @@ import { IStrategy } from '../types';
|
|
|
8
8
|
* @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
|
|
9
9
|
* @returns IStrategyResult
|
|
10
10
|
*/
|
|
11
|
-
export declare function strategyOptimizedFactory(impressionsObserver: IImpressionObserver, impressionsCounter:
|
|
11
|
+
export declare function strategyOptimizedFactory(impressionsObserver: IImpressionObserver, impressionsCounter: IImpressionCountsCacheBase): IStrategy;
|
|
@@ -4,7 +4,7 @@ import { IFilterAdapter, IUniqueKeysTracker } from './types';
|
|
|
4
4
|
/**
|
|
5
5
|
* Trackes uniques keys
|
|
6
6
|
* Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
|
|
7
|
-
*
|
|
7
|
+
* or schedule to be sent; if not it will be added in an internal cache and sent in the next post.
|
|
8
8
|
*
|
|
9
9
|
* @param log Logger instance
|
|
10
10
|
* @param uniqueKeysCache cache to save unique keys
|