@splitsoftware/splitio-commons 2.0.0-rc.4 → 2.0.0-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.
- package/CHANGES.txt +1 -0
- package/cjs/integrations/pluggable.js +2 -2
- package/cjs/logger/sdkLogger.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +2 -21
- package/cjs/sdkClient/client.js +0 -1
- package/cjs/sdkClient/clientAttributesDecoration.js +9 -9
- package/cjs/sdkClient/clientCS.js +2 -2
- package/cjs/services/splitApi.js +13 -13
- package/cjs/services/splitHttpClient.js +2 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +1 -4
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -4
- package/cjs/storages/dataLoader.js +5 -6
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +10 -10
- package/cjs/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -5
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -3
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +3 -3
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/cjs/storages/pluggable/inMemoryWrapper.js +1 -1
- package/cjs/storages/pluggable/index.js +1 -1
- package/cjs/storages/pluggable/wrapperAdapter.js +2 -2
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +8 -8
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -13
- package/cjs/sync/streaming/AuthClient/index.js +2 -2
- package/cjs/sync/streaming/SSEClient/index.js +4 -7
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +5 -4
- package/cjs/sync/streaming/SSEHandler/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/parseUtils.js +13 -13
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/sync/syncTask.js +4 -4
- package/cjs/trackers/eventTracker.js +2 -2
- package/cjs/trackers/impressionsTracker.js +5 -5
- package/cjs/trackers/strategy/strategyDebug.js +1 -1
- package/cjs/trackers/strategy/strategyNone.js +2 -2
- package/cjs/trackers/strategy/strategyOptimized.js +2 -2
- package/cjs/trackers/uniqueKeysTracker.js +3 -3
- package/cjs/utils/Backoff.js +0 -4
- package/cjs/utils/Semver.js +1 -1
- package/cjs/utils/base64/index.js +2 -2
- package/cjs/utils/decompress/index.js +4 -4
- package/cjs/utils/lang/binarySearch.js +2 -2
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +1 -1
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/murmur3/utfx.js +10 -17
- package/cjs/utils/promise/wrapper.js +2 -2
- package/cjs/utils/settingsValidation/index.js +2 -2
- package/cjs/utils/settingsValidation/integrations/common.js +4 -4
- package/cjs/utils/settingsValidation/integrations/configurable.js +3 -3
- package/cjs/utils/settingsValidation/integrations/pluggable.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -1
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +8 -11
- package/cjs/utils/settingsValidation/storage/storageCS.js +2 -2
- package/cjs/utils/settingsValidation/url.js +3 -3
- package/esm/integrations/pluggable.js +2 -2
- package/esm/logger/sdkLogger.js +2 -2
- package/esm/readiness/sdkReadinessManager.js +2 -21
- package/esm/sdkClient/client.js +0 -1
- package/esm/sdkClient/clientAttributesDecoration.js +9 -9
- package/esm/sdkClient/clientCS.js +2 -2
- package/esm/services/splitApi.js +13 -13
- package/esm/services/splitHttpClient.js +2 -2
- package/esm/storages/AbstractSplitsCacheAsync.js +1 -4
- package/esm/storages/AbstractSplitsCacheSync.js +1 -4
- package/esm/storages/dataLoader.js +5 -6
- package/esm/storages/findLatencyIndex.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +1 -6
- package/esm/storages/inMemory/AttributesCacheInMemory.js +10 -10
- package/esm/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/InMemoryStorage.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +0 -5
- package/esm/storages/inRedis/SplitsCacheInRedis.js +1 -3
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -3
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/esm/storages/pluggable/TelemetryCachePluggable.js +3 -3
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/inMemoryWrapper.js +1 -1
- package/esm/storages/pluggable/index.js +1 -1
- package/esm/storages/pluggable/wrapperAdapter.js +2 -2
- package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/esm/sync/offline/syncManagerOffline.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +8 -8
- package/esm/sync/polling/updaters/splitChangesUpdater.js +13 -13
- package/esm/sync/streaming/AuthClient/index.js +2 -2
- package/esm/sync/streaming/SSEClient/index.js +4 -7
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/esm/sync/streaming/SSEHandler/NotificationParser.js +5 -4
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +3 -3
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/esm/sync/streaming/parseUtils.js +13 -13
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/sync/syncTask.js +4 -4
- package/esm/trackers/eventTracker.js +2 -2
- package/esm/trackers/impressionsTracker.js +5 -5
- package/esm/trackers/strategy/strategyDebug.js +1 -1
- package/esm/trackers/strategy/strategyNone.js +2 -2
- package/esm/trackers/strategy/strategyOptimized.js +2 -2
- package/esm/trackers/uniqueKeysTracker.js +3 -3
- package/esm/utils/Backoff.js +0 -4
- package/esm/utils/Semver.js +1 -1
- package/esm/utils/base64/index.js +2 -2
- package/esm/utils/decompress/index.js +4 -4
- package/esm/utils/lang/binarySearch.js +2 -2
- package/esm/utils/murmur3/murmur3_128.js +1 -1
- package/esm/utils/murmur3/murmur3_128_x86.js +1 -1
- package/esm/utils/murmur3/murmur3_64.js +1 -1
- package/esm/utils/murmur3/utfx.js +10 -17
- package/esm/utils/promise/wrapper.js +2 -2
- package/esm/utils/settingsValidation/index.js +2 -2
- package/esm/utils/settingsValidation/integrations/common.js +4 -4
- package/esm/utils/settingsValidation/integrations/configurable.js +3 -3
- package/esm/utils/settingsValidation/integrations/pluggable.js +2 -2
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -1
- package/esm/utils/settingsValidation/logger/commons.js +1 -1
- package/esm/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +8 -11
- package/esm/utils/settingsValidation/storage/storageCS.js +2 -2
- package/esm/utils/settingsValidation/url.js +3 -3
- package/package.json +3 -2
- package/src/dtos/types.ts +1 -1
- package/src/evaluator/Engine.ts +1 -1
- package/src/evaluator/combiners/ifelseif.ts +1 -1
- package/src/evaluator/condition/index.ts +1 -1
- package/src/evaluator/index.ts +1 -1
- package/src/evaluator/parser/index.ts +1 -1
- package/src/evaluator/types.ts +1 -1
- package/src/evaluator/value/index.ts +1 -1
- package/src/evaluator/value/sanitize.ts +1 -1
- package/src/integrations/pluggable.ts +3 -3
- package/src/integrations/types.ts +3 -2
- package/src/listeners/browser.ts +3 -2
- package/src/logger/index.ts +6 -6
- package/src/logger/sdkLogger.ts +4 -4
- package/src/logger/types.ts +11 -13
- package/src/readiness/readinessManager.ts +5 -4
- package/src/readiness/sdkReadinessManager.ts +6 -23
- package/src/readiness/types.ts +5 -4
- package/src/sdkClient/client.ts +5 -6
- package/src/sdkClient/clientAttributesDecoration.ts +10 -10
- package/src/sdkClient/clientCS.ts +5 -5
- package/src/sdkClient/clientInputValidation.ts +2 -1
- package/src/sdkClient/identity.ts +1 -1
- package/src/sdkClient/sdkClient.ts +2 -2
- package/src/sdkClient/sdkClientMethod.ts +1 -1
- package/src/sdkClient/sdkClientMethodCS.ts +3 -3
- package/src/sdkFactory/index.ts +3 -3
- package/src/sdkFactory/types.ts +8 -7
- package/src/sdkManager/index.ts +2 -1
- package/src/services/splitApi.ts +13 -13
- package/src/services/splitHttpClient.ts +2 -2
- package/src/storages/AbstractMySegmentsCacheSync.ts +1 -1
- package/src/storages/AbstractSplitsCacheAsync.ts +1 -4
- package/src/storages/AbstractSplitsCacheSync.ts +1 -4
- package/src/storages/dataLoader.ts +7 -8
- package/src/storages/findLatencyIndex.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -6
- package/src/storages/inMemory/AttributesCacheInMemory.ts +11 -11
- package/src/storages/inMemory/EventsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +5 -5
- package/src/storages/inMemory/InMemoryStorage.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +0 -5
- package/src/storages/inRedis/EventsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/ImpressionsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -3
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -1
- package/src/storages/pluggable/EventsCachePluggable.ts +2 -2
- package/src/storages/pluggable/ImpressionsCachePluggable.ts +3 -3
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
- package/src/storages/pluggable/TelemetryCachePluggable.ts +3 -3
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -1
- package/src/storages/pluggable/inMemoryWrapper.ts +1 -1
- package/src/storages/pluggable/index.ts +1 -1
- package/src/storages/pluggable/wrapperAdapter.ts +2 -2
- package/src/storages/types.ts +51 -68
- package/src/storages/utils.ts +3 -2
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
- package/src/sync/offline/syncManagerOffline.ts +1 -1
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +8 -8
- package/src/sync/polling/updaters/splitChangesUpdater.ts +13 -13
- package/src/sync/streaming/AuthClient/index.ts +2 -2
- package/src/sync/streaming/SSEClient/index.ts +4 -7
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +1 -1
- package/src/sync/streaming/SSEHandler/NotificationParser.ts +5 -4
- package/src/sync/streaming/SSEHandler/index.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +3 -3
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +4 -4
- package/src/sync/streaming/parseUtils.ts +13 -13
- package/src/sync/streaming/types.ts +2 -2
- package/src/sync/submitters/impressionsSubmitter.ts +2 -2
- package/src/sync/submitters/telemetrySubmitter.ts +4 -3
- package/src/sync/submitters/types.ts +1 -1
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/sync/syncTask.ts +4 -4
- package/src/trackers/eventTracker.ts +4 -3
- package/src/trackers/impressionObserver/ImpressionObserver.ts +4 -4
- package/src/trackers/impressionObserver/buildKey.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverCS.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverSS.ts +2 -2
- package/src/trackers/impressionObserver/types.ts +2 -2
- package/src/trackers/impressionsTracker.ts +8 -7
- package/src/trackers/strategy/strategyDebug.ts +3 -3
- package/src/trackers/strategy/strategyNone.ts +4 -4
- package/src/trackers/strategy/strategyOptimized.ts +5 -5
- package/src/trackers/types.ts +5 -5
- package/src/trackers/uniqueKeysTracker.ts +3 -3
- package/src/types.ts +37 -1355
- package/src/utils/Backoff.ts +0 -4
- package/src/utils/MinEventEmitter.ts +2 -3
- package/src/utils/MinEvents.ts +2 -2
- package/src/utils/Semver.ts +1 -1
- package/src/utils/base64/index.ts +2 -2
- package/src/utils/constants/index.ts +9 -10
- package/src/utils/decompress/index.ts +4 -4
- package/src/utils/inputValidation/attributes.ts +1 -1
- package/src/utils/inputValidation/eventProperties.ts +1 -1
- package/src/utils/inputValidation/key.ts +1 -1
- package/src/utils/inputValidation/preloadedData.ts +1 -2
- package/src/utils/inputValidation/trafficTypeExistence.ts +2 -2
- package/src/utils/key/index.ts +1 -1
- package/src/utils/lang/binarySearch.ts +2 -2
- package/src/utils/murmur3/murmur3_128.ts +1 -1
- package/src/utils/murmur3/murmur3_128_x86.ts +1 -1
- package/src/utils/murmur3/murmur3_64.ts +1 -1
- package/src/utils/murmur3/utfx.ts +10 -17
- package/src/utils/promise/wrapper.ts +2 -2
- package/src/utils/settingsValidation/consent.ts +2 -2
- package/src/utils/settingsValidation/impressionsMode.ts +1 -1
- package/src/utils/settingsValidation/index.ts +2 -2
- package/src/utils/settingsValidation/integrations/common.ts +4 -4
- package/src/utils/settingsValidation/integrations/configurable.ts +3 -3
- package/src/utils/settingsValidation/integrations/pluggable.ts +2 -2
- package/src/utils/settingsValidation/logger/builtinLogger.ts +3 -3
- package/src/utils/settingsValidation/logger/commons.ts +3 -3
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +3 -3
- package/src/utils/settingsValidation/splitFilters.ts +9 -12
- package/src/utils/settingsValidation/storage/storageCS.ts +5 -4
- package/src/utils/settingsValidation/url.ts +3 -3
- package/types/splitio.d.ts +1019 -1381
package/types/splitio.d.ts
CHANGED
|
@@ -8,334 +8,759 @@ export as namespace SplitIO;
|
|
|
8
8
|
export = SplitIO;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Common settings properties.
|
|
12
12
|
*/
|
|
13
|
-
interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
interface EventEmitter extends IEventEmitter {
|
|
27
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
28
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
29
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
30
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
31
|
-
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
32
|
-
removeAllListeners(event?: string | symbol): this;
|
|
33
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
34
|
-
setMaxListeners(n: number): this;
|
|
35
|
-
getMaxListeners(): number;
|
|
36
|
-
listeners(event: string | symbol): Function[];
|
|
37
|
-
rawListeners(event: string | symbol): Function[];
|
|
38
|
-
listenerCount(type: string | symbol): number;
|
|
39
|
-
// Added in Node 6...
|
|
40
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
41
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
42
|
-
eventNames(): Array<string | symbol>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @typedef {Object} EventConsts
|
|
46
|
-
* @property {string} SDK_READY The ready event.
|
|
47
|
-
* @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data.
|
|
48
|
-
* @property {string} SDK_READY_TIMED_OUT The timeout event.
|
|
49
|
-
* @property {string} SDK_UPDATE The update event.
|
|
50
|
-
*/
|
|
51
|
-
type EventConsts = {
|
|
52
|
-
SDK_READY: 'init::ready';
|
|
53
|
-
SDK_READY_FROM_CACHE: 'init::cache-ready';
|
|
54
|
-
SDK_READY_TIMED_OUT: 'init::timeout';
|
|
55
|
-
SDK_UPDATE: 'state::update';
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* SDK Modes.
|
|
59
|
-
* @typedef {string} SDKMode
|
|
60
|
-
*/
|
|
61
|
-
type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial';
|
|
62
|
-
/**
|
|
63
|
-
* Storage types.
|
|
64
|
-
* @typedef {string} StorageType
|
|
65
|
-
*/
|
|
66
|
-
type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
|
|
67
|
-
/**
|
|
68
|
-
* Settings interface. This is a representation of the settings the SDK expose, that's why
|
|
69
|
-
* most of it's props are readonly. Only features should be rewritten when localhost mode is active.
|
|
70
|
-
* @interface ISettings
|
|
71
|
-
*/
|
|
72
|
-
interface ISettings {
|
|
73
|
-
readonly core: {
|
|
74
|
-
authorizationKey: string;
|
|
75
|
-
key: SplitIO.SplitKey;
|
|
76
|
-
labelsEnabled: boolean;
|
|
77
|
-
IPAddressesEnabled: boolean;
|
|
78
|
-
};
|
|
79
|
-
readonly mode: SDKMode;
|
|
80
|
-
readonly scheduler: {
|
|
81
|
-
featuresRefreshRate: number;
|
|
82
|
-
impressionsRefreshRate: number;
|
|
83
|
-
impressionsQueueSize: number;
|
|
13
|
+
interface ISharedSettings {
|
|
14
|
+
/**
|
|
15
|
+
* The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
|
|
16
|
+
* which will check for the logImpression method.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue `undefined`
|
|
19
|
+
*/
|
|
20
|
+
impressionListener?: SplitIO.IImpressionListener;
|
|
21
|
+
/**
|
|
22
|
+
* SDK synchronization settings.
|
|
23
|
+
*/
|
|
24
|
+
sync?: {
|
|
84
25
|
/**
|
|
85
|
-
*
|
|
26
|
+
* List of feature flag filters. These filters are used to fetch a subset of the feature flag definitions in your environment, in order to reduce the delay of the SDK to be ready.
|
|
27
|
+
* This configuration is only meaningful when the SDK is working in "standalone" mode.
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
* ```
|
|
31
|
+
* splitFilter: [
|
|
32
|
+
* { type: 'byName', values: ['my_feature_flag_1', 'my_feature_flag_2'] }, // will fetch feature flags named 'my_feature_flag_1' and 'my_feature_flag_2'
|
|
33
|
+
* ]
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
splitFilters?: SplitIO.SplitFilter[];
|
|
37
|
+
/**
|
|
38
|
+
* Impressions Collection Mode. Option to determine how impressions are going to be sent to Split servers.
|
|
39
|
+
* Possible values are 'DEBUG', 'OPTIMIZED', and 'NONE'.
|
|
40
|
+
* - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
|
|
41
|
+
* - OPTIMIZED: will send unique impressions to Split servers, avoiding a considerable amount of traffic that duplicated impressions could generate.
|
|
42
|
+
* - NONE: will send unique keys evaluated per feature to Split servers instead of full blown impressions, avoiding a considerable amount of traffic that impressions could generate.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue `'OPTIMIZED'`
|
|
45
|
+
*/
|
|
46
|
+
impressionsMode?: SplitIO.ImpressionsMode;
|
|
47
|
+
/**
|
|
48
|
+
* Custom options object for HTTP(S) requests.
|
|
49
|
+
* If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
|
|
50
|
+
* This configuration has no effect in "consumer" mode, as no HTTP(S) requests are made by the SDK.
|
|
86
51
|
*/
|
|
87
|
-
metricsRefreshRate?: number;
|
|
88
|
-
telemetryRefreshRate: number;
|
|
89
|
-
segmentsRefreshRate: number;
|
|
90
|
-
offlineRefreshRate: number;
|
|
91
|
-
eventsPushRate: number;
|
|
92
|
-
eventsQueueSize: number;
|
|
93
|
-
pushRetryBackoffBase: number;
|
|
94
|
-
};
|
|
95
|
-
readonly startup: {
|
|
96
|
-
readyTimeout: number;
|
|
97
|
-
requestTimeoutBeforeReady: number;
|
|
98
|
-
retriesOnFailureBeforeReady: number;
|
|
99
|
-
eventsFirstPushWindow: number;
|
|
100
|
-
};
|
|
101
|
-
readonly storage: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory | SplitIO.StorageOptions;
|
|
102
|
-
readonly urls: {
|
|
103
|
-
events: string;
|
|
104
|
-
sdk: string;
|
|
105
|
-
auth: string;
|
|
106
|
-
streaming: string;
|
|
107
|
-
telemetry: string;
|
|
108
|
-
};
|
|
109
|
-
readonly integrations?: SplitIO.IntegrationFactory[];
|
|
110
|
-
readonly debug: boolean | LogLevel | SplitIO.ILogger;
|
|
111
|
-
readonly version: string;
|
|
112
|
-
/**
|
|
113
|
-
* Mocked features map if using in client-side, or mocked features file path string if using in server-side (NodeJS).
|
|
114
|
-
*/
|
|
115
|
-
features: SplitIO.MockedFeaturesMap | SplitIO.MockedFeaturesFilePath;
|
|
116
|
-
readonly streamingEnabled: boolean;
|
|
117
|
-
readonly sync: {
|
|
118
|
-
splitFilters: SplitIO.SplitFilter[];
|
|
119
|
-
impressionsMode: SplitIO.ImpressionsMode;
|
|
120
|
-
enabled: boolean;
|
|
121
|
-
flagSpecVersion: string;
|
|
122
52
|
requestOptions?: {
|
|
53
|
+
/**
|
|
54
|
+
* Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
|
|
55
|
+
* Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
|
|
56
|
+
* To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
|
|
57
|
+
* Or provide keys with different cases since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
|
|
58
|
+
*
|
|
59
|
+
* NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers,
|
|
60
|
+
* like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and they will be ignored.
|
|
61
|
+
*
|
|
62
|
+
* @defaultValue `undefined`
|
|
63
|
+
*
|
|
64
|
+
* @param context - The context for the request, which contains the `headers` property object representing the current headers in the request.
|
|
65
|
+
* @returns An object representing a set of headers to be merged with the current headers.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```
|
|
69
|
+
* const getHeaderOverrides = (context) => {
|
|
70
|
+
* return {
|
|
71
|
+
* 'Authorization': context.headers['Authorization'] + ', other-value',
|
|
72
|
+
* 'custom-header': 'custom-value'
|
|
73
|
+
* };
|
|
74
|
+
* };
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
123
77
|
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>;
|
|
124
78
|
};
|
|
125
79
|
};
|
|
126
80
|
/**
|
|
127
|
-
*
|
|
81
|
+
* List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone and partial consumer modes.
|
|
82
|
+
* Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
|
|
128
83
|
*/
|
|
129
|
-
|
|
84
|
+
urls?: SplitIO.UrlSettings;
|
|
130
85
|
}
|
|
131
86
|
/**
|
|
132
|
-
*
|
|
133
|
-
* @typedef {string} LogLevel
|
|
87
|
+
* Common settings properties for SDKs with synchronous API (standalone and localhost modes).
|
|
134
88
|
*/
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Logger API
|
|
138
|
-
* @interface ILoggerAPI
|
|
139
|
-
*/
|
|
140
|
-
interface ILoggerAPI {
|
|
141
|
-
/**
|
|
142
|
-
* Enables SDK logging to the console.
|
|
143
|
-
* @function enable
|
|
144
|
-
* @returns {void}
|
|
145
|
-
*/
|
|
146
|
-
enable(): void;
|
|
89
|
+
interface ISyncSharedSettings extends ISharedSettings {
|
|
147
90
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
91
|
+
* The SDK mode. When using the default in-memory storage or `InLocalStorage` as storage, the only possible value is "standalone", which is the default.
|
|
92
|
+
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
93
|
+
*
|
|
94
|
+
* @defaultValue `'standalone'`
|
|
151
95
|
*/
|
|
152
|
-
|
|
96
|
+
mode?: 'standalone';
|
|
153
97
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
98
|
+
* Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
|
|
99
|
+
* the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue `true`
|
|
157
102
|
*/
|
|
158
|
-
|
|
103
|
+
streamingEnabled?: boolean;
|
|
159
104
|
/**
|
|
160
|
-
*
|
|
105
|
+
* SDK synchronization settings.
|
|
161
106
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
107
|
+
sync?: ISharedSettings['sync'] & {
|
|
108
|
+
/**
|
|
109
|
+
* Controls the SDK continuous synchronization flags.
|
|
110
|
+
*
|
|
111
|
+
* When `true` a running SDK will process rollout plan updates performed on the UI (default).
|
|
112
|
+
* When false it'll just fetch all data upon init.
|
|
113
|
+
*
|
|
114
|
+
* @defaultValue `true`
|
|
115
|
+
*/
|
|
116
|
+
enabled?: boolean;
|
|
164
117
|
};
|
|
165
118
|
}
|
|
166
119
|
/**
|
|
167
|
-
*
|
|
168
|
-
* @interface IUserConsentAPI
|
|
120
|
+
* Common settings properties for SDKs with pluggable configuration.
|
|
169
121
|
*/
|
|
170
|
-
interface
|
|
122
|
+
interface IPluggableSettings {
|
|
171
123
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
124
|
+
* Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object.
|
|
125
|
+
* Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes.
|
|
126
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}.
|
|
175
127
|
*
|
|
176
|
-
*
|
|
128
|
+
* Examples:
|
|
129
|
+
* ```
|
|
130
|
+
* config.debug = true
|
|
131
|
+
* config.debug = 'WARN'
|
|
132
|
+
* config.debug = ErrorLogger()
|
|
133
|
+
* ```
|
|
177
134
|
*
|
|
178
|
-
* @
|
|
179
|
-
* @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
|
|
180
|
-
* @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
|
|
135
|
+
* @defaultValue `false`
|
|
181
136
|
*/
|
|
182
|
-
|
|
137
|
+
debug?: boolean | SplitIO.LogLevel | SplitIO.ILogger;
|
|
183
138
|
/**
|
|
184
|
-
*
|
|
139
|
+
* Defines an optional list of factory functions used to instantiate SDK integrations.
|
|
185
140
|
*
|
|
186
|
-
*
|
|
187
|
-
* @returns {ConsentStatus} The user consent status.
|
|
188
|
-
*/
|
|
189
|
-
getStatus(): SplitIO.ConsentStatus;
|
|
190
|
-
/**
|
|
191
|
-
* Consent status constants. Use this to compare with the getStatus function result.
|
|
141
|
+
* NOTE: at the moment there are not integrations to plug in.
|
|
192
142
|
*/
|
|
193
|
-
|
|
194
|
-
[status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus;
|
|
195
|
-
};
|
|
143
|
+
integrations?: SplitIO.IntegrationFactory[];
|
|
196
144
|
}
|
|
197
145
|
/**
|
|
198
|
-
* Common
|
|
199
|
-
* @interface IStatusInterface
|
|
200
|
-
* @extends EventEmitter
|
|
146
|
+
* Common settings properties for SDKs without pluggable configuration.
|
|
201
147
|
*/
|
|
202
|
-
interface
|
|
203
|
-
/**
|
|
204
|
-
* Constant object containing the SDK events for you to use.
|
|
205
|
-
* @property {EventConsts} Event
|
|
206
|
-
*/
|
|
207
|
-
Event: EventConsts;
|
|
148
|
+
interface INonPluggableSettings {
|
|
208
149
|
/**
|
|
209
|
-
*
|
|
210
|
-
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `ready` method will return a resolved promise once the SDK is ready.
|
|
150
|
+
* Boolean value to indicate whether the logger should be enabled or disabled, or a log level string.
|
|
211
151
|
*
|
|
212
|
-
*
|
|
213
|
-
* However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
|
|
152
|
+
* Examples:
|
|
214
153
|
* ```
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* // SDK is ready
|
|
218
|
-
* } catch(e) {
|
|
219
|
-
* // SDK has timedout
|
|
220
|
-
* }
|
|
154
|
+
* config.debug = true
|
|
155
|
+
* config.debug = 'WARN'
|
|
221
156
|
* ```
|
|
222
157
|
*
|
|
223
|
-
* @
|
|
224
|
-
* @returns {Promise<void>}
|
|
158
|
+
* @defaultValue `false`
|
|
225
159
|
*/
|
|
226
|
-
|
|
160
|
+
debug?: boolean | SplitIO.LogLevel;
|
|
227
161
|
}
|
|
228
162
|
/**
|
|
229
|
-
* Common
|
|
230
|
-
* @interface IBasicClient
|
|
231
|
-
* @extends IStatusInterface
|
|
163
|
+
* Common settings properties for server-side SDKs.
|
|
232
164
|
*/
|
|
233
|
-
interface
|
|
165
|
+
interface IServerSideSharedSettings {
|
|
234
166
|
/**
|
|
235
|
-
*
|
|
167
|
+
* SDK Core settings for NodeJS.
|
|
168
|
+
*/
|
|
169
|
+
core: {
|
|
170
|
+
/**
|
|
171
|
+
* Your SDK key.
|
|
172
|
+
*
|
|
173
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
174
|
+
*/
|
|
175
|
+
authorizationKey: string;
|
|
176
|
+
/**
|
|
177
|
+
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
178
|
+
*
|
|
179
|
+
* @defaultValue `true`
|
|
180
|
+
*/
|
|
181
|
+
labelsEnabled?: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Disable machine IP and Name from being sent to Split backend.
|
|
184
|
+
*
|
|
185
|
+
* @defaultValue `true`
|
|
186
|
+
*/
|
|
187
|
+
IPAddressesEnabled?: boolean;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* SDK Startup settings for NodeJS.
|
|
191
|
+
*/
|
|
192
|
+
startup?: {
|
|
193
|
+
/**
|
|
194
|
+
* Maximum amount of time used before notify a timeout.
|
|
195
|
+
*
|
|
196
|
+
* @defaultValue `15`
|
|
197
|
+
*/
|
|
198
|
+
readyTimeout?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Time to wait for a request before the SDK is ready. If this time expires, JS SDK will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
|
|
201
|
+
*
|
|
202
|
+
* @defaultValue `15`
|
|
203
|
+
*/
|
|
204
|
+
requestTimeoutBeforeReady?: number;
|
|
205
|
+
/**
|
|
206
|
+
* How many quick retries we will do while starting up the SDK.
|
|
207
|
+
*
|
|
208
|
+
* @defaultValue `1`
|
|
209
|
+
*/
|
|
210
|
+
retriesOnFailureBeforeReady?: number;
|
|
211
|
+
/**
|
|
212
|
+
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
213
|
+
* to better control on browsers. This number defines that window before the first events push.
|
|
214
|
+
*
|
|
215
|
+
* @defaultValue `0`
|
|
216
|
+
*/
|
|
217
|
+
eventsFirstPushWindow?: number;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* SDK scheduler settings.
|
|
221
|
+
*/
|
|
222
|
+
scheduler?: {
|
|
223
|
+
/**
|
|
224
|
+
* The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
|
|
225
|
+
*
|
|
226
|
+
* @defaultValue `60`
|
|
227
|
+
*/
|
|
228
|
+
featuresRefreshRate?: number;
|
|
229
|
+
/**
|
|
230
|
+
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
231
|
+
*
|
|
232
|
+
* @defaultValue `300`
|
|
233
|
+
*/
|
|
234
|
+
impressionsRefreshRate?: number;
|
|
235
|
+
/**
|
|
236
|
+
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
237
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
238
|
+
*
|
|
239
|
+
* @defaultValue `30000`
|
|
240
|
+
*/
|
|
241
|
+
impressionsQueueSize?: number;
|
|
242
|
+
/**
|
|
243
|
+
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
244
|
+
*
|
|
245
|
+
* @defaultValue `120`
|
|
246
|
+
* @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
|
|
247
|
+
*/
|
|
248
|
+
metricsRefreshRate?: number;
|
|
249
|
+
/**
|
|
250
|
+
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
251
|
+
*
|
|
252
|
+
* @defaultValue `3600`
|
|
253
|
+
*/
|
|
254
|
+
telemetryRefreshRate?: number;
|
|
255
|
+
/**
|
|
256
|
+
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
257
|
+
*
|
|
258
|
+
* @defaultValue `60`
|
|
259
|
+
*/
|
|
260
|
+
segmentsRefreshRate?: number;
|
|
261
|
+
/**
|
|
262
|
+
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
263
|
+
*
|
|
264
|
+
* @defaultValue `60`
|
|
265
|
+
*/
|
|
266
|
+
eventsPushRate?: number;
|
|
267
|
+
/**
|
|
268
|
+
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
269
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
270
|
+
*
|
|
271
|
+
* @defaultValue `500`
|
|
272
|
+
*/
|
|
273
|
+
eventsQueueSize?: number;
|
|
274
|
+
/**
|
|
275
|
+
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
276
|
+
* For more information see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
|
|
277
|
+
*
|
|
278
|
+
* @defaultValue `15`
|
|
279
|
+
*/
|
|
280
|
+
offlineRefreshRate?: number;
|
|
281
|
+
/**
|
|
282
|
+
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
283
|
+
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
284
|
+
*
|
|
285
|
+
* @defaultValue `1`
|
|
286
|
+
*/
|
|
287
|
+
pushRetryBackoffBase?: number;
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Mocked features file path. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
291
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
|
|
236
292
|
*
|
|
237
|
-
*
|
|
238
|
-
|
|
239
|
-
|
|
293
|
+
* @defaultValue `'$HOME/.split'`
|
|
294
|
+
*/
|
|
295
|
+
features?: SplitIO.MockedFeaturesFilePath;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Common settings properties for client-side SDKs.
|
|
299
|
+
*/
|
|
300
|
+
interface IClientSideSharedSettings {
|
|
301
|
+
/**
|
|
302
|
+
* SDK Core settings for client-side.
|
|
303
|
+
*/
|
|
304
|
+
core: {
|
|
305
|
+
/**
|
|
306
|
+
* Your SDK key.
|
|
307
|
+
*
|
|
308
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
309
|
+
*/
|
|
310
|
+
authorizationKey: string;
|
|
311
|
+
/**
|
|
312
|
+
* Customer identifier. Whatever this means to you.
|
|
313
|
+
*
|
|
314
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
315
|
+
*/
|
|
316
|
+
key: SplitIO.SplitKey;
|
|
317
|
+
/**
|
|
318
|
+
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
319
|
+
*
|
|
320
|
+
* @defaultValue `true`
|
|
321
|
+
*/
|
|
322
|
+
labelsEnabled?: boolean;
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
|
|
326
|
+
* - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
|
|
327
|
+
* - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
|
|
328
|
+
* - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends
|
|
329
|
+
* them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method.
|
|
240
330
|
*
|
|
241
|
-
* @
|
|
242
|
-
* @returns {Promise<void>} A promise that resolves once the client is destroyed.
|
|
331
|
+
* @defaultValue `'GRANTED'`
|
|
243
332
|
*/
|
|
244
|
-
|
|
333
|
+
userConsent?: SplitIO.ConsentStatus;
|
|
245
334
|
}
|
|
246
335
|
/**
|
|
247
|
-
* Common
|
|
248
|
-
* @interface IBasicSDK
|
|
336
|
+
* Common settings properties for client-side standalone SDKs.
|
|
249
337
|
*/
|
|
250
|
-
interface
|
|
338
|
+
interface IClientSideSyncSharedSettings extends IClientSideSharedSettings, ISyncSharedSettings {
|
|
251
339
|
/**
|
|
252
|
-
*
|
|
253
|
-
* @
|
|
340
|
+
* Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
341
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
|
|
254
342
|
*/
|
|
255
|
-
|
|
343
|
+
features?: SplitIO.MockedFeaturesMap;
|
|
256
344
|
/**
|
|
257
|
-
*
|
|
258
|
-
* @property Logger
|
|
345
|
+
* SDK Startup settings.
|
|
259
346
|
*/
|
|
260
|
-
|
|
347
|
+
startup?: {
|
|
348
|
+
/**
|
|
349
|
+
* Maximum amount of time used before notify a timeout.
|
|
350
|
+
*
|
|
351
|
+
* @defaultValue `10`
|
|
352
|
+
*/
|
|
353
|
+
readyTimeout?: number;
|
|
354
|
+
/**
|
|
355
|
+
* Time to wait for a request before the SDK is ready. If this time expires, JS SDK will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
|
|
356
|
+
*
|
|
357
|
+
* @defaultValue `5`
|
|
358
|
+
*/
|
|
359
|
+
requestTimeoutBeforeReady?: number;
|
|
360
|
+
/**
|
|
361
|
+
* How many quick retries we will do while starting up the SDK.
|
|
362
|
+
*
|
|
363
|
+
* @defaultValue `1`
|
|
364
|
+
*/
|
|
365
|
+
retriesOnFailureBeforeReady?: number;
|
|
366
|
+
/**
|
|
367
|
+
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
368
|
+
* to better control on browsers or mobile. This number defines that window before the first events push.
|
|
369
|
+
*
|
|
370
|
+
* @defaultValue `10`
|
|
371
|
+
*/
|
|
372
|
+
eventsFirstPushWindow?: number;
|
|
373
|
+
};
|
|
261
374
|
/**
|
|
262
|
-
*
|
|
263
|
-
* @function destroy
|
|
264
|
-
* @returns {Promise<void>}
|
|
375
|
+
* SDK scheduler settings.
|
|
265
376
|
*/
|
|
266
|
-
|
|
377
|
+
scheduler?: {
|
|
378
|
+
/**
|
|
379
|
+
* The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
|
|
380
|
+
*
|
|
381
|
+
* @defaultValue `60`
|
|
382
|
+
*/
|
|
383
|
+
featuresRefreshRate?: number;
|
|
384
|
+
/**
|
|
385
|
+
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
386
|
+
*
|
|
387
|
+
* @defaultValue `60`
|
|
388
|
+
*/
|
|
389
|
+
impressionsRefreshRate?: number;
|
|
390
|
+
/**
|
|
391
|
+
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
392
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
393
|
+
*
|
|
394
|
+
* @defaultValue `30000`
|
|
395
|
+
*/
|
|
396
|
+
impressionsQueueSize?: number;
|
|
397
|
+
/**
|
|
398
|
+
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
399
|
+
*
|
|
400
|
+
* @defaultValue `120`
|
|
401
|
+
* @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
|
|
402
|
+
*/
|
|
403
|
+
metricsRefreshRate?: number;
|
|
404
|
+
/**
|
|
405
|
+
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
406
|
+
*
|
|
407
|
+
* @defaultValue `3600`
|
|
408
|
+
*/
|
|
409
|
+
telemetryRefreshRate?: number;
|
|
410
|
+
/**
|
|
411
|
+
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
412
|
+
*
|
|
413
|
+
* @defaultValue `60`
|
|
414
|
+
*/
|
|
415
|
+
segmentsRefreshRate?: number;
|
|
416
|
+
/**
|
|
417
|
+
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
418
|
+
*
|
|
419
|
+
* @defaultValue `60`
|
|
420
|
+
*/
|
|
421
|
+
eventsPushRate?: number;
|
|
422
|
+
/**
|
|
423
|
+
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
424
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
425
|
+
*
|
|
426
|
+
* @defaultValue `500`
|
|
427
|
+
*/
|
|
428
|
+
eventsQueueSize?: number;
|
|
429
|
+
/**
|
|
430
|
+
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
431
|
+
* For more information see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
|
|
432
|
+
*
|
|
433
|
+
* @defaultValue `15`
|
|
434
|
+
*/
|
|
435
|
+
offlineRefreshRate?: number;
|
|
436
|
+
/**
|
|
437
|
+
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
438
|
+
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
439
|
+
*
|
|
440
|
+
* @defaultValue `1`
|
|
441
|
+
*/
|
|
442
|
+
pushRetryBackoffBase?: number;
|
|
443
|
+
};
|
|
267
444
|
}
|
|
445
|
+
|
|
268
446
|
/****** Exposed namespace ******/
|
|
269
447
|
/**
|
|
270
|
-
* Shared types and interfaces for `@splitsoftware` packages
|
|
448
|
+
* Shared types and interfaces for `@splitsoftware` packages, to support integrating JavaScript SDKs with TypeScript.
|
|
271
449
|
*/
|
|
272
450
|
declare namespace SplitIO {
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* EventEmitter interface based on a subset of the NodeJS.EventEmitter methods.
|
|
454
|
+
*/
|
|
455
|
+
interface IEventEmitter {
|
|
456
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
457
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
458
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
459
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
|
460
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
461
|
+
removeAllListeners(event?: string): this;
|
|
462
|
+
emit(event: string, ...args: any[]): boolean;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* NodeJS.EventEmitter interface
|
|
466
|
+
* @see {@link https://nodejs.org/api/events.html}
|
|
467
|
+
*/
|
|
468
|
+
interface EventEmitter extends IEventEmitter {
|
|
469
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
470
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
471
|
+
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
472
|
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
473
|
+
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
474
|
+
removeAllListeners(event?: string | symbol): this;
|
|
475
|
+
emit(event: string | symbol, ...args: any[]): boolean;
|
|
476
|
+
setMaxListeners(n: number): this;
|
|
477
|
+
getMaxListeners(): number;
|
|
478
|
+
listeners(event: string | symbol): Function[];
|
|
479
|
+
rawListeners(event: string | symbol): Function[];
|
|
480
|
+
listenerCount(type: string | symbol): number;
|
|
481
|
+
// Added in Node 6...
|
|
482
|
+
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
483
|
+
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
484
|
+
eventNames(): Array<string | symbol>;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Event constants.
|
|
488
|
+
*/
|
|
489
|
+
type EventConsts = {
|
|
490
|
+
/**
|
|
491
|
+
* The ready event.
|
|
492
|
+
*/
|
|
493
|
+
SDK_READY: 'init::ready';
|
|
494
|
+
/**
|
|
495
|
+
* The ready event when fired with cached data.
|
|
496
|
+
*/
|
|
497
|
+
SDK_READY_FROM_CACHE: 'init::cache-ready';
|
|
498
|
+
/**
|
|
499
|
+
* The timeout event.
|
|
500
|
+
*/
|
|
501
|
+
SDK_READY_TIMED_OUT: 'init::timeout';
|
|
502
|
+
/**
|
|
503
|
+
* The update event.
|
|
504
|
+
*/
|
|
505
|
+
SDK_UPDATE: 'state::update';
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* SDK Modes.
|
|
509
|
+
*/
|
|
510
|
+
type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial';
|
|
511
|
+
/**
|
|
512
|
+
* Storage types.
|
|
513
|
+
*/
|
|
514
|
+
type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
|
|
515
|
+
/**
|
|
516
|
+
* Settings interface. This is a representation of the settings the SDK expose, that's why
|
|
517
|
+
* most of it's props are readonly. Only features should be rewritten when localhost mode is active.
|
|
518
|
+
*/
|
|
519
|
+
interface ISettings {
|
|
520
|
+
readonly core: {
|
|
521
|
+
authorizationKey: string;
|
|
522
|
+
key: SplitKey;
|
|
523
|
+
labelsEnabled: boolean;
|
|
524
|
+
IPAddressesEnabled: boolean;
|
|
525
|
+
};
|
|
526
|
+
readonly mode: SDKMode;
|
|
527
|
+
readonly scheduler: {
|
|
528
|
+
featuresRefreshRate: number;
|
|
529
|
+
impressionsRefreshRate: number;
|
|
530
|
+
impressionsQueueSize: number;
|
|
531
|
+
/**
|
|
532
|
+
* @deprecated Use `telemetryRefreshRate` instead.
|
|
533
|
+
*/
|
|
534
|
+
metricsRefreshRate?: number;
|
|
535
|
+
telemetryRefreshRate: number;
|
|
536
|
+
segmentsRefreshRate: number;
|
|
537
|
+
offlineRefreshRate: number;
|
|
538
|
+
eventsPushRate: number;
|
|
539
|
+
eventsQueueSize: number;
|
|
540
|
+
pushRetryBackoffBase: number;
|
|
541
|
+
};
|
|
542
|
+
readonly startup: {
|
|
543
|
+
readyTimeout: number;
|
|
544
|
+
requestTimeoutBeforeReady: number;
|
|
545
|
+
retriesOnFailureBeforeReady: number;
|
|
546
|
+
eventsFirstPushWindow: number;
|
|
547
|
+
};
|
|
548
|
+
readonly storage: StorageSyncFactory | StorageAsyncFactory | StorageOptions;
|
|
549
|
+
readonly urls: {
|
|
550
|
+
events: string;
|
|
551
|
+
sdk: string;
|
|
552
|
+
auth: string;
|
|
553
|
+
streaming: string;
|
|
554
|
+
telemetry: string;
|
|
555
|
+
};
|
|
556
|
+
readonly integrations?: IntegrationFactory[];
|
|
557
|
+
readonly debug: boolean | LogLevel | ILogger;
|
|
558
|
+
readonly version: string;
|
|
559
|
+
/**
|
|
560
|
+
* Mocked features map if using in client-side, or mocked features file path string if using in server-side (NodeJS).
|
|
561
|
+
*/
|
|
562
|
+
features: MockedFeaturesMap | MockedFeaturesFilePath;
|
|
563
|
+
readonly streamingEnabled: boolean;
|
|
564
|
+
readonly sync: {
|
|
565
|
+
splitFilters: SplitFilter[];
|
|
566
|
+
impressionsMode: ImpressionsMode;
|
|
567
|
+
enabled: boolean;
|
|
568
|
+
flagSpecVersion: string;
|
|
569
|
+
requestOptions?: {
|
|
570
|
+
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>;
|
|
571
|
+
};
|
|
572
|
+
};
|
|
573
|
+
readonly runtime: {
|
|
574
|
+
ip: string | false;
|
|
575
|
+
hostname: string | false;
|
|
576
|
+
};
|
|
577
|
+
readonly impressionListener?: IImpressionListener;
|
|
578
|
+
/**
|
|
579
|
+
* User consent status if using in client-side. Undefined if using in server-side (NodeJS).
|
|
580
|
+
*/
|
|
581
|
+
readonly userConsent?: ConsentStatus;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Log levels.
|
|
585
|
+
*/
|
|
586
|
+
type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
|
|
587
|
+
/**
|
|
588
|
+
* Logger API
|
|
589
|
+
*/
|
|
590
|
+
interface ILoggerAPI {
|
|
591
|
+
/**
|
|
592
|
+
* Enables SDK logging to the console.
|
|
593
|
+
*/
|
|
594
|
+
enable(): void;
|
|
595
|
+
/**
|
|
596
|
+
* Disables SDK logging.
|
|
597
|
+
*/
|
|
598
|
+
disable(): void;
|
|
599
|
+
/**
|
|
600
|
+
* Sets a log level for the SDK logs.
|
|
601
|
+
*/
|
|
602
|
+
setLogLevel(logLevel: LogLevel): void;
|
|
603
|
+
/**
|
|
604
|
+
* Log level constants. Use this to pass them to setLogLevel function.
|
|
605
|
+
*/
|
|
606
|
+
LogLevel: {
|
|
607
|
+
[level in LogLevel]: LogLevel;
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* User consent API
|
|
612
|
+
*/
|
|
613
|
+
interface IUserConsentAPI {
|
|
614
|
+
/**
|
|
615
|
+
* Sets or updates the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
|
|
616
|
+
* - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
|
|
617
|
+
* - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
|
|
618
|
+
*
|
|
619
|
+
* NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
|
|
620
|
+
*
|
|
621
|
+
* @param userConsent - The user consent status, true for 'GRANTED' and false for 'DECLINED'.
|
|
622
|
+
* @returns Whether the provided param is a valid value (i.e., a boolean value) or not.
|
|
623
|
+
*/
|
|
624
|
+
setStatus(userConsent: boolean): boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Gets the user consent status.
|
|
627
|
+
*
|
|
628
|
+
* @returns The user consent status.
|
|
629
|
+
*/
|
|
630
|
+
getStatus(): ConsentStatus;
|
|
631
|
+
/**
|
|
632
|
+
* Consent status constants. Use this to compare with the getStatus function result.
|
|
633
|
+
*/
|
|
634
|
+
Status: {
|
|
635
|
+
[status in ConsentStatus]: ConsentStatus;
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Common API for entities that expose status handlers.
|
|
640
|
+
*/
|
|
641
|
+
interface IStatusInterface extends EventEmitter {
|
|
642
|
+
/**
|
|
643
|
+
* Constant object containing the SDK events for you to use.
|
|
644
|
+
*/
|
|
645
|
+
Event: EventConsts;
|
|
646
|
+
/**
|
|
647
|
+
* Returns a promise that resolves once the SDK has finished loading (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
|
|
648
|
+
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `ready` method will return a resolved promise once the SDK is ready.
|
|
649
|
+
*
|
|
650
|
+
* Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises.
|
|
651
|
+
* However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
|
|
652
|
+
* ```
|
|
653
|
+
* try {
|
|
654
|
+
* await client.ready().catch((e) => { throw e; });
|
|
655
|
+
* // SDK is ready
|
|
656
|
+
* } catch(e) {
|
|
657
|
+
* // SDK has timedout
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @returns A promise that resolves once the SDK is ready or rejects if the SDK has timedout.
|
|
662
|
+
*/
|
|
663
|
+
ready(): Promise<void>;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Common definitions between clients for different environments interface.
|
|
667
|
+
*/
|
|
668
|
+
interface IBasicClient extends IStatusInterface {
|
|
669
|
+
/**
|
|
670
|
+
* Destroys the client instance.
|
|
671
|
+
*
|
|
672
|
+
* In 'standalone' and 'partial consumer' modes, this method will flush any pending impressions and events.
|
|
673
|
+
* In 'standalone' mode, it also stops the synchronization of feature flag definitions with the backend.
|
|
674
|
+
* In 'consumer' and 'partial consumer' modes, this method also disconnects the SDK from the Pluggable storage.
|
|
675
|
+
*
|
|
676
|
+
* @returns A promise that resolves once the client is destroyed.
|
|
677
|
+
*/
|
|
678
|
+
destroy(): Promise<void>;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Common definitions between SDK instances for different environments interface.
|
|
682
|
+
*/
|
|
683
|
+
interface IBasicSDK {
|
|
684
|
+
/**
|
|
685
|
+
* Current settings of the SDK instance.
|
|
686
|
+
*/
|
|
687
|
+
settings: ISettings;
|
|
688
|
+
/**
|
|
689
|
+
* Logger API.
|
|
690
|
+
*/
|
|
691
|
+
Logger: ILoggerAPI;
|
|
692
|
+
/**
|
|
693
|
+
* Destroys all the clients created by this factory.
|
|
694
|
+
*
|
|
695
|
+
* @returns A promise that resolves once all clients are destroyed.
|
|
696
|
+
*/
|
|
697
|
+
destroy(): Promise<void>;
|
|
698
|
+
}
|
|
273
699
|
/**
|
|
274
700
|
* Feature flag treatment value, returned by getTreatment.
|
|
275
|
-
* @typedef {string} Treatment
|
|
276
701
|
*/
|
|
277
702
|
type Treatment = string;
|
|
278
703
|
/**
|
|
279
704
|
* Feature flag treatment promise that resolves to actual treatment value.
|
|
280
|
-
* @typedef {Promise<string>} AsyncTreatment
|
|
281
705
|
*/
|
|
282
|
-
type AsyncTreatment = Promise<
|
|
706
|
+
type AsyncTreatment = Promise<Treatment>;
|
|
283
707
|
/**
|
|
284
708
|
* An object with the treatments for a bulk of feature flags, returned by getTreatments. For example:
|
|
709
|
+
* ```
|
|
285
710
|
* {
|
|
286
711
|
* feature1: 'on',
|
|
287
|
-
* feature2: 'off
|
|
712
|
+
* feature2: 'off'
|
|
288
713
|
* }
|
|
289
|
-
*
|
|
714
|
+
* ```
|
|
290
715
|
*/
|
|
291
716
|
type Treatments = {
|
|
292
717
|
[featureName: string]: Treatment;
|
|
293
718
|
};
|
|
294
719
|
/**
|
|
295
720
|
* Feature flag treatments promise that resolves to the actual SplitIO.Treatments object.
|
|
296
|
-
* @typedef {Promise<Treatments>} AsyncTreatments
|
|
297
721
|
*/
|
|
298
722
|
type AsyncTreatments = Promise<Treatments>;
|
|
299
723
|
/**
|
|
300
724
|
* Feature flag evaluation result with treatment and configuration, returned by getTreatmentWithConfig.
|
|
301
|
-
* @typedef {Object} TreatmentWithConfig
|
|
302
|
-
* @property {string} treatment The treatment string
|
|
303
|
-
* @property {string | null} config The stringified version of the JSON config defined for that treatment, null if there is no config for the resulting treatment.
|
|
304
725
|
*/
|
|
305
726
|
type TreatmentWithConfig = {
|
|
727
|
+
/**
|
|
728
|
+
* The treatment string.
|
|
729
|
+
*/
|
|
306
730
|
treatment: string;
|
|
731
|
+
/**
|
|
732
|
+
* The stringified version of the JSON config defined for that treatment, null if there is no config for the resulting treatment.
|
|
733
|
+
*/
|
|
307
734
|
config: string | null;
|
|
308
735
|
};
|
|
309
736
|
/**
|
|
310
|
-
* Feature flag treatment promise that resolves to actual
|
|
311
|
-
* @typedef {Promise<TreatmentWithConfig>} AsyncTreatmentWithConfig
|
|
737
|
+
* Feature flag treatment promise that resolves to actual SplitIO.TreatmentWithConfig object.
|
|
312
738
|
*/
|
|
313
739
|
type AsyncTreatmentWithConfig = Promise<TreatmentWithConfig>;
|
|
314
740
|
/**
|
|
315
741
|
* An object with the treatments with configs for a bulk of feature flags, returned by getTreatmentsWithConfig.
|
|
316
742
|
* Each existing configuration is a stringified version of the JSON you defined on the Split user interface. For example:
|
|
743
|
+
* ```
|
|
317
744
|
* {
|
|
318
745
|
* feature1: { treatment: 'on', config: null }
|
|
319
746
|
* feature2: { treatment: 'off', config: '{"bannerText":"Click here."}' }
|
|
320
747
|
* }
|
|
321
|
-
*
|
|
748
|
+
* ```
|
|
322
749
|
*/
|
|
323
750
|
type TreatmentsWithConfig = {
|
|
324
751
|
[featureName: string]: TreatmentWithConfig;
|
|
325
752
|
};
|
|
326
753
|
/**
|
|
327
754
|
* Feature flag treatments promise that resolves to the actual SplitIO.TreatmentsWithConfig object.
|
|
328
|
-
* @typedef {Promise<TreatmentsWithConfig>} AsyncTreatmentsWithConfig
|
|
329
755
|
*/
|
|
330
756
|
type AsyncTreatmentsWithConfig = Promise<TreatmentsWithConfig>;
|
|
331
757
|
/**
|
|
332
758
|
* Possible Split SDK events.
|
|
333
|
-
* @typedef {string} Event
|
|
334
759
|
*/
|
|
335
760
|
type Event = 'init::timeout' | 'init::ready' | 'init::cache-ready' | 'state::update';
|
|
336
761
|
/**
|
|
337
762
|
* Attributes should be on object with values of type string, boolean, number (dates should be sent as millis since epoch) or array of strings or numbers.
|
|
338
|
-
*
|
|
763
|
+
*
|
|
339
764
|
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax}
|
|
340
765
|
*/
|
|
341
766
|
type Attributes = {
|
|
@@ -343,20 +768,18 @@ declare namespace SplitIO {
|
|
|
343
768
|
};
|
|
344
769
|
/**
|
|
345
770
|
* Type of an attribute value
|
|
346
|
-
* @typedef {string | number | boolean | Array<string | number>} AttributeType
|
|
347
771
|
*/
|
|
348
772
|
type AttributeType = string | number | boolean | Array<string | number>;
|
|
349
773
|
/**
|
|
350
774
|
* Properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb.
|
|
351
|
-
*
|
|
352
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track
|
|
775
|
+
*
|
|
776
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track}
|
|
353
777
|
*/
|
|
354
778
|
type Properties = {
|
|
355
779
|
[propertyName: string]: string | number | boolean | null;
|
|
356
780
|
};
|
|
357
781
|
/**
|
|
358
782
|
* The SplitKey object format.
|
|
359
|
-
* @typedef {Object.<string>} SplitKeyObject
|
|
360
783
|
*/
|
|
361
784
|
type SplitKeyObject = {
|
|
362
785
|
matchingKey: string;
|
|
@@ -364,128 +787,114 @@ declare namespace SplitIO {
|
|
|
364
787
|
};
|
|
365
788
|
/**
|
|
366
789
|
* The customer identifier. Could be a SplitKeyObject or a string.
|
|
367
|
-
* @typedef {SplitKeyObject|string} SplitKey
|
|
368
790
|
*/
|
|
369
791
|
type SplitKey = SplitKeyObject | string;
|
|
370
792
|
/**
|
|
371
793
|
* Path to file with mocked features (for node).
|
|
372
|
-
* @typedef {string} MockedFeaturesFilePath
|
|
373
794
|
*/
|
|
374
795
|
type MockedFeaturesFilePath = string;
|
|
375
796
|
/**
|
|
376
797
|
* Object with mocked features mapping for client-side (e.g., Browser or React Native). We need to specify the featureName as key, and the mocked treatment as value.
|
|
377
|
-
* @typedef {Object} MockedFeaturesMap
|
|
378
798
|
*/
|
|
379
799
|
type MockedFeaturesMap = {
|
|
380
800
|
[featureName: string]: string | TreatmentWithConfig;
|
|
381
801
|
};
|
|
802
|
+
/**
|
|
803
|
+
* Impression DTO generated by the SDK when processing evaluations.
|
|
804
|
+
*/
|
|
805
|
+
type ImpressionDTO = {
|
|
806
|
+
feature: string;
|
|
807
|
+
keyName: string;
|
|
808
|
+
treatment: string;
|
|
809
|
+
time: number;
|
|
810
|
+
bucketingKey?: string;
|
|
811
|
+
label: string;
|
|
812
|
+
changeNumber: number;
|
|
813
|
+
pt?: number;
|
|
814
|
+
}
|
|
382
815
|
/**
|
|
383
816
|
* Object with information about an impression. It contains the generated impression DTO as well as
|
|
384
817
|
* complementary information around where and how it was generated in that way.
|
|
385
|
-
* @typedef {Object} ImpressionData
|
|
386
818
|
*/
|
|
387
819
|
type ImpressionData = {
|
|
388
|
-
impression:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
time: number;
|
|
393
|
-
bucketingKey?: string;
|
|
394
|
-
label: string;
|
|
395
|
-
changeNumber: number;
|
|
396
|
-
pt?: number;
|
|
397
|
-
};
|
|
398
|
-
attributes?: SplitIO.Attributes;
|
|
399
|
-
ip: string;
|
|
400
|
-
hostname: string;
|
|
820
|
+
impression: ImpressionDTO;
|
|
821
|
+
attributes?: Attributes;
|
|
822
|
+
ip: string | false;
|
|
823
|
+
hostname: string | false;
|
|
401
824
|
sdkLanguageVersion: string;
|
|
402
825
|
};
|
|
403
826
|
/**
|
|
404
827
|
* Data corresponding to one feature flag view.
|
|
405
|
-
* @typedef {Object} SplitView
|
|
406
828
|
*/
|
|
407
829
|
type SplitView = {
|
|
408
830
|
/**
|
|
409
831
|
* The name of the feature flag.
|
|
410
|
-
* @property {string} name
|
|
411
832
|
*/
|
|
412
833
|
name: string;
|
|
413
834
|
/**
|
|
414
835
|
* The traffic type of the feature flag.
|
|
415
|
-
* @property {string} trafficType
|
|
416
836
|
*/
|
|
417
837
|
trafficType: string;
|
|
418
838
|
/**
|
|
419
839
|
* Whether the feature flag is killed or not.
|
|
420
|
-
* @property {boolean} killed
|
|
421
840
|
*/
|
|
422
841
|
killed: boolean;
|
|
423
842
|
/**
|
|
424
843
|
* The list of treatments available for the feature flag.
|
|
425
|
-
* @property {Array<string>} treatments
|
|
426
844
|
*/
|
|
427
845
|
treatments: Array<string>;
|
|
428
846
|
/**
|
|
429
847
|
* Current change number of the feature flag.
|
|
430
|
-
* @property {number} changeNumber
|
|
431
848
|
*/
|
|
432
849
|
changeNumber: number;
|
|
433
850
|
/**
|
|
434
851
|
* Map of configurations per treatment.
|
|
435
852
|
* Each existing configuration is a stringified version of the JSON you defined on the Split user interface.
|
|
436
|
-
* @property {Object.<string>} configs
|
|
437
853
|
*/
|
|
438
854
|
configs: {
|
|
439
855
|
[treatmentName: string]: string;
|
|
440
856
|
};
|
|
441
857
|
/**
|
|
442
858
|
* List of sets of the feature flag.
|
|
443
|
-
* @property {string[]} sets
|
|
444
859
|
*/
|
|
445
860
|
sets: string[];
|
|
446
861
|
/**
|
|
447
862
|
* The default treatment of the feature flag.
|
|
448
|
-
* @property {string} defaultTreatment
|
|
449
863
|
*/
|
|
450
864
|
defaultTreatment: string;
|
|
451
865
|
};
|
|
452
866
|
/**
|
|
453
|
-
* A promise that resolves to a feature flag view.
|
|
454
|
-
* @typedef {Promise<SplitView>} SplitView
|
|
867
|
+
* A promise that resolves to a feature flag view or null if the feature flag is not found.
|
|
455
868
|
*/
|
|
456
|
-
type SplitViewAsync = Promise<SplitView>;
|
|
869
|
+
type SplitViewAsync = Promise<SplitView | null>;
|
|
457
870
|
/**
|
|
458
871
|
* An array containing the SplitIO.SplitView elements.
|
|
459
872
|
*/
|
|
460
873
|
type SplitViews = Array<SplitView>;
|
|
461
874
|
/**
|
|
462
875
|
* A promise that resolves to an SplitIO.SplitViews array.
|
|
463
|
-
* @typedef {Promise<SplitViews>} SplitViewsAsync
|
|
464
876
|
*/
|
|
465
877
|
type SplitViewsAsync = Promise<SplitViews>;
|
|
466
878
|
/**
|
|
467
879
|
* An array of feature flag names.
|
|
468
|
-
* @typedef {Array<string>} SplitNames
|
|
469
880
|
*/
|
|
470
881
|
type SplitNames = Array<string>;
|
|
471
882
|
/**
|
|
472
883
|
* A promise that resolves to an array of feature flag names.
|
|
473
|
-
* @typedef {Promise<SplitNames>} SplitNamesAsync
|
|
474
884
|
*/
|
|
475
885
|
type SplitNamesAsync = Promise<SplitNames>;
|
|
476
886
|
/**
|
|
477
887
|
* Storage for synchronous (standalone) SDK.
|
|
478
888
|
* Its interface details are not part of the public API.
|
|
479
889
|
*/
|
|
480
|
-
type StorageSync =
|
|
890
|
+
type StorageSync = any;
|
|
481
891
|
/**
|
|
482
892
|
* Storage builder for synchronous (standalone) SDK.
|
|
483
|
-
* By returning undefined, the SDK will use the default IN MEMORY storage.
|
|
484
893
|
* Input parameter details are not part of the public API.
|
|
485
894
|
*/
|
|
486
895
|
type StorageSyncFactory = {
|
|
487
896
|
readonly type: StorageType;
|
|
488
|
-
(params:
|
|
897
|
+
(params: any): (StorageSync | undefined);
|
|
489
898
|
}
|
|
490
899
|
/**
|
|
491
900
|
* Configuration params for `InLocalStorage`
|
|
@@ -493,8 +902,8 @@ declare namespace SplitIO {
|
|
|
493
902
|
type InLocalStorageOptions = {
|
|
494
903
|
/**
|
|
495
904
|
* Optional prefix to prevent any kind of data collision when having multiple factories using the same storage type.
|
|
496
|
-
*
|
|
497
|
-
* @
|
|
905
|
+
*
|
|
906
|
+
* @defaultValue `'SPLITIO'`
|
|
498
907
|
*/
|
|
499
908
|
prefix?: string;
|
|
500
909
|
}
|
|
@@ -502,14 +911,14 @@ declare namespace SplitIO {
|
|
|
502
911
|
* Storage for asynchronous (consumer) SDK.
|
|
503
912
|
* Its interface details are not part of the public API.
|
|
504
913
|
*/
|
|
505
|
-
type StorageAsync =
|
|
914
|
+
type StorageAsync = any
|
|
506
915
|
/**
|
|
507
916
|
* Storage builder for asynchronous (consumer) SDK.
|
|
508
917
|
* Input parameter details are not part of the public API.
|
|
509
918
|
*/
|
|
510
919
|
type StorageAsyncFactory = {
|
|
511
|
-
readonly type:
|
|
512
|
-
(params:
|
|
920
|
+
readonly type: StorageType;
|
|
921
|
+
(params: any): StorageAsync;
|
|
513
922
|
}
|
|
514
923
|
/**
|
|
515
924
|
* Configuration params for `PluggableStorage`
|
|
@@ -517,29 +926,25 @@ declare namespace SplitIO {
|
|
|
517
926
|
type PluggableStorageOptions = {
|
|
518
927
|
/**
|
|
519
928
|
* Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper.
|
|
520
|
-
*
|
|
521
|
-
* @
|
|
929
|
+
*
|
|
930
|
+
* @defaultValue `'SPLITIO'`
|
|
522
931
|
*/
|
|
523
932
|
prefix?: string;
|
|
524
933
|
/**
|
|
525
934
|
* Storage wrapper.
|
|
526
|
-
* @property {Object} wrapper
|
|
527
935
|
*/
|
|
528
936
|
wrapper: Object;
|
|
529
937
|
}
|
|
530
938
|
/**
|
|
531
939
|
* Synchronous storage valid types for NodeJS.
|
|
532
|
-
* @typedef {string} NodeSyncStorage
|
|
533
940
|
*/
|
|
534
941
|
type NodeSyncStorage = 'MEMORY';
|
|
535
942
|
/**
|
|
536
943
|
* Asynchronous storages valid types for NodeJS.
|
|
537
|
-
* @typedef {string} NodeAsyncStorage
|
|
538
944
|
*/
|
|
539
945
|
type NodeAsyncStorage = 'REDIS';
|
|
540
946
|
/**
|
|
541
947
|
* Storage valid types for the browser.
|
|
542
|
-
* @typedef {string} BrowserStorage
|
|
543
948
|
*/
|
|
544
949
|
type BrowserStorage = 'MEMORY' | 'LOCALSTORAGE';
|
|
545
950
|
/**
|
|
@@ -553,17 +958,17 @@ declare namespace SplitIO {
|
|
|
553
958
|
/**
|
|
554
959
|
* Impression listener interface. This is the interface that needs to be implemented
|
|
555
960
|
* by the element you provide to the SDK as impression listener.
|
|
556
|
-
*
|
|
961
|
+
*
|
|
557
962
|
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#listener}
|
|
558
963
|
*/
|
|
559
964
|
interface IImpressionListener {
|
|
560
|
-
logImpression(data:
|
|
965
|
+
logImpression(data: ImpressionData): void;
|
|
561
966
|
}
|
|
562
967
|
/**
|
|
563
968
|
* SDK integration instance.
|
|
564
969
|
* Its interface details are not part of the public API.
|
|
565
970
|
*/
|
|
566
|
-
type Integration =
|
|
971
|
+
type Integration = any;
|
|
567
972
|
/**
|
|
568
973
|
* SDK integration factory.
|
|
569
974
|
* By returning an integration, the SDK will queue events and impressions into it.
|
|
@@ -571,21 +976,23 @@ declare namespace SplitIO {
|
|
|
571
976
|
*/
|
|
572
977
|
type IntegrationFactory = {
|
|
573
978
|
readonly type: string;
|
|
574
|
-
(params:
|
|
979
|
+
(params: any): (Integration | void);
|
|
575
980
|
}
|
|
576
981
|
/**
|
|
577
982
|
* A pair of user key and it's trafficType, required for tracking valid Split events.
|
|
578
|
-
* @typedef {Object} Identity
|
|
579
|
-
* @property {string} key The user key.
|
|
580
|
-
* @property {string} trafficType The key traffic type.
|
|
581
983
|
*/
|
|
582
984
|
type Identity = {
|
|
985
|
+
/**
|
|
986
|
+
* The user key.
|
|
987
|
+
*/
|
|
583
988
|
key: string;
|
|
989
|
+
/**
|
|
990
|
+
* The key traffic type.
|
|
991
|
+
*/
|
|
584
992
|
trafficType: string;
|
|
585
993
|
};
|
|
586
994
|
/**
|
|
587
995
|
* Object with information about a Split event.
|
|
588
|
-
* @typedef {Object} EventData
|
|
589
996
|
*/
|
|
590
997
|
type EventData = {
|
|
591
998
|
eventTypeId: string;
|
|
@@ -593,55 +1000,68 @@ declare namespace SplitIO {
|
|
|
593
1000
|
properties?: Properties;
|
|
594
1001
|
trafficTypeName?: string;
|
|
595
1002
|
key?: string;
|
|
596
|
-
timestamp
|
|
1003
|
+
timestamp: number;
|
|
597
1004
|
};
|
|
598
1005
|
/**
|
|
599
1006
|
* Object representing the data sent by Split (events and impressions).
|
|
600
|
-
* @typedef {Object} IntegrationData
|
|
601
|
-
* @property {string} type The type of Split data, either 'IMPRESSION' or 'EVENT'.
|
|
602
|
-
* @property {ImpressionData | EventData} payload The data instance itself.
|
|
603
1007
|
*/
|
|
604
|
-
type IntegrationData = {
|
|
1008
|
+
type IntegrationData = {
|
|
1009
|
+
/**
|
|
1010
|
+
* The type of Split data.
|
|
1011
|
+
*/
|
|
1012
|
+
type: 'IMPRESSION';
|
|
1013
|
+
/**
|
|
1014
|
+
* The impression data.
|
|
1015
|
+
*/
|
|
1016
|
+
payload: ImpressionData;
|
|
1017
|
+
} | {
|
|
1018
|
+
/**
|
|
1019
|
+
* The type of Split data.
|
|
1020
|
+
*/
|
|
1021
|
+
type: 'EVENT';
|
|
1022
|
+
/**
|
|
1023
|
+
* The event data.
|
|
1024
|
+
*/
|
|
1025
|
+
payload: EventData;
|
|
1026
|
+
};
|
|
605
1027
|
/**
|
|
606
1028
|
* Available URL settings for the SDKs.
|
|
607
1029
|
*/
|
|
608
1030
|
type UrlSettings = {
|
|
609
1031
|
/**
|
|
610
1032
|
* String property to override the base URL where the SDK will get rollout plan related data, like feature flags and segments definitions.
|
|
611
|
-
*
|
|
612
|
-
* @
|
|
1033
|
+
*
|
|
1034
|
+
* @defaultValue `'https://sdk.split.io/api'`
|
|
613
1035
|
*/
|
|
614
1036
|
sdk?: string;
|
|
615
1037
|
/**
|
|
616
1038
|
* String property to override the base URL where the SDK will post event-related information like impressions.
|
|
617
|
-
*
|
|
618
|
-
* @
|
|
1039
|
+
*
|
|
1040
|
+
* @defaultValue `'https://events.split.io/api'`
|
|
619
1041
|
*/
|
|
620
1042
|
events?: string;
|
|
621
1043
|
/**
|
|
622
1044
|
* String property to override the base URL where the SDK will get authorization tokens to be used with functionality that requires it, like streaming.
|
|
623
|
-
*
|
|
624
|
-
* @
|
|
1045
|
+
*
|
|
1046
|
+
* @defaultValue `'https://auth.split.io/api'`
|
|
625
1047
|
*/
|
|
626
1048
|
auth?: string;
|
|
627
1049
|
/**
|
|
628
1050
|
* String property to override the base URL where the SDK will connect to receive streaming updates.
|
|
629
|
-
*
|
|
630
|
-
* @
|
|
1051
|
+
*
|
|
1052
|
+
* @defaultValue `'https://streaming.split.io'`
|
|
631
1053
|
*/
|
|
632
1054
|
streaming?: string;
|
|
633
1055
|
/**
|
|
634
1056
|
* String property to override the base URL where the SDK will post telemetry data.
|
|
635
|
-
*
|
|
636
|
-
* @
|
|
1057
|
+
*
|
|
1058
|
+
* @defaultValue `'https://telemetry.split.io/api'`
|
|
637
1059
|
*/
|
|
638
1060
|
telemetry?: string;
|
|
639
1061
|
};
|
|
640
1062
|
|
|
641
1063
|
/**
|
|
642
1064
|
* SplitFilter type.
|
|
643
|
-
*
|
|
644
|
-
* @typedef {string} SplitFilterType
|
|
645
1065
|
*/
|
|
646
1066
|
type SplitFilterType = 'bySet' | 'byName' | 'byPrefix';
|
|
647
1067
|
/**
|
|
@@ -650,215 +1070,37 @@ declare namespace SplitIO {
|
|
|
650
1070
|
interface SplitFilter {
|
|
651
1071
|
/**
|
|
652
1072
|
* Type of the filter.
|
|
653
|
-
*
|
|
654
|
-
* @property {SplitFilterType} type
|
|
655
1073
|
*/
|
|
656
1074
|
type: SplitFilterType;
|
|
657
1075
|
/**
|
|
658
1076
|
* List of values: feature flag names for 'byName' filter type, and feature flag name prefixes for 'byPrefix' type.
|
|
659
|
-
*
|
|
660
|
-
* @property {string[]} values
|
|
661
1077
|
*/
|
|
662
1078
|
values: string[];
|
|
663
1079
|
}
|
|
664
1080
|
/**
|
|
665
1081
|
* ImpressionsMode type
|
|
666
|
-
* @typedef {string} ImpressionsMode
|
|
667
1082
|
*/
|
|
668
1083
|
type ImpressionsMode = 'OPTIMIZED' | 'DEBUG' | 'NONE';
|
|
669
1084
|
/**
|
|
670
1085
|
* User consent status.
|
|
671
|
-
* @typedef {string} ConsentStatus
|
|
672
1086
|
*/
|
|
673
1087
|
type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
|
|
674
1088
|
/**
|
|
675
|
-
* Logger
|
|
676
|
-
* Its interface details are not part of the public API. It shouldn't be used directly.
|
|
677
|
-
* @interface ILogger
|
|
1089
|
+
* Logger. Its interface details are not part of the public API. It shouldn't be used directly.
|
|
678
1090
|
*/
|
|
679
1091
|
interface ILogger {
|
|
680
1092
|
setLogLevel(logLevel: LogLevel): void;
|
|
681
1093
|
}
|
|
682
1094
|
/**
|
|
683
|
-
*
|
|
1095
|
+
* Settings interface for Browser SDK instances created with client-side API and synchronous storage (e.g., in-memory or local storage).
|
|
684
1096
|
*
|
|
685
|
-
* @interface IClientSideBasicSettings
|
|
686
|
-
*/
|
|
687
|
-
interface IClientSideBasicSettings {
|
|
688
|
-
/**
|
|
689
|
-
* SDK Core settings for client-side.
|
|
690
|
-
* @property {Object} core
|
|
691
|
-
*/
|
|
692
|
-
core: {
|
|
693
|
-
/**
|
|
694
|
-
* Your SDK key.
|
|
695
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
696
|
-
* @property {string} authorizationKey
|
|
697
|
-
*/
|
|
698
|
-
authorizationKey: string;
|
|
699
|
-
/**
|
|
700
|
-
* Customer identifier. Whatever this means to you.
|
|
701
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
702
|
-
* @property {SplitKey} key
|
|
703
|
-
*/
|
|
704
|
-
key: SplitKey;
|
|
705
|
-
/**
|
|
706
|
-
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
707
|
-
* @property {boolean} labelsEnabled
|
|
708
|
-
* @default true
|
|
709
|
-
*/
|
|
710
|
-
labelsEnabled?: boolean;
|
|
711
|
-
};
|
|
712
|
-
/**
|
|
713
|
-
* Boolean value to indicate whether the logger should be enabled or disabled by default, or a log level string or a Logger object.
|
|
714
|
-
* Passing a logger object is required to get descriptive log messages. Otherwise most logs will print with message codes.
|
|
715
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}.
|
|
716
|
-
*
|
|
717
|
-
* Examples:
|
|
718
|
-
* ```
|
|
719
|
-
* config.debug = true
|
|
720
|
-
* config.debug = 'WARN'
|
|
721
|
-
* config.debug = ErrorLogger()
|
|
722
|
-
* ```
|
|
723
|
-
* @property {boolean | LogLevel | ILogger} debug
|
|
724
|
-
* @default false
|
|
725
|
-
*/
|
|
726
|
-
debug?: boolean | LogLevel | SplitIO.ILogger;
|
|
727
|
-
/**
|
|
728
|
-
* The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
|
|
729
|
-
* which will check for the logImpression method.
|
|
730
|
-
* @property {IImpressionListener} impressionListener
|
|
731
|
-
* @default undefined
|
|
732
|
-
*/
|
|
733
|
-
impressionListener?: SplitIO.IImpressionListener;
|
|
734
|
-
/**
|
|
735
|
-
* Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
|
|
736
|
-
* the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
|
|
737
|
-
* @property {boolean} streamingEnabled
|
|
738
|
-
* @default true
|
|
739
|
-
*/
|
|
740
|
-
streamingEnabled?: boolean;
|
|
741
|
-
/**
|
|
742
|
-
* SDK synchronization settings.
|
|
743
|
-
* @property {Object} sync
|
|
744
|
-
*/
|
|
745
|
-
sync?: {
|
|
746
|
-
/**
|
|
747
|
-
* List of feature flag filters. These filters are used to fetch a subset of the feature flag definitions in your environment, in order to reduce the delay of the SDK to be ready.
|
|
748
|
-
* This configuration is only meaningful when the SDK is working in "standalone" mode.
|
|
749
|
-
*
|
|
750
|
-
* Example:
|
|
751
|
-
* `splitFilter: [
|
|
752
|
-
* { type: 'byName', values: ['my_feature_flag_1', 'my_feature_flag_2'] }, // will fetch feature flags named 'my_feature_flag_1' and 'my_feature_flag_2'
|
|
753
|
-
* ]`
|
|
754
|
-
* @property {SplitIO.SplitFilter[]} splitFilters
|
|
755
|
-
*/
|
|
756
|
-
splitFilters?: SplitIO.SplitFilter[]
|
|
757
|
-
/**
|
|
758
|
-
* Impressions Collection Mode. Option to determine how impressions are going to be sent to Split servers.
|
|
759
|
-
* Possible values are 'DEBUG', 'OPTIMIZED', and 'NONE'.
|
|
760
|
-
* - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
|
|
761
|
-
* - OPTIMIZED: will send unique impressions to Split servers, avoiding a considerable amount of traffic that duplicated impressions could generate.
|
|
762
|
-
* - NONE: will send unique keys evaluated per feature to Split servers instead of full blown impressions, avoiding a considerable amount of traffic that impressions could generate.
|
|
763
|
-
*
|
|
764
|
-
* @property {string} impressionsMode
|
|
765
|
-
* @default 'OPTIMIZED'
|
|
766
|
-
*/
|
|
767
|
-
impressionsMode?: SplitIO.ImpressionsMode;
|
|
768
|
-
/**
|
|
769
|
-
* Controls the SDK continuous synchronization flags.
|
|
770
|
-
*
|
|
771
|
-
* When `true` a running SDK will process rollout plan updates performed on the UI (default).
|
|
772
|
-
* When false it'll just fetch all data upon init.
|
|
773
|
-
*
|
|
774
|
-
* @property {boolean} enabled
|
|
775
|
-
* @default true
|
|
776
|
-
*/
|
|
777
|
-
enabled?: boolean
|
|
778
|
-
/**
|
|
779
|
-
* Custom options object for HTTP(S) requests.
|
|
780
|
-
* If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
|
|
781
|
-
* This configuration has no effect in "consumer" mode, as no HTTP(S) requests are made by the SDK.
|
|
782
|
-
*/
|
|
783
|
-
requestOptions?: {
|
|
784
|
-
/**
|
|
785
|
-
* Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
|
|
786
|
-
* Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
|
|
787
|
-
* To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
|
|
788
|
-
* Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
|
|
789
|
-
*
|
|
790
|
-
* NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers,
|
|
791
|
-
* like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and will be ignored.
|
|
792
|
-
*
|
|
793
|
-
* @property getHeaderOverrides
|
|
794
|
-
* @default undefined
|
|
795
|
-
*
|
|
796
|
-
* @param context - The context for the request.
|
|
797
|
-
* @param context.headers - The current headers in the request.
|
|
798
|
-
* @returns A set of headers to be merged with the current headers.
|
|
799
|
-
*
|
|
800
|
-
* @example
|
|
801
|
-
* const getHeaderOverrides = (context) => {
|
|
802
|
-
* return {
|
|
803
|
-
* 'Authorization': context.headers['Authorization'] + ', other-value',
|
|
804
|
-
* 'custom-header': 'custom-value'
|
|
805
|
-
* };
|
|
806
|
-
* };
|
|
807
|
-
*/
|
|
808
|
-
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>;
|
|
809
|
-
};
|
|
810
|
-
};
|
|
811
|
-
/**
|
|
812
|
-
* List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
|
|
813
|
-
* Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
|
|
814
|
-
* @property {Object} urls
|
|
815
|
-
*/
|
|
816
|
-
urls?: UrlSettings;
|
|
817
|
-
/**
|
|
818
|
-
* Defines an optional list of factory functions used to instantiate SDK integrations.
|
|
819
|
-
*
|
|
820
|
-
* NOTE: at the moment there are not integrations to plug in.
|
|
821
|
-
*
|
|
822
|
-
* @property {Object} integrations
|
|
823
|
-
*/
|
|
824
|
-
integrations?: IntegrationFactory[];
|
|
825
|
-
/**
|
|
826
|
-
* User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
|
|
827
|
-
* - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
|
|
828
|
-
* - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
|
|
829
|
-
* - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends
|
|
830
|
-
* them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method.
|
|
831
|
-
*
|
|
832
|
-
* @typedef {string} userConsent
|
|
833
|
-
* @default 'GRANTED'
|
|
834
|
-
*/
|
|
835
|
-
userConsent?: ConsentStatus;
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Settings interface for SDK instances created for client-side with synchronous storage (e.g., Browser or React Native).
|
|
839
|
-
*
|
|
840
|
-
* @interface IClientSideSettings
|
|
841
|
-
* @extends IClientSideBasicSettings
|
|
842
1097
|
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
|
|
843
1098
|
*/
|
|
844
|
-
interface IClientSideSettings extends
|
|
1099
|
+
interface IClientSideSettings extends IClientSideSyncSharedSettings, IPluggableSettings {
|
|
845
1100
|
/**
|
|
846
|
-
*
|
|
847
|
-
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
1101
|
+
* Defines the factory function to instantiate the storage. If not provided, the default in-memory storage is used.
|
|
848
1102
|
*
|
|
849
|
-
*
|
|
850
|
-
* @default 'standalone'
|
|
851
|
-
*/
|
|
852
|
-
mode?: 'standalone';
|
|
853
|
-
/**
|
|
854
|
-
* Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
855
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
|
|
856
|
-
*/
|
|
857
|
-
features?: MockedFeaturesMap;
|
|
858
|
-
/**
|
|
859
|
-
* Defines the factory function to instantiate the storage. If not provided, the default IN MEMORY storage is used.
|
|
860
|
-
*
|
|
861
|
-
* NOTE: at the moment there are not storages to plug in React Native SDK, only `InLocalStorage` for Browser SDK.
|
|
1103
|
+
* NOTE: Currently, there is no persistent storage option available for the React Native SDK; only `InLocalStorage` for the Browser SDK.
|
|
862
1104
|
*
|
|
863
1105
|
* Example:
|
|
864
1106
|
* ```
|
|
@@ -867,119 +1109,26 @@ declare namespace SplitIO {
|
|
|
867
1109
|
* storage: InLocalStorage()
|
|
868
1110
|
* })
|
|
869
1111
|
* ```
|
|
870
|
-
* @property {Object} storage
|
|
871
1112
|
*/
|
|
872
1113
|
storage?: StorageSyncFactory;
|
|
873
|
-
/**
|
|
874
|
-
* SDK Startup settings.
|
|
875
|
-
* @property {Object} startup
|
|
876
|
-
*/
|
|
877
|
-
startup?: {
|
|
878
|
-
/**
|
|
879
|
-
* Maximum amount of time used before notify a timeout.
|
|
880
|
-
* @property {number} readyTimeout
|
|
881
|
-
* @default 1.5
|
|
882
|
-
*/
|
|
883
|
-
readyTimeout?: number;
|
|
884
|
-
/**
|
|
885
|
-
* Time to wait for a request before the SDK is ready. If this time expires, JS Sdk will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
|
|
886
|
-
* @property {number} requestTimeoutBeforeReady
|
|
887
|
-
* @default 1.5
|
|
888
|
-
*/
|
|
889
|
-
requestTimeoutBeforeReady?: number;
|
|
890
|
-
/**
|
|
891
|
-
* How many quick retries we will do while starting up the SDK.
|
|
892
|
-
* @property {number} retriesOnFailureBeforeReady
|
|
893
|
-
* @default 1
|
|
894
|
-
*/
|
|
895
|
-
retriesOnFailureBeforeReady?: number;
|
|
896
|
-
/**
|
|
897
|
-
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
898
|
-
* to better control on browsers or mobile. This number defines that window before the first events push.
|
|
899
|
-
*
|
|
900
|
-
* @property {number} eventsFirstPushWindow
|
|
901
|
-
* @default 10
|
|
902
|
-
*/
|
|
903
|
-
eventsFirstPushWindow?: number;
|
|
904
|
-
};
|
|
905
|
-
/**
|
|
906
|
-
* SDK scheduler settings.
|
|
907
|
-
* @property {Object} scheduler
|
|
908
|
-
*/
|
|
909
|
-
scheduler?: {
|
|
910
|
-
/**
|
|
911
|
-
* The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
|
|
912
|
-
* @property {number} featuresRefreshRate
|
|
913
|
-
* @default 60
|
|
914
|
-
*/
|
|
915
|
-
featuresRefreshRate?: number;
|
|
916
|
-
/**
|
|
917
|
-
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
918
|
-
* @property {number} impressionsRefreshRate
|
|
919
|
-
* @default 60
|
|
920
|
-
*/
|
|
921
|
-
impressionsRefreshRate?: number;
|
|
922
|
-
/**
|
|
923
|
-
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
924
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
925
|
-
* @property {number} impressionsQueueSize
|
|
926
|
-
* @default 30000
|
|
927
|
-
*/
|
|
928
|
-
impressionsQueueSize?: number;
|
|
929
|
-
/**
|
|
930
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
931
|
-
* @property {number} telemetryRefreshRate
|
|
932
|
-
* @default 3600
|
|
933
|
-
*/
|
|
934
|
-
telemetryRefreshRate?: number;
|
|
935
|
-
/**
|
|
936
|
-
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
937
|
-
* @property {number} segmentsRefreshRate
|
|
938
|
-
* @default 60
|
|
939
|
-
*/
|
|
940
|
-
segmentsRefreshRate?: number;
|
|
941
|
-
/**
|
|
942
|
-
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
943
|
-
* @property {number} eventsPushRate
|
|
944
|
-
* @default 60
|
|
945
|
-
*/
|
|
946
|
-
eventsPushRate?: number;
|
|
947
|
-
/**
|
|
948
|
-
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
949
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
950
|
-
* @property {number} eventsQueueSize
|
|
951
|
-
* @default 500
|
|
952
|
-
*/
|
|
953
|
-
eventsQueueSize?: number;
|
|
954
|
-
/**
|
|
955
|
-
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
956
|
-
* For more information see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
|
|
957
|
-
* @property {number} offlineRefreshRate
|
|
958
|
-
* @default 15
|
|
959
|
-
*/
|
|
960
|
-
offlineRefreshRate?: number;
|
|
961
|
-
/**
|
|
962
|
-
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
963
|
-
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
964
|
-
* @property {number} pushRetryBackoffBase
|
|
965
|
-
* @default 1
|
|
966
|
-
*/
|
|
967
|
-
pushRetryBackoffBase?: number;
|
|
968
|
-
}
|
|
969
1114
|
}
|
|
970
1115
|
/**
|
|
971
|
-
* Settings interface
|
|
972
|
-
*
|
|
973
|
-
* @
|
|
974
|
-
|
|
1116
|
+
* Settings interface for React Native SDK instances, with client-side API and synchronous storage.
|
|
1117
|
+
*
|
|
1118
|
+
* @see {@link https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK#configuration}
|
|
1119
|
+
*/
|
|
1120
|
+
interface IReactNativeSettings extends IClientSideSettings { }
|
|
1121
|
+
/**
|
|
1122
|
+
* Settings interface for Browser SDK instances created with client-side API and asynchronous storage (e.g., serverless environments with a persistent storage).
|
|
1123
|
+
* If your storage is synchronous (by default we use memory, which is sync) use SplitIO.IClientSideSettings instead.
|
|
1124
|
+
*
|
|
1125
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage}
|
|
975
1126
|
*/
|
|
976
|
-
interface IClientSideAsyncSettings extends
|
|
1127
|
+
interface IClientSideAsyncSettings extends IClientSideSharedSettings, ISharedSettings, IPluggableSettings {
|
|
977
1128
|
/**
|
|
978
1129
|
* The SDK mode. When using `PluggableStorage` as storage, the possible values are "consumer" and "consumer_partial".
|
|
979
1130
|
*
|
|
980
1131
|
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage}
|
|
981
|
-
*
|
|
982
|
-
* @property {'consumer' | 'consumer_partial'} mode
|
|
983
1132
|
*/
|
|
984
1133
|
mode: 'consumer' | 'consumer_partial';
|
|
985
1134
|
/**
|
|
@@ -992,18 +1141,16 @@ declare namespace SplitIO {
|
|
|
992
1141
|
* storage: PluggableStorage({ wrapper: SomeWrapper })
|
|
993
1142
|
* })
|
|
994
1143
|
* ```
|
|
995
|
-
* @property {Object} storage
|
|
996
1144
|
*/
|
|
997
1145
|
storage: StorageAsyncFactory;
|
|
998
1146
|
/**
|
|
999
1147
|
* SDK Startup settings.
|
|
1000
|
-
* @property {Object} startup
|
|
1001
1148
|
*/
|
|
1002
1149
|
startup?: {
|
|
1003
1150
|
/**
|
|
1004
1151
|
* Maximum amount of time used before notify a timeout.
|
|
1005
|
-
*
|
|
1006
|
-
* @
|
|
1152
|
+
*
|
|
1153
|
+
* @defaultValue `5`
|
|
1007
1154
|
*/
|
|
1008
1155
|
readyTimeout?: number;
|
|
1009
1156
|
/**
|
|
@@ -1011,43 +1158,46 @@ declare namespace SplitIO {
|
|
|
1011
1158
|
* to better control on browsers or mobile. This number defines that window before the first events push.
|
|
1012
1159
|
*
|
|
1013
1160
|
* NOTE: this param is ignored in 'consumer' mode.
|
|
1014
|
-
*
|
|
1015
|
-
* @
|
|
1161
|
+
*
|
|
1162
|
+
* @defaultValue `10`
|
|
1016
1163
|
*/
|
|
1017
1164
|
eventsFirstPushWindow?: number;
|
|
1018
1165
|
};
|
|
1019
1166
|
/**
|
|
1020
1167
|
* SDK scheduler settings.
|
|
1021
|
-
* @property {Object} scheduler
|
|
1022
1168
|
*/
|
|
1023
1169
|
scheduler?: {
|
|
1024
1170
|
/**
|
|
1025
1171
|
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
1026
1172
|
*
|
|
1027
1173
|
* NOTE: this param is ignored in 'consumer' mode.
|
|
1028
|
-
*
|
|
1029
|
-
* @
|
|
1174
|
+
*
|
|
1175
|
+
* @defaultValue `60`
|
|
1030
1176
|
*/
|
|
1031
1177
|
impressionsRefreshRate?: number;
|
|
1032
1178
|
/**
|
|
1033
1179
|
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
1034
1180
|
* If you use a 0 here, the queue will have no maximum size.
|
|
1035
|
-
*
|
|
1036
|
-
*
|
|
1181
|
+
*
|
|
1182
|
+
* NOTE: this param is ignored in 'consumer' mode.
|
|
1183
|
+
*
|
|
1184
|
+
* @defaultValue `30000`
|
|
1037
1185
|
*/
|
|
1038
1186
|
impressionsQueueSize?: number;
|
|
1039
1187
|
/**
|
|
1040
1188
|
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1189
|
+
*
|
|
1190
|
+
* NOTE: this param is ignored in 'consumer' mode.
|
|
1191
|
+
*
|
|
1192
|
+
* @defaultValue `3600`
|
|
1043
1193
|
*/
|
|
1044
1194
|
telemetryRefreshRate?: number;
|
|
1045
1195
|
/**
|
|
1046
1196
|
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
1047
1197
|
*
|
|
1048
1198
|
* NOTE: this param is ignored in 'consumer' mode.
|
|
1049
|
-
*
|
|
1050
|
-
* @
|
|
1199
|
+
*
|
|
1200
|
+
* @defaultValue `60`
|
|
1051
1201
|
*/
|
|
1052
1202
|
eventsPushRate?: number;
|
|
1053
1203
|
/**
|
|
@@ -1055,504 +1205,63 @@ declare namespace SplitIO {
|
|
|
1055
1205
|
* If you use a 0 here, the queue will have no maximum size.
|
|
1056
1206
|
*
|
|
1057
1207
|
* NOTE: this param is ignored in 'consumer' mode.
|
|
1058
|
-
* @property {number} eventsQueueSize
|
|
1059
|
-
* @default 500
|
|
1060
|
-
*/
|
|
1061
|
-
eventsQueueSize?: number;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
/**
|
|
1065
|
-
* Common settings between Browser and NodeJS settings interface.
|
|
1066
|
-
* @interface ISharedSettings
|
|
1067
|
-
*/
|
|
1068
|
-
interface ISharedSettings {
|
|
1069
|
-
/**
|
|
1070
|
-
* Boolean value to indicate whether the logger should be enabled or disabled, or a log level string.
|
|
1071
|
-
*
|
|
1072
|
-
* Examples:
|
|
1073
|
-
* ```
|
|
1074
|
-
* config.debug = true
|
|
1075
|
-
* config.debug = 'WARN'
|
|
1076
|
-
* ```
|
|
1077
|
-
* @property {boolean | LogLevel} debug
|
|
1078
|
-
* @default false
|
|
1079
|
-
*/
|
|
1080
|
-
debug?: boolean | LogLevel,
|
|
1081
|
-
/**
|
|
1082
|
-
* The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
|
|
1083
|
-
* which will check for the logImpression method.
|
|
1084
|
-
* @property {IImpressionListener} impressionListener
|
|
1085
|
-
* @default undefined
|
|
1086
|
-
*/
|
|
1087
|
-
impressionListener?: SplitIO.IImpressionListener,
|
|
1088
|
-
/**
|
|
1089
|
-
* Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
|
|
1090
|
-
* the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
|
|
1091
|
-
* @property {boolean} streamingEnabled
|
|
1092
|
-
* @default true
|
|
1093
|
-
*/
|
|
1094
|
-
streamingEnabled?: boolean,
|
|
1095
|
-
/**
|
|
1096
|
-
* SDK synchronization settings.
|
|
1097
|
-
* @property {Object} sync
|
|
1098
|
-
*/
|
|
1099
|
-
sync?: {
|
|
1100
|
-
/**
|
|
1101
|
-
* List of feature flag filters. These filters are used to fetch a subset of the feature flag definitions in your environment, in order to reduce the delay of the SDK to be ready.
|
|
1102
|
-
* This configuration is only meaningful when the SDK is working in "standalone" mode.
|
|
1103
|
-
*
|
|
1104
|
-
* Example:
|
|
1105
|
-
* `splitFilter: [
|
|
1106
|
-
* { type: 'byName', values: ['my_feature_flag_1', 'my_feature_flag_2'] }, // will fetch feature flags named 'my_feature_flag_1' and 'my_feature_flag_2'
|
|
1107
|
-
* ]`
|
|
1108
|
-
* @property {SplitIO.SplitFilter[]} splitFilters
|
|
1109
|
-
*/
|
|
1110
|
-
splitFilters?: SplitIO.SplitFilter[]
|
|
1111
|
-
/**
|
|
1112
|
-
* Impressions Collection Mode. Option to determine how impressions are going to be sent to Split servers.
|
|
1113
|
-
* Possible values are 'DEBUG', 'OPTIMIZED', and 'NONE'.
|
|
1114
|
-
* - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
|
|
1115
|
-
* - OPTIMIZED: will send unique impressions to Split servers, avoiding a considerable amount of traffic that duplicated impressions could generate.
|
|
1116
|
-
* - NONE: will send unique keys evaluated per feature to Split servers instead of full blown impressions, avoiding a considerable amount of traffic that impressions could generate.
|
|
1117
|
-
*
|
|
1118
|
-
* @property {string} impressionsMode
|
|
1119
|
-
* @default 'OPTIMIZED'
|
|
1120
|
-
*/
|
|
1121
|
-
impressionsMode?: SplitIO.ImpressionsMode,
|
|
1122
|
-
/**
|
|
1123
|
-
* Controls the SDK continuous synchronization flags.
|
|
1124
|
-
*
|
|
1125
|
-
* When `true` a running SDK will process rollout plan updates performed on the UI (default).
|
|
1126
|
-
* When false it'll just fetch all data upon init.
|
|
1127
|
-
*
|
|
1128
|
-
* @property {boolean} enabled
|
|
1129
|
-
* @default true
|
|
1130
|
-
*/
|
|
1131
|
-
enabled?: boolean
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* Common settings interface for SDK instances on NodeJS.
|
|
1136
|
-
* @interface INodeBasicSettings
|
|
1137
|
-
* @extends ISharedSettings
|
|
1138
|
-
*/
|
|
1139
|
-
interface INodeBasicSettings extends ISharedSettings {
|
|
1140
|
-
/**
|
|
1141
|
-
* SDK Startup settings for NodeJS.
|
|
1142
|
-
* @property {Object} startup
|
|
1143
|
-
*/
|
|
1144
|
-
startup?: {
|
|
1145
|
-
/**
|
|
1146
|
-
* Maximum amount of time used before notify a timeout.
|
|
1147
|
-
* @property {number} readyTimeout
|
|
1148
|
-
* @default 15
|
|
1149
|
-
*/
|
|
1150
|
-
readyTimeout?: number,
|
|
1151
|
-
/**
|
|
1152
|
-
* Time to wait for a request before the SDK is ready. If this time expires, JS Sdk will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
|
|
1153
|
-
* @property {number} requestTimeoutBeforeReady
|
|
1154
|
-
* @default 15
|
|
1155
|
-
*/
|
|
1156
|
-
requestTimeoutBeforeReady?: number,
|
|
1157
|
-
/**
|
|
1158
|
-
* How many quick retries we will do while starting up the SDK.
|
|
1159
|
-
* @property {number} retriesOnFailureBeforeReady
|
|
1160
|
-
* @default 1
|
|
1161
|
-
*/
|
|
1162
|
-
retriesOnFailureBeforeReady?: number,
|
|
1163
|
-
/**
|
|
1164
|
-
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
1165
|
-
* to better control on browsers. This number defines that window before the first events push.
|
|
1166
1208
|
*
|
|
1167
|
-
* @
|
|
1168
|
-
* @default 0
|
|
1169
|
-
*/
|
|
1170
|
-
eventsFirstPushWindow?: number,
|
|
1171
|
-
},
|
|
1172
|
-
/**
|
|
1173
|
-
* SDK scheduler settings.
|
|
1174
|
-
* @property {Object} scheduler
|
|
1175
|
-
*/
|
|
1176
|
-
scheduler?: {
|
|
1177
|
-
/**
|
|
1178
|
-
* The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
|
|
1179
|
-
* @property {number} featuresRefreshRate
|
|
1180
|
-
* @default 60
|
|
1181
|
-
*/
|
|
1182
|
-
featuresRefreshRate?: number,
|
|
1183
|
-
/**
|
|
1184
|
-
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
1185
|
-
* @property {number} impressionsRefreshRate
|
|
1186
|
-
* @default 300
|
|
1187
|
-
*/
|
|
1188
|
-
impressionsRefreshRate?: number,
|
|
1189
|
-
/**
|
|
1190
|
-
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
1191
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
1192
|
-
* @property {number} impressionsQueueSize
|
|
1193
|
-
* @default 30000
|
|
1194
|
-
*/
|
|
1195
|
-
impressionsQueueSize?: number,
|
|
1196
|
-
/**
|
|
1197
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
1198
|
-
* @property {number} metricsRefreshRate
|
|
1199
|
-
* @default 120
|
|
1200
|
-
* @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
|
|
1201
|
-
*/
|
|
1202
|
-
metricsRefreshRate?: number,
|
|
1203
|
-
/**
|
|
1204
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
1205
|
-
* @property {number} telemetryRefreshRate
|
|
1206
|
-
* @default 3600
|
|
1207
|
-
*/
|
|
1208
|
-
telemetryRefreshRate?: number,
|
|
1209
|
-
/**
|
|
1210
|
-
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
1211
|
-
* @property {number} segmentsRefreshRate
|
|
1212
|
-
* @default 60
|
|
1213
|
-
*/
|
|
1214
|
-
segmentsRefreshRate?: number,
|
|
1215
|
-
/**
|
|
1216
|
-
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
1217
|
-
* @property {number} eventsPushRate
|
|
1218
|
-
* @default 60
|
|
1219
|
-
*/
|
|
1220
|
-
eventsPushRate?: number,
|
|
1221
|
-
/**
|
|
1222
|
-
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
1223
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
1224
|
-
* @property {number} eventsQueueSize
|
|
1225
|
-
* @default 500
|
|
1226
|
-
*/
|
|
1227
|
-
eventsQueueSize?: number,
|
|
1228
|
-
/**
|
|
1229
|
-
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
1230
|
-
* For more information see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
|
|
1231
|
-
* @property {number} offlineRefreshRate
|
|
1232
|
-
* @default 15
|
|
1233
|
-
*/
|
|
1234
|
-
offlineRefreshRate?: number
|
|
1235
|
-
/**
|
|
1236
|
-
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
1237
|
-
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
1238
|
-
* @property {number} pushRetryBackoffBase
|
|
1239
|
-
* @default 1
|
|
1240
|
-
*/
|
|
1241
|
-
pushRetryBackoffBase?: number,
|
|
1242
|
-
},
|
|
1243
|
-
/**
|
|
1244
|
-
* SDK Core settings for NodeJS.
|
|
1245
|
-
* @property {Object} core
|
|
1246
|
-
*/
|
|
1247
|
-
core: {
|
|
1248
|
-
/**
|
|
1249
|
-
* Your SDK key.
|
|
1250
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
1251
|
-
* @property {string} authorizationKey
|
|
1252
|
-
*/
|
|
1253
|
-
authorizationKey: string,
|
|
1254
|
-
/**
|
|
1255
|
-
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
1256
|
-
* @property {boolean} labelsEnabled
|
|
1257
|
-
* @default true
|
|
1258
|
-
*/
|
|
1259
|
-
labelsEnabled?: boolean
|
|
1260
|
-
/**
|
|
1261
|
-
* Disable machine IP and Name from being sent to Split backend.
|
|
1262
|
-
* @property {boolean} IPAddressesEnabled
|
|
1263
|
-
* @default true
|
|
1264
|
-
*/
|
|
1265
|
-
IPAddressesEnabled?: boolean
|
|
1266
|
-
},
|
|
1267
|
-
/**
|
|
1268
|
-
* Defines which kind of storage we should instantiate.
|
|
1269
|
-
* @property {Object} storage
|
|
1270
|
-
*/
|
|
1271
|
-
storage?: {
|
|
1272
|
-
/**
|
|
1273
|
-
* Storage type to be instantiated by the SDK.
|
|
1274
|
-
* @property {StorageType} type
|
|
1275
|
-
* @default 'MEMORY'
|
|
1276
|
-
*/
|
|
1277
|
-
type?: StorageType,
|
|
1278
|
-
/**
|
|
1279
|
-
* Options to be passed to the selected storage.
|
|
1280
|
-
* @property {Object} options
|
|
1209
|
+
* @defaultValue `500`
|
|
1281
1210
|
*/
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
1285
|
-
* @property {string} prefix
|
|
1286
|
-
* @default 'SPLITIO'
|
|
1287
|
-
*/
|
|
1288
|
-
prefix?: string
|
|
1289
|
-
},
|
|
1290
|
-
/**
|
|
1291
|
-
* The SDK mode. Possible values are "standalone", which is the default when using a synchronous storage, like 'MEMORY' and 'LOCALSTORAGE',
|
|
1292
|
-
* and "consumer", which must be set when using an asynchronous storage, like 'REDIS'. For "localhost" mode, use "localhost" as authorizationKey.
|
|
1293
|
-
* @property {SDKMode} mode
|
|
1294
|
-
* @default 'standalone'
|
|
1295
|
-
*/
|
|
1296
|
-
mode?: SDKMode,
|
|
1297
|
-
/**
|
|
1298
|
-
* Mocked features file path. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
1299
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
|
|
1300
|
-
* @property {MockedFeaturesFilePath} features
|
|
1301
|
-
* @default '$HOME/.split'
|
|
1302
|
-
*/
|
|
1303
|
-
features?: SplitIO.MockedFeaturesFilePath,
|
|
1211
|
+
eventsQueueSize?: number;
|
|
1212
|
+
};
|
|
1304
1213
|
}
|
|
1305
1214
|
/**
|
|
1306
|
-
* Settings interface for SDK instances created on the browser
|
|
1307
|
-
*
|
|
1308
|
-
* @extends ISharedSettings
|
|
1215
|
+
* Settings interface for JavaScript SDK instances created on the browser, with client-side API and synchronous storage (e.g., in-memory or local storage).
|
|
1216
|
+
*
|
|
1309
1217
|
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
|
|
1310
1218
|
*/
|
|
1311
|
-
interface IBrowserSettings extends
|
|
1312
|
-
/**
|
|
1313
|
-
* SDK Startup settings for the Browser.
|
|
1314
|
-
* @property {Object} startup
|
|
1315
|
-
*/
|
|
1316
|
-
startup?: {
|
|
1317
|
-
/**
|
|
1318
|
-
* Maximum amount of time used before notify a timeout.
|
|
1319
|
-
* @property {number} readyTimeout
|
|
1320
|
-
* @default 1.5
|
|
1321
|
-
*/
|
|
1322
|
-
readyTimeout?: number,
|
|
1323
|
-
/**
|
|
1324
|
-
* Time to wait for a request before the SDK is ready. If this time expires, JS Sdk will retry 'retriesOnFailureBeforeReady' times before notifying its failure to be 'ready'.
|
|
1325
|
-
* @property {number} requestTimeoutBeforeReady
|
|
1326
|
-
* @default 1.5
|
|
1327
|
-
*/
|
|
1328
|
-
requestTimeoutBeforeReady?: number,
|
|
1329
|
-
/**
|
|
1330
|
-
* How many quick retries we will do while starting up the SDK.
|
|
1331
|
-
* @property {number} retriesOnFailureBeforeReady
|
|
1332
|
-
* @default 1
|
|
1333
|
-
*/
|
|
1334
|
-
retriesOnFailureBeforeReady?: number,
|
|
1335
|
-
/**
|
|
1336
|
-
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
1337
|
-
* to better control on browsers. This number defines that window before the first events push.
|
|
1338
|
-
*
|
|
1339
|
-
* @property {number} eventsFirstPushWindow
|
|
1340
|
-
* @default 10
|
|
1341
|
-
*/
|
|
1342
|
-
eventsFirstPushWindow?: number,
|
|
1343
|
-
},
|
|
1344
|
-
/**
|
|
1345
|
-
* SDK scheduler settings.
|
|
1346
|
-
* @property {Object} scheduler
|
|
1347
|
-
*/
|
|
1348
|
-
scheduler?: {
|
|
1349
|
-
/**
|
|
1350
|
-
* The SDK polls Split servers for changes to feature flag definitions. This parameter controls this polling period in seconds.
|
|
1351
|
-
* @property {number} featuresRefreshRate
|
|
1352
|
-
* @default 60
|
|
1353
|
-
*/
|
|
1354
|
-
featuresRefreshRate?: number,
|
|
1355
|
-
/**
|
|
1356
|
-
* The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
|
|
1357
|
-
* @property {number} impressionsRefreshRate
|
|
1358
|
-
* @default 60
|
|
1359
|
-
*/
|
|
1360
|
-
impressionsRefreshRate?: number,
|
|
1361
|
-
/**
|
|
1362
|
-
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
1363
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
1364
|
-
* @property {number} impressionsQueueSize
|
|
1365
|
-
* @default 30000
|
|
1366
|
-
*/
|
|
1367
|
-
impressionsQueueSize?: number,
|
|
1368
|
-
/**
|
|
1369
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
1370
|
-
* @property {number} metricsRefreshRate
|
|
1371
|
-
* @default 120
|
|
1372
|
-
* @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
|
|
1373
|
-
*/
|
|
1374
|
-
metricsRefreshRate?: number,
|
|
1375
|
-
/**
|
|
1376
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
1377
|
-
* @property {number} telemetryRefreshRate
|
|
1378
|
-
* @default 3600
|
|
1379
|
-
*/
|
|
1380
|
-
telemetryRefreshRate?: number,
|
|
1381
|
-
/**
|
|
1382
|
-
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
1383
|
-
* @property {number} segmentsRefreshRate
|
|
1384
|
-
* @default 60
|
|
1385
|
-
*/
|
|
1386
|
-
segmentsRefreshRate?: number,
|
|
1387
|
-
/**
|
|
1388
|
-
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
1389
|
-
* @property {number} eventsPushRate
|
|
1390
|
-
* @default 60
|
|
1391
|
-
*/
|
|
1392
|
-
eventsPushRate?: number,
|
|
1393
|
-
/**
|
|
1394
|
-
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
1395
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
1396
|
-
* @property {number} eventsQueueSize
|
|
1397
|
-
* @default 500
|
|
1398
|
-
*/
|
|
1399
|
-
eventsQueueSize?: number,
|
|
1400
|
-
/**
|
|
1401
|
-
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
1402
|
-
* For more information see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
|
|
1403
|
-
* @property {number} offlineRefreshRate
|
|
1404
|
-
* @default 15
|
|
1405
|
-
*/
|
|
1406
|
-
offlineRefreshRate?: number,
|
|
1407
|
-
/**
|
|
1408
|
-
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
1409
|
-
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
1410
|
-
* @property {number} pushRetryBackoffBase
|
|
1411
|
-
* @default 1
|
|
1412
|
-
*/
|
|
1413
|
-
pushRetryBackoffBase?: number,
|
|
1414
|
-
},
|
|
1415
|
-
/**
|
|
1416
|
-
* SDK Core settings for the browser.
|
|
1417
|
-
* @property {Object} core
|
|
1418
|
-
*/
|
|
1419
|
-
core: {
|
|
1420
|
-
/**
|
|
1421
|
-
* Your SDK key.
|
|
1422
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
1423
|
-
* @property {string} authorizationKey
|
|
1424
|
-
*/
|
|
1425
|
-
authorizationKey: string,
|
|
1426
|
-
/**
|
|
1427
|
-
* Customer identifier. Whatever this means to you.
|
|
1428
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1429
|
-
* @property {SplitKey} key
|
|
1430
|
-
*/
|
|
1431
|
-
key: SplitKey,
|
|
1432
|
-
/**
|
|
1433
|
-
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
1434
|
-
* @property {boolean} labelsEnabled
|
|
1435
|
-
* @default true
|
|
1436
|
-
*/
|
|
1437
|
-
labelsEnabled?: boolean
|
|
1438
|
-
},
|
|
1439
|
-
/**
|
|
1440
|
-
* Mocked features map. For testing purposes only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
1441
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
|
|
1442
|
-
*/
|
|
1443
|
-
features?: MockedFeaturesMap,
|
|
1219
|
+
interface IBrowserSettings extends IClientSideSyncSharedSettings, INonPluggableSettings {
|
|
1444
1220
|
/**
|
|
1445
1221
|
* Defines which kind of storage we can instantiate on the browser.
|
|
1446
1222
|
* Possible storage types are 'MEMORY', which is the default, and 'LOCALSTORAGE'.
|
|
1447
|
-
* @property {Object} storage
|
|
1448
1223
|
*/
|
|
1449
1224
|
storage?: {
|
|
1450
1225
|
/**
|
|
1451
1226
|
* Storage type to be instantiated by the SDK.
|
|
1452
|
-
*
|
|
1453
|
-
* @
|
|
1227
|
+
*
|
|
1228
|
+
* @defaultValue `'MEMORY'`
|
|
1454
1229
|
*/
|
|
1455
|
-
type?: BrowserStorage
|
|
1230
|
+
type?: BrowserStorage;
|
|
1456
1231
|
/**
|
|
1457
1232
|
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
1458
|
-
*
|
|
1459
|
-
* @
|
|
1460
|
-
*/
|
|
1461
|
-
prefix?: string
|
|
1462
|
-
},
|
|
1463
|
-
/**
|
|
1464
|
-
* List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
|
|
1465
|
-
* Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
|
|
1466
|
-
* @property {Object} urls
|
|
1467
|
-
*/
|
|
1468
|
-
urls?: UrlSettings,
|
|
1469
|
-
/**
|
|
1470
|
-
* User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
|
|
1471
|
-
* - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
|
|
1472
|
-
* - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
|
|
1473
|
-
* - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends
|
|
1474
|
-
* them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method.
|
|
1475
|
-
*
|
|
1476
|
-
* @typedef {string} userConsent
|
|
1477
|
-
* @default 'GRANTED'
|
|
1478
|
-
*/
|
|
1479
|
-
userConsent?: ConsentStatus,
|
|
1480
|
-
sync?: ISharedSettings['sync'] & {
|
|
1481
|
-
/**
|
|
1482
|
-
* Custom options object for HTTP(S) requests in the Browser.
|
|
1483
|
-
* If provided, this object is merged with the options object passed by the SDK for EventSource and Fetch calls.
|
|
1233
|
+
*
|
|
1234
|
+
* @defaultValue `'SPLITIO'`
|
|
1484
1235
|
*/
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
* Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
|
|
1488
|
-
* Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
|
|
1489
|
-
* To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
|
|
1490
|
-
* Or provide keys with different case since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
|
|
1491
|
-
*
|
|
1492
|
-
* NOTE: to pass custom headers to the streaming connection in Browser, you should polyfill the `window.EventSource` object with a library that supports headers,
|
|
1493
|
-
* like https://www.npmjs.com/package/event-source-polyfill, since native EventSource does not support them and will be ignored.
|
|
1494
|
-
*
|
|
1495
|
-
* @property getHeaderOverrides
|
|
1496
|
-
* @default undefined
|
|
1497
|
-
*
|
|
1498
|
-
* @param context - The context for the request.
|
|
1499
|
-
* @param context.headers - The current headers in the request.
|
|
1500
|
-
* @returns A set of headers to be merged with the current headers.
|
|
1501
|
-
*
|
|
1502
|
-
* @example
|
|
1503
|
-
* const getHeaderOverrides = (context) => {
|
|
1504
|
-
* return {
|
|
1505
|
-
* 'Authorization': context.headers['Authorization'] + ', other-value',
|
|
1506
|
-
* 'custom-header': 'custom-value'
|
|
1507
|
-
* };
|
|
1508
|
-
* };
|
|
1509
|
-
*/
|
|
1510
|
-
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>
|
|
1511
|
-
},
|
|
1512
|
-
}
|
|
1236
|
+
prefix?: string;
|
|
1237
|
+
};
|
|
1513
1238
|
}
|
|
1514
1239
|
/**
|
|
1515
|
-
* Settings interface for SDK instances created on NodeJS.
|
|
1240
|
+
* Settings interface for JavaScript SDK instances created on NodeJS, with server-side API and synchronous in-memory storage.
|
|
1516
1241
|
* If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
|
|
1517
|
-
*
|
|
1518
|
-
* @extends INodeBasicSettings
|
|
1242
|
+
*
|
|
1519
1243
|
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
|
|
1520
1244
|
*/
|
|
1521
|
-
interface INodeSettings extends
|
|
1522
|
-
/**
|
|
1523
|
-
* List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
|
|
1524
|
-
* Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
|
|
1525
|
-
* @property {Object} urls
|
|
1526
|
-
*/
|
|
1527
|
-
urls?: UrlSettings,
|
|
1245
|
+
interface INodeSettings extends IServerSideSharedSettings, ISyncSharedSettings, INonPluggableSettings {
|
|
1528
1246
|
/**
|
|
1529
1247
|
* Defines which kind of storage we can instantiate on NodeJS for 'standalone' mode.
|
|
1530
1248
|
* The only possible storage type is 'MEMORY', which is the default.
|
|
1531
|
-
* @property {Object} storage
|
|
1532
1249
|
*/
|
|
1533
1250
|
storage?: {
|
|
1534
1251
|
/**
|
|
1535
1252
|
* Synchronous storage type to be instantiated by the SDK.
|
|
1536
|
-
*
|
|
1537
|
-
* @
|
|
1253
|
+
*
|
|
1254
|
+
* @defaultValue `'MEMORY'`
|
|
1538
1255
|
*/
|
|
1539
|
-
type?: NodeSyncStorage
|
|
1256
|
+
type?: NodeSyncStorage;
|
|
1540
1257
|
/**
|
|
1541
1258
|
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
1542
|
-
*
|
|
1543
|
-
* @
|
|
1259
|
+
*
|
|
1260
|
+
* @defaultValue `'SPLITIO'`
|
|
1544
1261
|
*/
|
|
1545
|
-
prefix?: string
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
* The SDK mode. When using the default 'MEMORY' storage, the only possible value is "standalone", which is the default.
|
|
1549
|
-
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
1550
|
-
*
|
|
1551
|
-
* @property {'standalone'} mode
|
|
1552
|
-
* @default 'standalone'
|
|
1553
|
-
*/
|
|
1554
|
-
mode?: 'standalone'
|
|
1555
|
-
sync?: INodeBasicSettings['sync'] & {
|
|
1262
|
+
prefix?: string;
|
|
1263
|
+
};
|
|
1264
|
+
sync?: ISyncSharedSettings['sync'] & {
|
|
1556
1265
|
/**
|
|
1557
1266
|
* Custom options object for HTTP(S) requests in NodeJS.
|
|
1558
1267
|
* If provided, this object is merged with the options object passed by the SDK for EventSource and Node-Fetch calls.
|
|
@@ -1563,24 +1272,24 @@ declare namespace SplitIO {
|
|
|
1563
1272
|
* Custom function called before each request, allowing you to add or update headers in SDK HTTP requests.
|
|
1564
1273
|
* Some headers, such as `SplitSDKVersion`, are required by the SDK and cannot be overridden.
|
|
1565
1274
|
* To pass multiple headers with the same name, combine their values into a single line, separated by commas. Example: `{ 'Authorization': 'value1, value2' }`
|
|
1566
|
-
* Or provide keys with different
|
|
1275
|
+
* Or provide keys with different cases since headers are case-insensitive. Example: `{ 'authorization': 'value1', 'Authorization': 'value2' }`
|
|
1567
1276
|
*
|
|
1568
|
-
* @
|
|
1569
|
-
* @default undefined
|
|
1277
|
+
* @defaultValue `undefined`
|
|
1570
1278
|
*
|
|
1571
|
-
* @param context - The context for the request.
|
|
1572
|
-
* @
|
|
1573
|
-
* @returns A set of headers to be merged with the current headers.
|
|
1279
|
+
* @param context - The context for the request, which contains the `headers` property object representing the current headers in the request.
|
|
1280
|
+
* @returns An object representing a set of headers to be merged with the current headers.
|
|
1574
1281
|
*
|
|
1575
1282
|
* @example
|
|
1283
|
+
* ```
|
|
1576
1284
|
* const getHeaderOverrides = (context) => {
|
|
1577
1285
|
* return {
|
|
1578
1286
|
* 'Authorization': context.headers['Authorization'] + ', other-value',
|
|
1579
1287
|
* 'custom-header': 'custom-value'
|
|
1580
1288
|
* };
|
|
1581
1289
|
* };
|
|
1290
|
+
* ```
|
|
1582
1291
|
*/
|
|
1583
|
-
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string
|
|
1292
|
+
getHeaderOverrides?: (context: { headers: Record<string, string> }) => Record<string, string>;
|
|
1584
1293
|
/**
|
|
1585
1294
|
* Custom NodeJS HTTP(S) Agent used by the SDK for HTTP(S) requests.
|
|
1586
1295
|
*
|
|
@@ -1603,35 +1312,36 @@ declare namespace SplitIO {
|
|
|
1603
1312
|
*
|
|
1604
1313
|
* @see {@link https://nodejs.org/api/https.html#class-httpsagent}
|
|
1605
1314
|
*
|
|
1606
|
-
* @
|
|
1607
|
-
* @default undefined
|
|
1315
|
+
* @defaultValue `undefined`
|
|
1608
1316
|
*/
|
|
1609
|
-
agent?: RequestOptions[
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1317
|
+
agent?: RequestOptions['agent'];
|
|
1318
|
+
};
|
|
1319
|
+
};
|
|
1612
1320
|
}
|
|
1613
1321
|
/**
|
|
1614
|
-
* Settings interface
|
|
1615
|
-
* If your storage is synchronous (by
|
|
1616
|
-
*
|
|
1617
|
-
* @extends INodeBasicSettings
|
|
1322
|
+
* Settings interface for JavaScript SDK instances created on NodeJS, with asynchronous storage like Redis.
|
|
1323
|
+
* If your storage is synchronous (by default we use memory, which is sync) use SplitIO.INodeSettings instead.
|
|
1324
|
+
*
|
|
1618
1325
|
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
|
|
1619
1326
|
*/
|
|
1620
|
-
interface INodeAsyncSettings extends
|
|
1327
|
+
interface INodeAsyncSettings extends IServerSideSharedSettings, ISharedSettings, INonPluggableSettings {
|
|
1328
|
+
/**
|
|
1329
|
+
* The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
|
|
1330
|
+
*
|
|
1331
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
|
|
1332
|
+
*/
|
|
1333
|
+
mode: 'consumer';
|
|
1621
1334
|
/**
|
|
1622
1335
|
* Defines which kind of async storage we can instantiate on NodeJS for 'consumer' mode.
|
|
1623
1336
|
* The only possible storage type is 'REDIS'.
|
|
1624
|
-
* @property {Object} storage
|
|
1625
1337
|
*/
|
|
1626
1338
|
storage: {
|
|
1627
1339
|
/**
|
|
1628
1340
|
* 'REDIS' storage type to be instantiated by the SDK.
|
|
1629
|
-
* @property {NodeAsyncStorage} type
|
|
1630
1341
|
*/
|
|
1631
|
-
type: NodeAsyncStorage
|
|
1342
|
+
type: NodeAsyncStorage;
|
|
1632
1343
|
/**
|
|
1633
1344
|
* Options to be passed to the Redis storage. Use it with storage type: 'REDIS'.
|
|
1634
|
-
* @property {Object} options
|
|
1635
1345
|
*/
|
|
1636
1346
|
options?: {
|
|
1637
1347
|
/**
|
|
@@ -1643,650 +1353,578 @@ declare namespace SplitIO {
|
|
|
1643
1353
|
* url: '127.0.0.1:6379'
|
|
1644
1354
|
* url: 'redis://:authpassword@127.0.0.1:6379/0'
|
|
1645
1355
|
* ```
|
|
1646
|
-
* @property {string=} url
|
|
1647
1356
|
*/
|
|
1648
|
-
url?: string
|
|
1357
|
+
url?: string;
|
|
1649
1358
|
/**
|
|
1650
1359
|
* Redis host.
|
|
1651
|
-
*
|
|
1652
|
-
* @
|
|
1360
|
+
*
|
|
1361
|
+
* @defaultValue `'localhost'`
|
|
1653
1362
|
*/
|
|
1654
|
-
host?: string
|
|
1363
|
+
host?: string;
|
|
1655
1364
|
/**
|
|
1656
1365
|
* Redis port.
|
|
1657
|
-
*
|
|
1658
|
-
* @
|
|
1366
|
+
*
|
|
1367
|
+
* @defaultValue `6379`
|
|
1659
1368
|
*/
|
|
1660
|
-
port?: number
|
|
1369
|
+
port?: number;
|
|
1661
1370
|
/**
|
|
1662
1371
|
* Redis database to be used.
|
|
1663
|
-
*
|
|
1664
|
-
* @
|
|
1372
|
+
*
|
|
1373
|
+
* @defaultValue `0`
|
|
1665
1374
|
*/
|
|
1666
|
-
db?: number
|
|
1375
|
+
db?: number;
|
|
1667
1376
|
/**
|
|
1668
1377
|
* Redis password. Don't define if no password is used.
|
|
1669
|
-
*
|
|
1670
|
-
* @
|
|
1378
|
+
*
|
|
1379
|
+
* @defaultValue `undefined`
|
|
1671
1380
|
*/
|
|
1672
|
-
pass?: string
|
|
1381
|
+
pass?: string;
|
|
1673
1382
|
/**
|
|
1674
1383
|
* The milliseconds before a timeout occurs during the initial connection to the Redis server.
|
|
1675
|
-
*
|
|
1676
|
-
* @
|
|
1384
|
+
*
|
|
1385
|
+
* @defaultValue `10000`
|
|
1677
1386
|
*/
|
|
1678
|
-
connectionTimeout?: number
|
|
1387
|
+
connectionTimeout?: number;
|
|
1679
1388
|
/**
|
|
1680
1389
|
* The milliseconds before Redis commands are timeout by the SDK.
|
|
1681
1390
|
* Method calls that involve Redis commands, like `client.getTreatment` or `client.track` calls, are resolved when the commands success or timeout.
|
|
1682
|
-
*
|
|
1683
|
-
* @
|
|
1391
|
+
*
|
|
1392
|
+
* @defaultValue `5000`
|
|
1684
1393
|
*/
|
|
1685
|
-
operationTimeout?: number
|
|
1394
|
+
operationTimeout?: number;
|
|
1686
1395
|
/**
|
|
1687
1396
|
* TLS configuration for Redis connection.
|
|
1688
1397
|
* @see {@link https://www.npmjs.com/package/ioredis#tls-options }
|
|
1689
1398
|
*
|
|
1690
|
-
* @
|
|
1691
|
-
* @default undefined
|
|
1399
|
+
* @defaultValue `undefined`
|
|
1692
1400
|
*/
|
|
1693
|
-
tls?: RedisOptions['tls']
|
|
1694
|
-
}
|
|
1401
|
+
tls?: RedisOptions['tls'];
|
|
1402
|
+
};
|
|
1695
1403
|
/**
|
|
1696
1404
|
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
1697
|
-
*
|
|
1698
|
-
* @
|
|
1405
|
+
*
|
|
1406
|
+
* @defaultValue `'SPLITIO'`
|
|
1699
1407
|
*/
|
|
1700
|
-
prefix?: string
|
|
1701
|
-
}
|
|
1702
|
-
/**
|
|
1703
|
-
* The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
|
|
1704
|
-
*
|
|
1705
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
|
|
1706
|
-
*
|
|
1707
|
-
* @property {'consumer'} mode
|
|
1708
|
-
*/
|
|
1709
|
-
mode: 'consumer'
|
|
1408
|
+
prefix?: string;
|
|
1409
|
+
};
|
|
1710
1410
|
}
|
|
1711
1411
|
/**
|
|
1712
1412
|
* This represents the interface for the SDK instance with synchronous storage and client-side API,
|
|
1713
1413
|
* i.e., where client instances have a bound user key.
|
|
1714
|
-
* @interface ISDK
|
|
1715
|
-
* @extends IBasicSDK
|
|
1716
1414
|
*/
|
|
1717
|
-
interface
|
|
1415
|
+
interface IBrowserSDK extends IBasicSDK {
|
|
1718
1416
|
/**
|
|
1719
1417
|
* Returns the default client instance of the SDK, associated with the key provided on settings.
|
|
1720
|
-
*
|
|
1721
|
-
* @returns
|
|
1418
|
+
*
|
|
1419
|
+
* @returns The client instance.
|
|
1722
1420
|
*/
|
|
1723
|
-
client():
|
|
1421
|
+
client(): IBrowserClient;
|
|
1724
1422
|
/**
|
|
1725
1423
|
* Returns a shared client of the SDK, associated with the given key.
|
|
1726
|
-
* @
|
|
1727
|
-
* @
|
|
1728
|
-
* @returns {IClient} The client instance.
|
|
1424
|
+
* @param key - The key for the new client instance.
|
|
1425
|
+
* @returns The client instance.
|
|
1729
1426
|
*/
|
|
1730
|
-
client(key: SplitKey):
|
|
1427
|
+
client(key: SplitKey): IBrowserClient;
|
|
1731
1428
|
/**
|
|
1732
1429
|
* Returns a manager instance of the SDK to explore available information.
|
|
1733
|
-
*
|
|
1734
|
-
* @returns
|
|
1430
|
+
*
|
|
1431
|
+
* @returns The manager instance.
|
|
1735
1432
|
*/
|
|
1736
1433
|
manager(): IManager;
|
|
1737
1434
|
/**
|
|
1738
1435
|
* User consent API.
|
|
1739
|
-
* @property UserConsent
|
|
1740
1436
|
*/
|
|
1741
1437
|
UserConsent: IUserConsentAPI;
|
|
1742
1438
|
}
|
|
1743
1439
|
/**
|
|
1744
1440
|
* This represents the interface for the SDK instance with asynchronous storage and client-side API,
|
|
1745
1441
|
* i.e., where client instances have a bound user key.
|
|
1746
|
-
* @interface IAsyncSDK
|
|
1747
|
-
* @extends IBasicSDK
|
|
1748
1442
|
*/
|
|
1749
|
-
interface
|
|
1443
|
+
interface IBrowserAsyncSDK extends IBasicSDK {
|
|
1750
1444
|
/**
|
|
1751
1445
|
* Returns the default client instance of the SDK, associated with the key provided on settings.
|
|
1752
|
-
*
|
|
1753
|
-
* @returns
|
|
1446
|
+
*
|
|
1447
|
+
* @returns The asynchronous client instance.
|
|
1754
1448
|
*/
|
|
1755
|
-
client():
|
|
1449
|
+
client(): IBrowserAsyncClient;
|
|
1756
1450
|
/**
|
|
1757
1451
|
* Returns a shared client of the SDK, associated with the given key.
|
|
1758
|
-
*
|
|
1759
|
-
* @param
|
|
1760
|
-
* @returns
|
|
1452
|
+
*
|
|
1453
|
+
* @param key - The key for the new client instance.
|
|
1454
|
+
* @returns The asynchronous client instance.
|
|
1761
1455
|
*/
|
|
1762
|
-
client(key: SplitKey):
|
|
1456
|
+
client(key: SplitKey): IBrowserAsyncClient;
|
|
1763
1457
|
/**
|
|
1764
1458
|
* Returns a manager instance of the SDK to explore available information.
|
|
1765
|
-
*
|
|
1766
|
-
* @returns
|
|
1459
|
+
*
|
|
1460
|
+
* @returns The manager instance.
|
|
1767
1461
|
*/
|
|
1768
1462
|
manager(): IAsyncManager;
|
|
1769
1463
|
/**
|
|
1770
1464
|
* User consent API.
|
|
1771
|
-
* @property UserConsent
|
|
1772
1465
|
*/
|
|
1773
1466
|
UserConsent: IUserConsentAPI;
|
|
1774
1467
|
}
|
|
1775
1468
|
/**
|
|
1776
1469
|
* This represents the interface for the SDK instance for server-side with synchronous storage.
|
|
1777
|
-
* @interface INodeSDK
|
|
1778
|
-
* @extends IBasicSDK
|
|
1779
1470
|
*/
|
|
1780
|
-
interface
|
|
1471
|
+
interface ISDK extends IBasicSDK {
|
|
1781
1472
|
/**
|
|
1782
1473
|
* Returns the default client instance of the SDK.
|
|
1783
|
-
*
|
|
1784
|
-
* @returns
|
|
1474
|
+
*
|
|
1475
|
+
* @returns The client instance.
|
|
1785
1476
|
*/
|
|
1786
|
-
client():
|
|
1477
|
+
client(): IClient;
|
|
1787
1478
|
/**
|
|
1788
1479
|
* Returns a manager instance of the SDK to explore available information.
|
|
1789
|
-
*
|
|
1790
|
-
* @returns
|
|
1480
|
+
*
|
|
1481
|
+
* @returns The manager instance.
|
|
1791
1482
|
*/
|
|
1792
1483
|
manager(): IManager;
|
|
1793
1484
|
}
|
|
1794
1485
|
/**
|
|
1795
1486
|
* This represents the interface for the SDK instance for server-side with asynchronous storage.
|
|
1796
|
-
* @interface INodeAsyncSDK
|
|
1797
|
-
* @extends IBasicSDK
|
|
1798
1487
|
*/
|
|
1799
|
-
interface
|
|
1488
|
+
interface IAsyncSDK extends IBasicSDK {
|
|
1800
1489
|
/**
|
|
1801
1490
|
* Returns the default client instance of the SDK.
|
|
1802
|
-
*
|
|
1803
|
-
* @returns
|
|
1491
|
+
*
|
|
1492
|
+
* @returns The asynchronous client instance.
|
|
1804
1493
|
*/
|
|
1805
|
-
client():
|
|
1494
|
+
client(): IAsyncClient;
|
|
1806
1495
|
/**
|
|
1807
1496
|
* Returns a manager instance of the SDK to explore available information.
|
|
1808
|
-
*
|
|
1809
|
-
* @returns
|
|
1497
|
+
*
|
|
1498
|
+
* @returns The manager instance.
|
|
1810
1499
|
*/
|
|
1811
1500
|
manager(): IAsyncManager;
|
|
1812
1501
|
}
|
|
1813
1502
|
/**
|
|
1814
1503
|
* This represents the interface for the Client instance on server-side, where the user key is not bound to the instance and must be provided on each method call.
|
|
1815
1504
|
* This interface is available in NodeJS, or when importing the 'server' sub-package of JS SDK (e.g., `import { SplitFactory } from '@splitsoftware/splitio/server'`).
|
|
1816
|
-
*
|
|
1817
|
-
* @interface INodeClient
|
|
1818
|
-
* @extends IBasicClient
|
|
1819
1505
|
*/
|
|
1820
|
-
interface
|
|
1506
|
+
interface IClient extends IBasicClient {
|
|
1821
1507
|
/**
|
|
1822
1508
|
* Returns a Treatment value, which is the treatment string for the given feature.
|
|
1823
1509
|
*
|
|
1824
|
-
* @
|
|
1825
|
-
* @param
|
|
1826
|
-
* @param
|
|
1827
|
-
* @
|
|
1828
|
-
* @returns {Treatment} The treatment string.
|
|
1510
|
+
* @param key - The string key representing the consumer.
|
|
1511
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1512
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1513
|
+
* @returns The treatment string.
|
|
1829
1514
|
*/
|
|
1830
1515
|
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): Treatment;
|
|
1831
1516
|
/**
|
|
1832
1517
|
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1833
1518
|
*
|
|
1834
|
-
* @
|
|
1835
|
-
* @param
|
|
1836
|
-
* @param
|
|
1837
|
-
* @
|
|
1838
|
-
* @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
|
|
1519
|
+
* @param key - The string key representing the consumer.
|
|
1520
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1521
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1522
|
+
* @returns The TreatmentWithConfig, the object containing the treatment string and the
|
|
1839
1523
|
* configuration stringified JSON (or null if there was no config for that treatment).
|
|
1840
1524
|
*/
|
|
1841
1525
|
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
|
|
1842
1526
|
/**
|
|
1843
1527
|
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1844
1528
|
*
|
|
1845
|
-
* @
|
|
1846
|
-
* @param
|
|
1847
|
-
* @param
|
|
1848
|
-
* @
|
|
1849
|
-
* @returns {Treatments} The treatments object map.
|
|
1529
|
+
* @param key - The string key representing the consumer.
|
|
1530
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1531
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1532
|
+
* @returns The treatments object map.
|
|
1850
1533
|
*/
|
|
1851
1534
|
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): Treatments;
|
|
1852
1535
|
/**
|
|
1853
1536
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1854
1537
|
*
|
|
1855
|
-
* @
|
|
1856
|
-
* @param
|
|
1857
|
-
* @param
|
|
1858
|
-
* @
|
|
1859
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1538
|
+
* @param key - The string key representing the consumer.
|
|
1539
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1540
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1541
|
+
* @returns The map with all the TreatmentWithConfig objects
|
|
1860
1542
|
*/
|
|
1861
1543
|
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1862
1544
|
/**
|
|
1863
1545
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1864
1546
|
*
|
|
1865
|
-
* @
|
|
1866
|
-
* @param
|
|
1867
|
-
* @param
|
|
1868
|
-
* @
|
|
1869
|
-
* @returns {Treatments} The map with all the Treatment objects
|
|
1547
|
+
* @param key - The string key representing the consumer.
|
|
1548
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1549
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1550
|
+
* @returns The map with all the Treatment objects
|
|
1870
1551
|
*/
|
|
1871
1552
|
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments;
|
|
1872
1553
|
/**
|
|
1873
1554
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1874
1555
|
*
|
|
1875
|
-
* @
|
|
1876
|
-
* @param
|
|
1877
|
-
* @param
|
|
1878
|
-
* @
|
|
1879
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1556
|
+
* @param key - The string key representing the consumer.
|
|
1557
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1558
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1559
|
+
* @returns The map with all the TreatmentWithConfig objects
|
|
1880
1560
|
*/
|
|
1881
1561
|
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
|
|
1882
1562
|
/**
|
|
1883
1563
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1884
1564
|
*
|
|
1885
|
-
* @
|
|
1886
|
-
* @param
|
|
1887
|
-
* @param
|
|
1888
|
-
* @
|
|
1889
|
-
* @returns {Treatments} The map with all the Treatment objects
|
|
1565
|
+
* @param key - The string key representing the consumer.
|
|
1566
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1567
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1568
|
+
* @returns The map with all the Treatment objects
|
|
1890
1569
|
*/
|
|
1891
1570
|
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments;
|
|
1892
1571
|
/**
|
|
1893
1572
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1894
1573
|
*
|
|
1895
|
-
* @
|
|
1896
|
-
* @param
|
|
1897
|
-
* @param
|
|
1898
|
-
* @
|
|
1899
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1574
|
+
* @param key - The string key representing the consumer.
|
|
1575
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1576
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1577
|
+
* @returns The map with all the TreatmentWithConfig objects
|
|
1900
1578
|
*/
|
|
1901
1579
|
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
1902
1580
|
/**
|
|
1903
1581
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
1904
1582
|
*
|
|
1905
|
-
* @
|
|
1906
|
-
* @param
|
|
1907
|
-
* @param
|
|
1908
|
-
* @param
|
|
1909
|
-
* @param
|
|
1910
|
-
* @
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean;
|
|
1583
|
+
* @param key - The key that identifies the entity related to this event.
|
|
1584
|
+
* @param trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1585
|
+
* @param eventType - The event type corresponding to this event.
|
|
1586
|
+
* @param value - The value of this event.
|
|
1587
|
+
* @param properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1588
|
+
* @returns Whether the event was added to the queue successfully or not.
|
|
1589
|
+
*/
|
|
1590
|
+
track(key: SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean;
|
|
1914
1591
|
}
|
|
1915
1592
|
/**
|
|
1916
1593
|
* This represents the interface for the Client instance on server-side with asynchronous storage, like REDIS.
|
|
1917
1594
|
* User key is not bound to the instance and must be provided on each method call, which returns a promise.
|
|
1918
1595
|
* This interface is available in NodeJS, or when importing the 'server' sub-package in JS SDK (e.g., `import { SplitFactory } from '@splitsoftware/splitio/server'`).
|
|
1919
|
-
*
|
|
1920
|
-
* @interface INodeAsyncClient
|
|
1921
|
-
* @extends IBasicClient
|
|
1922
1596
|
*/
|
|
1923
|
-
interface
|
|
1597
|
+
interface IAsyncClient extends IBasicClient {
|
|
1924
1598
|
/**
|
|
1925
1599
|
* Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
|
|
1926
1600
|
*
|
|
1927
|
-
* @
|
|
1928
|
-
* @param
|
|
1929
|
-
* @param
|
|
1930
|
-
* @
|
|
1931
|
-
* @returns {AsyncTreatment} Treatment promise that resolves to the treatment string.
|
|
1601
|
+
* @param key - The string key representing the consumer.
|
|
1602
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1603
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1604
|
+
* @returns Treatment promise that resolves to the treatment string.
|
|
1932
1605
|
*/
|
|
1933
1606
|
getTreatment(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatment;
|
|
1934
1607
|
/**
|
|
1935
1608
|
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1936
1609
|
*
|
|
1937
|
-
* @
|
|
1938
|
-
* @param
|
|
1939
|
-
* @param
|
|
1940
|
-
* @
|
|
1941
|
-
* @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1610
|
+
* @param key - The string key representing the consumer.
|
|
1611
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1612
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1613
|
+
* @returns TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1942
1614
|
*/
|
|
1943
1615
|
getTreatmentWithConfig(key: SplitKey, featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
|
|
1944
1616
|
/**
|
|
1945
1617
|
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1946
1618
|
*
|
|
1947
|
-
* @
|
|
1948
|
-
* @param
|
|
1949
|
-
* @param
|
|
1950
|
-
* @
|
|
1951
|
-
* @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
|
|
1619
|
+
* @param key - The string key representing the consumer.
|
|
1620
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1621
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1622
|
+
* @returns Treatments promise that resolves to the treatments object map.
|
|
1952
1623
|
*/
|
|
1953
1624
|
getTreatments(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
|
|
1954
1625
|
/**
|
|
1955
1626
|
* Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1956
1627
|
*
|
|
1957
|
-
* @
|
|
1958
|
-
* @param
|
|
1959
|
-
* @param
|
|
1960
|
-
* @
|
|
1961
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1628
|
+
* @param key - The string key representing the consumer.
|
|
1629
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1630
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1631
|
+
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1962
1632
|
*/
|
|
1963
1633
|
getTreatmentsWithConfig(key: SplitKey, featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1964
1634
|
/**
|
|
1965
1635
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1966
1636
|
*
|
|
1967
|
-
* @
|
|
1968
|
-
* @param
|
|
1969
|
-
* @param
|
|
1970
|
-
* @
|
|
1971
|
-
* @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
|
|
1637
|
+
* @param key - The string key representing the consumer.
|
|
1638
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1639
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1640
|
+
* @returns Treatments promise that resolves to the treatments object map.
|
|
1972
1641
|
*/
|
|
1973
1642
|
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatments;
|
|
1974
1643
|
/**
|
|
1975
1644
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1976
1645
|
*
|
|
1977
|
-
* @
|
|
1978
|
-
* @param
|
|
1979
|
-
* @param
|
|
1980
|
-
* @
|
|
1981
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1646
|
+
* @param key - The string key representing the consumer.
|
|
1647
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1648
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1649
|
+
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1982
1650
|
*/
|
|
1983
1651
|
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
1984
1652
|
/**
|
|
1985
1653
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1986
1654
|
*
|
|
1987
|
-
* @
|
|
1988
|
-
* @param
|
|
1989
|
-
* @param
|
|
1990
|
-
* @
|
|
1991
|
-
* @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
|
|
1655
|
+
* @param key - The string key representing the consumer.
|
|
1656
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1657
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1658
|
+
* @returns Treatments promise that resolves to the treatments object map.
|
|
1992
1659
|
*/
|
|
1993
1660
|
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatments;
|
|
1994
1661
|
/**
|
|
1995
1662
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1996
1663
|
*
|
|
1997
|
-
* @
|
|
1998
|
-
* @param
|
|
1999
|
-
* @param
|
|
2000
|
-
* @
|
|
2001
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
1664
|
+
* @param key - The string key representing the consumer.
|
|
1665
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1666
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1667
|
+
* @returns TreatmentsWithConfig promise that resolves to the map of TreatmentsWithConfig objects.
|
|
2002
1668
|
*/
|
|
2003
1669
|
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
2004
1670
|
/**
|
|
2005
1671
|
* Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not).
|
|
2006
1672
|
*
|
|
2007
|
-
* @
|
|
2008
|
-
* @param
|
|
2009
|
-
* @param
|
|
2010
|
-
* @param
|
|
2011
|
-
* @param
|
|
2012
|
-
* @
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>;
|
|
1673
|
+
* @param key - The key that identifies the entity related to this event.
|
|
1674
|
+
* @param trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1675
|
+
* @param eventType - The event type corresponding to this event.
|
|
1676
|
+
* @param value - The value of this event.
|
|
1677
|
+
* @param properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1678
|
+
* @returns A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
|
|
1679
|
+
*/
|
|
1680
|
+
track(key: SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>;
|
|
2016
1681
|
}
|
|
2017
1682
|
interface IClientWithAttributes extends IBasicClient {
|
|
2018
1683
|
/**
|
|
2019
|
-
* Add an attribute to client's in
|
|
1684
|
+
* Add an attribute to client's in-memory attributes storage.
|
|
2020
1685
|
*
|
|
2021
|
-
* @param
|
|
2022
|
-
* @param
|
|
2023
|
-
* @returns
|
|
1686
|
+
* @param attributeName - Attribute name
|
|
1687
|
+
* @param attributeValue - Attribute value
|
|
1688
|
+
* @returns true if the attribute was stored and false otherwise
|
|
2024
1689
|
*/
|
|
2025
1690
|
setAttribute(attributeName: string, attributeValue: AttributeType): boolean;
|
|
2026
1691
|
/**
|
|
2027
1692
|
* Returns the attribute with the given name.
|
|
2028
1693
|
*
|
|
2029
|
-
* @param
|
|
2030
|
-
* @returns
|
|
1694
|
+
* @param attributeName - Attribute name
|
|
1695
|
+
* @returns Attribute with the given name
|
|
2031
1696
|
*/
|
|
2032
1697
|
getAttribute(attributeName: string): AttributeType;
|
|
2033
1698
|
/**
|
|
2034
|
-
* Removes from client's in
|
|
1699
|
+
* Removes from client's in-memory attributes storage the attribute with the given name.
|
|
2035
1700
|
*
|
|
2036
|
-
* @param
|
|
2037
|
-
* @returns
|
|
1701
|
+
* @param attributeName - Attribute name
|
|
1702
|
+
* @returns true if attribute was removed and false otherwise
|
|
2038
1703
|
*/
|
|
2039
1704
|
removeAttribute(attributeName: string): boolean;
|
|
2040
1705
|
/**
|
|
2041
|
-
* Add to client's in
|
|
1706
|
+
* Add to client's in-memory attributes storage the attributes in 'attributes'.
|
|
2042
1707
|
*
|
|
2043
|
-
* @param
|
|
1708
|
+
* @param attributes - Object with attributes to store
|
|
2044
1709
|
* @returns true if attributes were stored an false otherwise
|
|
2045
1710
|
*/
|
|
2046
1711
|
setAttributes(attributes: Attributes): boolean;
|
|
2047
1712
|
/**
|
|
2048
|
-
* Return all the attributes stored in client's in
|
|
1713
|
+
* Return all the attributes stored in client's in-memory attributes storage.
|
|
2049
1714
|
*
|
|
2050
|
-
* @returns
|
|
1715
|
+
* @returns returns all the stored attributes
|
|
2051
1716
|
*/
|
|
2052
1717
|
getAttributes(): Attributes;
|
|
2053
1718
|
/**
|
|
2054
|
-
* Remove all the stored attributes in the client's in
|
|
1719
|
+
* Remove all the stored attributes in the client's in-memory attribute storage.
|
|
2055
1720
|
*
|
|
2056
|
-
* @returns
|
|
1721
|
+
* @returns true if all attribute were removed and false otherwise
|
|
2057
1722
|
*/
|
|
2058
1723
|
clearAttributes(): boolean;
|
|
2059
1724
|
}
|
|
2060
1725
|
/**
|
|
2061
1726
|
* This represents the interface for the Client instance on client-side, where the user key is bound to the instance on creation and does not need to be provided on each method call.
|
|
2062
|
-
*
|
|
2063
|
-
* @interface IClient
|
|
2064
|
-
* @extends IClientWithAttributes
|
|
2065
1727
|
*/
|
|
2066
|
-
interface
|
|
1728
|
+
interface IBrowserClient extends IClientWithAttributes {
|
|
2067
1729
|
/**
|
|
2068
1730
|
* Returns a Treatment value, which is the treatment string for the given feature.
|
|
2069
1731
|
*
|
|
2070
|
-
* @
|
|
2071
|
-
* @param
|
|
2072
|
-
* @
|
|
2073
|
-
* @returns {Treatment} The treatment string.
|
|
1732
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1733
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1734
|
+
* @returns The treatment string.
|
|
2074
1735
|
*/
|
|
2075
1736
|
getTreatment(featureFlagName: string, attributes?: Attributes): Treatment;
|
|
2076
1737
|
/**
|
|
2077
1738
|
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
2078
1739
|
*
|
|
2079
|
-
* @
|
|
2080
|
-
* @param
|
|
2081
|
-
* @
|
|
2082
|
-
* @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
|
|
1740
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1741
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1742
|
+
* @returns The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
|
|
2083
1743
|
*/
|
|
2084
1744
|
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): TreatmentWithConfig;
|
|
2085
1745
|
/**
|
|
2086
1746
|
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
2087
1747
|
*
|
|
2088
|
-
* @
|
|
2089
|
-
* @param
|
|
2090
|
-
* @
|
|
2091
|
-
* @returns {Treatments} The treatments object map.
|
|
1748
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1749
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1750
|
+
* @returns The treatments object map.
|
|
2092
1751
|
*/
|
|
2093
1752
|
getTreatments(featureFlagNames: string[], attributes?: Attributes): Treatments;
|
|
2094
1753
|
/**
|
|
2095
1754
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
2096
1755
|
*
|
|
2097
|
-
* @
|
|
2098
|
-
* @param
|
|
2099
|
-
* @
|
|
2100
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1756
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1757
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1758
|
+
* @returns The map with all the TreatmentWithConfig objects
|
|
2101
1759
|
*/
|
|
2102
1760
|
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
2103
1761
|
/**
|
|
2104
1762
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
2105
1763
|
*
|
|
2106
|
-
* @
|
|
2107
|
-
* @param
|
|
2108
|
-
* @
|
|
2109
|
-
* @returns {Treatments} The map with all the Treatments objects
|
|
1764
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1765
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1766
|
+
* @returns The map with all the Treatments objects
|
|
2110
1767
|
*/
|
|
2111
1768
|
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments;
|
|
2112
1769
|
/**
|
|
2113
1770
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
2114
1771
|
*
|
|
2115
|
-
* @
|
|
2116
|
-
* @param
|
|
2117
|
-
* @
|
|
2118
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1772
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1773
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1774
|
+
* @returns The map with all the TreatmentWithConfig objects
|
|
2119
1775
|
*/
|
|
2120
1776
|
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig;
|
|
2121
1777
|
/**
|
|
2122
1778
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
2123
1779
|
*
|
|
2124
|
-
* @
|
|
2125
|
-
* @param
|
|
2126
|
-
* @
|
|
2127
|
-
* @returns {Treatments} The map with all the Treatments objects
|
|
1780
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1781
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1782
|
+
* @returns The map with all the Treatments objects
|
|
2128
1783
|
*/
|
|
2129
1784
|
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments;
|
|
2130
1785
|
/**
|
|
2131
1786
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
2132
1787
|
*
|
|
2133
|
-
* @
|
|
2134
|
-
* @param
|
|
2135
|
-
* @
|
|
2136
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1788
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1789
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1790
|
+
* @returns The map with all the TreatmentWithConfig objects
|
|
2137
1791
|
*/
|
|
2138
1792
|
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig;
|
|
2139
1793
|
/**
|
|
2140
1794
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
2141
1795
|
*
|
|
2142
|
-
* @
|
|
2143
|
-
* @param
|
|
2144
|
-
* @param
|
|
2145
|
-
* @param
|
|
2146
|
-
* @
|
|
2147
|
-
* @returns {boolean} Whether the event was added to the queue successfully or not.
|
|
1796
|
+
* @param trafficType - The traffic type of the entity related to this event. See {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1797
|
+
* @param eventType - The event type corresponding to this event.
|
|
1798
|
+
* @param value - The value of this event.
|
|
1799
|
+
* @param properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1800
|
+
* @returns Whether the event was added to the queue successfully or not.
|
|
2148
1801
|
*/
|
|
2149
1802
|
track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean;
|
|
2150
1803
|
}
|
|
2151
1804
|
/**
|
|
2152
1805
|
* This represents the interface for the Client instance with asynchronous storage for client-side SDK, where each client has associated a key.
|
|
2153
|
-
* @interface IAsyncClient
|
|
2154
|
-
* @extends IClientWithAttributes
|
|
2155
1806
|
*/
|
|
2156
|
-
interface
|
|
1807
|
+
interface IBrowserAsyncClient extends IClientWithAttributes {
|
|
2157
1808
|
/**
|
|
2158
1809
|
* Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
|
|
2159
1810
|
*
|
|
2160
|
-
* @
|
|
2161
|
-
* @param
|
|
2162
|
-
* @
|
|
2163
|
-
* @returns {AsyncTreatment} Treatment promise that resolves to the treatment string.
|
|
1811
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1812
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1813
|
+
* @returns Treatment promise that resolves to the treatment string.
|
|
2164
1814
|
*/
|
|
2165
1815
|
getTreatment(featureFlagName: string, attributes?: Attributes): AsyncTreatment;
|
|
2166
1816
|
/**
|
|
2167
1817
|
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
2168
1818
|
*
|
|
2169
|
-
* @
|
|
2170
|
-
* @param
|
|
2171
|
-
* @
|
|
2172
|
-
* @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
1819
|
+
* @param featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1820
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1821
|
+
* @returns TreatmentWithConfig promise that resolves to the TreatmentWithConfig object.
|
|
2173
1822
|
*/
|
|
2174
1823
|
getTreatmentWithConfig(featureFlagName: string, attributes?: Attributes): AsyncTreatmentWithConfig;
|
|
2175
1824
|
/**
|
|
2176
1825
|
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
2177
1826
|
*
|
|
2178
|
-
* @
|
|
2179
|
-
* @param
|
|
2180
|
-
* @
|
|
2181
|
-
* @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
|
|
1827
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1828
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1829
|
+
* @returns Treatments promise that resolves to the treatments object map.
|
|
2182
1830
|
*/
|
|
2183
1831
|
getTreatments(featureFlagNames: string[], attributes?: Attributes): AsyncTreatments;
|
|
2184
1832
|
/**
|
|
2185
1833
|
* Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
2186
1834
|
*
|
|
2187
|
-
* @
|
|
2188
|
-
* @param
|
|
2189
|
-
* @
|
|
2190
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1835
|
+
* @param featureFlagNames - An array of the feature flag names we want to get the treatments.
|
|
1836
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1837
|
+
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
2191
1838
|
*/
|
|
2192
1839
|
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
2193
1840
|
/**
|
|
2194
1841
|
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
2195
1842
|
*
|
|
2196
|
-
* @
|
|
2197
|
-
* @param
|
|
2198
|
-
* @
|
|
2199
|
-
* @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
|
|
1843
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1844
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1845
|
+
* @returns Treatments promise that resolves to the treatments object map.
|
|
2200
1846
|
*/
|
|
2201
1847
|
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatments;
|
|
2202
1848
|
/**
|
|
2203
1849
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
2204
1850
|
*
|
|
2205
|
-
* @
|
|
2206
|
-
* @param
|
|
2207
|
-
* @
|
|
2208
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1851
|
+
* @param flagSet - The flag set name we want to get the treatments.
|
|
1852
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1853
|
+
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
2209
1854
|
*/
|
|
2210
1855
|
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
2211
1856
|
/**
|
|
2212
1857
|
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
2213
1858
|
*
|
|
2214
|
-
* @
|
|
2215
|
-
* @param
|
|
2216
|
-
* @
|
|
2217
|
-
* @returns {AsyncTreatments} Treatments promise that resolves to the treatments object map.
|
|
1859
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1860
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1861
|
+
* @returns Treatments promise that resolves to the treatments object map.
|
|
2218
1862
|
*/
|
|
2219
1863
|
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatments;
|
|
2220
1864
|
/**
|
|
2221
1865
|
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
2222
1866
|
*
|
|
2223
|
-
* @
|
|
2224
|
-
* @param
|
|
2225
|
-
* @
|
|
2226
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
1867
|
+
* @param flagSets - An array of the flag set names we want to get the treatments.
|
|
1868
|
+
* @param attributes - An object of type Attributes defining the attributes for the given key.
|
|
1869
|
+
* @returns TreatmentsWithConfig promise that resolves to the TreatmentsWithConfig object.
|
|
2227
1870
|
*/
|
|
2228
1871
|
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): AsyncTreatmentsWithConfig;
|
|
2229
1872
|
/**
|
|
2230
1873
|
* Tracks an event to be fed to the results product on Split user interface, and returns a promise to signal when the event was successfully queued (or not).
|
|
2231
1874
|
*
|
|
2232
|
-
* @
|
|
2233
|
-
* @param
|
|
2234
|
-
* @param
|
|
2235
|
-
* @param
|
|
2236
|
-
* @
|
|
2237
|
-
* @returns {boolean} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
|
|
1875
|
+
* @param trafficType - The traffic type of the entity related to this event.
|
|
1876
|
+
* @param eventType - The event type corresponding to this event.
|
|
1877
|
+
* @param value - The value of this event.
|
|
1878
|
+
* @param properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1879
|
+
* @returns A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
|
|
2238
1880
|
*/
|
|
2239
1881
|
track(trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>;
|
|
2240
1882
|
}
|
|
2241
1883
|
/**
|
|
2242
1884
|
* Representation of a manager instance with synchronous storage of the SDK.
|
|
2243
|
-
* @interface IManager
|
|
2244
|
-
* @extends IStatusInterface
|
|
2245
1885
|
*/
|
|
2246
1886
|
interface IManager extends IStatusInterface {
|
|
2247
1887
|
/**
|
|
2248
1888
|
* Get the array of feature flag names.
|
|
2249
|
-
*
|
|
2250
|
-
* @returns
|
|
1889
|
+
*
|
|
1890
|
+
* @returns The list of feature flag names.
|
|
2251
1891
|
*/
|
|
2252
1892
|
names(): SplitNames;
|
|
2253
1893
|
/**
|
|
2254
1894
|
* Get the array of feature flags data in SplitView format.
|
|
2255
|
-
*
|
|
2256
|
-
* @returns
|
|
1895
|
+
*
|
|
1896
|
+
* @returns The list of SplitIO.SplitView.
|
|
2257
1897
|
*/
|
|
2258
1898
|
splits(): SplitViews;
|
|
2259
1899
|
/**
|
|
2260
1900
|
* Get the data of a feature flag in SplitView format.
|
|
2261
|
-
*
|
|
2262
|
-
* @param
|
|
2263
|
-
* @returns
|
|
1901
|
+
*
|
|
1902
|
+
* @param featureFlagName - The name of the feature flag we want to get info of.
|
|
1903
|
+
* @returns The SplitIO.SplitView of the given feature flag name or null if the feature flag is not found.
|
|
2264
1904
|
*/
|
|
2265
1905
|
split(featureFlagName: string): SplitView | null;
|
|
2266
1906
|
}
|
|
2267
1907
|
/**
|
|
2268
1908
|
* Representation of a manager instance with asynchronous storage of the SDK.
|
|
2269
|
-
* @interface IAsyncManager
|
|
2270
|
-
* @extends IStatusInterface
|
|
2271
1909
|
*/
|
|
2272
1910
|
interface IAsyncManager extends IStatusInterface {
|
|
2273
1911
|
/**
|
|
2274
1912
|
* Get the array of feature flag names.
|
|
2275
|
-
*
|
|
2276
|
-
* @returns
|
|
1913
|
+
*
|
|
1914
|
+
* @returns A promise that resolves to the list of feature flag names.
|
|
2277
1915
|
*/
|
|
2278
1916
|
names(): SplitNamesAsync;
|
|
2279
1917
|
/**
|
|
2280
1918
|
* Get the array of feature flags data in SplitView format.
|
|
2281
|
-
*
|
|
2282
|
-
* @returns
|
|
1919
|
+
*
|
|
1920
|
+
* @returns A promise that resolves to the SplitIO.SplitView list.
|
|
2283
1921
|
*/
|
|
2284
1922
|
splits(): SplitViewsAsync;
|
|
2285
1923
|
/**
|
|
2286
1924
|
* Get the data of a feature flag in SplitView format.
|
|
2287
|
-
*
|
|
2288
|
-
* @param
|
|
2289
|
-
* @returns
|
|
1925
|
+
*
|
|
1926
|
+
* @param featureFlagName - The name of the feature flag we want to get info of.
|
|
1927
|
+
* @returns A promise that resolves to the SplitIO.SplitView value.
|
|
2290
1928
|
*/
|
|
2291
1929
|
split(featureFlagName: string): SplitViewAsync;
|
|
2292
1930
|
}
|