@splitsoftware/splitio 10.21.1 → 10.21.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/splitio.d.ts
CHANGED
|
@@ -2,1067 +2,41 @@
|
|
|
2
2
|
// Project: http://www.split.io/
|
|
3
3
|
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
|
|
4
4
|
|
|
5
|
-
/// <reference types="
|
|
6
|
-
import { RedisOptions } from "ioredis";
|
|
5
|
+
/// <reference types="@splitsoftware/splitio-commons/src/types" />
|
|
7
6
|
|
|
8
|
-
export as namespace SplitIO;
|
|
9
|
-
export = SplitIO;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* NodeJS.EventEmitter interface
|
|
13
|
-
* @see {@link https://nodejs.org/api/events.html}
|
|
14
|
-
*/
|
|
15
|
-
interface EventEmitter {
|
|
16
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
17
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
18
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
19
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
20
|
-
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
21
|
-
removeAllListeners(event?: string | symbol): this;
|
|
22
|
-
setMaxListeners(n: number): this;
|
|
23
|
-
getMaxListeners(): number;
|
|
24
|
-
listeners(event: string | symbol): Function[];
|
|
25
|
-
rawListeners(event: string | symbol): Function[];
|
|
26
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
27
|
-
listenerCount(type: string | symbol): number;
|
|
28
|
-
// Added in Node 6...
|
|
29
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
30
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
31
|
-
eventNames(): Array<string | symbol>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @typedef {Object} EventConsts
|
|
35
|
-
* @property {string} SDK_READY The ready event.
|
|
36
|
-
* @property {string} SDK_READY_FROM_CACHE The ready event when fired with cached data.
|
|
37
|
-
* @property {string} SDK_READY_TIMED_OUT The timeout event.
|
|
38
|
-
* @property {string} SDK_UPDATE The update event.
|
|
39
|
-
*/
|
|
40
|
-
type EventConsts = {
|
|
41
|
-
SDK_READY: 'init::ready',
|
|
42
|
-
SDK_READY_FROM_CACHE: 'init::cache-ready',
|
|
43
|
-
SDK_READY_TIMED_OUT: 'init::timeout',
|
|
44
|
-
SDK_UPDATE: 'state::update'
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* SDK Modes.
|
|
48
|
-
* @typedef {string} SDKMode
|
|
49
|
-
*/
|
|
50
|
-
type SDKMode = 'standalone' | 'consumer';
|
|
51
|
-
/**
|
|
52
|
-
* Storage types.
|
|
53
|
-
* @typedef {string} StorageType
|
|
54
|
-
*/
|
|
55
|
-
type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS';
|
|
56
|
-
/**
|
|
57
|
-
* Settings interface. This is a representation of the settings the SDK expose, that's why
|
|
58
|
-
* most of it's props are readonly. Only features should be rewritten when localhost mode is active.
|
|
59
|
-
* @interface ISettings
|
|
60
|
-
*/
|
|
61
|
-
interface ISettings {
|
|
62
|
-
readonly core: {
|
|
63
|
-
authorizationKey: string,
|
|
64
|
-
key: SplitIO.SplitKey,
|
|
65
|
-
trafficType: string,
|
|
66
|
-
labelsEnabled: boolean,
|
|
67
|
-
IPAddressesEnabled: boolean
|
|
68
|
-
},
|
|
69
|
-
readonly mode: SDKMode,
|
|
70
|
-
readonly scheduler: {
|
|
71
|
-
featuresRefreshRate: number,
|
|
72
|
-
impressionsRefreshRate: number,
|
|
73
|
-
impressionsQueueSize: number,
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated
|
|
76
|
-
*/
|
|
77
|
-
metricsRefreshRate?: number,
|
|
78
|
-
telemetryRefreshRate: number,
|
|
79
|
-
segmentsRefreshRate: number,
|
|
80
|
-
offlineRefreshRate: number,
|
|
81
|
-
eventsPushRate: number,
|
|
82
|
-
eventsQueueSize: number,
|
|
83
|
-
pushRetryBackoffBase: number
|
|
84
|
-
},
|
|
85
|
-
readonly startup: {
|
|
86
|
-
readyTimeout: number,
|
|
87
|
-
requestTimeoutBeforeReady: number,
|
|
88
|
-
retriesOnFailureBeforeReady: number,
|
|
89
|
-
eventsFirstPushWindow: number
|
|
90
|
-
},
|
|
91
|
-
readonly storage: {
|
|
92
|
-
prefix: string,
|
|
93
|
-
options: Object,
|
|
94
|
-
type: StorageType
|
|
95
|
-
},
|
|
96
|
-
readonly urls: {
|
|
97
|
-
events: string,
|
|
98
|
-
sdk: string,
|
|
99
|
-
auth: string,
|
|
100
|
-
streaming: string,
|
|
101
|
-
telemetry: string
|
|
102
|
-
},
|
|
103
|
-
readonly debug: boolean | LogLevel,
|
|
104
|
-
readonly version: string,
|
|
105
|
-
/**
|
|
106
|
-
* Mocked features map if using in browser, or mocked features file path string if using in NodeJS.
|
|
107
|
-
*/
|
|
108
|
-
features: SplitIO.MockedFeaturesMap | SplitIO.MockedFeaturesFilePath,
|
|
109
|
-
readonly streamingEnabled: boolean,
|
|
110
|
-
readonly sync: {
|
|
111
|
-
splitFilters: SplitIO.SplitFilter[],
|
|
112
|
-
impressionsMode: SplitIO.ImpressionsMode,
|
|
113
|
-
enabled: boolean
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* User consent status if using in browser. Undefined if using in NodeJS.
|
|
117
|
-
*/
|
|
118
|
-
readonly userConsent?: SplitIO.ConsentStatus
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Log levels.
|
|
122
|
-
* @typedef {string} LogLevel
|
|
123
|
-
*/
|
|
124
|
-
type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE';
|
|
125
|
-
/**
|
|
126
|
-
* Logger API
|
|
127
|
-
* @interface ILoggerAPI
|
|
128
|
-
*/
|
|
129
|
-
interface ILoggerAPI {
|
|
130
|
-
/**
|
|
131
|
-
* Enables SDK logging to the console.
|
|
132
|
-
* @function enable
|
|
133
|
-
* @returns {void}
|
|
134
|
-
*/
|
|
135
|
-
enable(): void,
|
|
136
|
-
/**
|
|
137
|
-
* Disables SDK logging.
|
|
138
|
-
* @function disable
|
|
139
|
-
* @returns {void}
|
|
140
|
-
*/
|
|
141
|
-
disable(): void,
|
|
142
|
-
/**
|
|
143
|
-
* Sets a log level for the SDK logs.
|
|
144
|
-
* @function setLogLevel
|
|
145
|
-
* @returns {void}
|
|
146
|
-
*/
|
|
147
|
-
setLogLevel(logLevel: LogLevel): void,
|
|
148
|
-
/**
|
|
149
|
-
* Log level constants. Use this to pass them to setLogLevel function.
|
|
150
|
-
*/
|
|
151
|
-
LogLevel: {
|
|
152
|
-
[level in LogLevel]: LogLevel
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* User consent API
|
|
157
|
-
* @interface IUserConsentAPI
|
|
158
|
-
*/
|
|
159
|
-
interface IUserConsentAPI {
|
|
160
|
-
/**
|
|
161
|
-
* Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
|
|
162
|
-
* - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
|
|
163
|
-
* - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
|
|
164
|
-
*
|
|
165
|
-
* NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
|
|
166
|
-
*
|
|
167
|
-
* @function setStatus
|
|
168
|
-
* @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
|
|
169
|
-
* @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
|
|
170
|
-
*/
|
|
171
|
-
setStatus(userConsent: boolean): boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Get the user consent status.
|
|
174
|
-
*
|
|
175
|
-
* @function getStatus
|
|
176
|
-
* @returns {ConsentStatus} The user consent status.
|
|
177
|
-
*/
|
|
178
|
-
getStatus(): SplitIO.ConsentStatus;
|
|
179
|
-
/**
|
|
180
|
-
* Consent status constants. Use this to compare with the getStatus function result.
|
|
181
|
-
*/
|
|
182
|
-
Status: {
|
|
183
|
-
[status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Common settings between Browser and NodeJS settings interface.
|
|
188
|
-
* @interface ISharedSettings
|
|
189
|
-
*/
|
|
190
|
-
interface ISharedSettings {
|
|
191
|
-
/**
|
|
192
|
-
* Whether the logger should be enabled or disabled by default.
|
|
193
|
-
* @property {Boolean} debug
|
|
194
|
-
* @default false
|
|
195
|
-
*/
|
|
196
|
-
debug?: boolean | LogLevel,
|
|
197
|
-
/**
|
|
198
|
-
* The impression listener, which is optional. Whatever you provide here needs to comply with the SplitIO.IImpressionListener interface,
|
|
199
|
-
* which will check for the logImpression method.
|
|
200
|
-
* @property {IImpressionListener} impressionListener
|
|
201
|
-
* @default undefined
|
|
202
|
-
*/
|
|
203
|
-
impressionListener?: SplitIO.IImpressionListener,
|
|
204
|
-
/**
|
|
205
|
-
* Boolean flag to enable the streaming service as default synchronization mechanism. In the event of any issue with streaming,
|
|
206
|
-
* the SDK would fallback to the polling mechanism. If false, the SDK would poll for changes as usual without attempting to use streaming.
|
|
207
|
-
* @property {boolean} streamingEnabled
|
|
208
|
-
* @default true
|
|
209
|
-
*/
|
|
210
|
-
streamingEnabled?: boolean,
|
|
211
|
-
/**
|
|
212
|
-
* SDK synchronization settings.
|
|
213
|
-
* @property {Object} sync
|
|
214
|
-
*/
|
|
215
|
-
sync?: {
|
|
216
|
-
/**
|
|
217
|
-
* List of Split filters. These filters are used to fetch a subset of the Splits definitions in your environment, in order to reduce the delay of the SDK to be ready.
|
|
218
|
-
* This configuration is only meaningful when the SDK is working in "standalone" mode.
|
|
219
|
-
*
|
|
220
|
-
* At the moment, two types of split filters are supported: by name and by prefix.
|
|
221
|
-
* Example:
|
|
222
|
-
* `splitFilter: [
|
|
223
|
-
* { type: 'byName', values: ['my_split_1', 'my_split_2'] }, // will fetch splits named 'my_split_1' and 'my_split_2'
|
|
224
|
-
* { type: 'byPrefix', values: ['testing'] } // will fetch splits whose names start with 'testing__' prefix
|
|
225
|
-
* ]`
|
|
226
|
-
* @property {SplitIO.SplitFilter[]} splitFilters
|
|
227
|
-
*/
|
|
228
|
-
splitFilters?: SplitIO.SplitFilter[]
|
|
229
|
-
/**
|
|
230
|
-
* Impressions Collection Mode. Option to determine how impressions are going to be sent to Split Servers.
|
|
231
|
-
* Possible values are 'DEBUG' and 'OPTIMIZED'.
|
|
232
|
-
* - DEBUG: will send all the impressions generated (recommended only for debugging purposes).
|
|
233
|
-
* - OPTIMIZED: will send unique impressions to Split Servers avoiding a considerable amount of traffic that duplicated impressions could generate.
|
|
234
|
-
* @property {string} impressionsMode
|
|
235
|
-
* @default 'OPTIMIZED'
|
|
236
|
-
*/
|
|
237
|
-
impressionsMode?: SplitIO.ImpressionsMode,
|
|
238
|
-
/**
|
|
239
|
-
* Controls the SDK continuous synchronization flags.
|
|
240
|
-
*
|
|
241
|
-
* When `true` a running SDK will process rollout plan updates performed on the UI (default).
|
|
242
|
-
* When false it'll just fetch all data upon init
|
|
243
|
-
*
|
|
244
|
-
* @property {boolean} enabled
|
|
245
|
-
* @default true
|
|
246
|
-
*/
|
|
247
|
-
enabled?: boolean
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Common settings interface for SDK instances on NodeJS.
|
|
252
|
-
* @interface INodeBasicSettings
|
|
253
|
-
* @extends ISharedSettings
|
|
254
|
-
*/
|
|
255
|
-
interface INodeBasicSettings extends ISharedSettings {
|
|
256
|
-
/**
|
|
257
|
-
* SDK Startup settings for NodeJS.
|
|
258
|
-
* @property {Object} startup
|
|
259
|
-
*/
|
|
260
|
-
startup?: {
|
|
261
|
-
/**
|
|
262
|
-
* Maximum amount of time used before notify a timeout.
|
|
263
|
-
* @property {number} readyTimeout
|
|
264
|
-
* @default 15
|
|
265
|
-
*/
|
|
266
|
-
readyTimeout?: number,
|
|
267
|
-
/**
|
|
268
|
-
* 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'.
|
|
269
|
-
* @property {number} requestTimeoutBeforeReady
|
|
270
|
-
* @default 15
|
|
271
|
-
*/
|
|
272
|
-
requestTimeoutBeforeReady?: number,
|
|
273
|
-
/**
|
|
274
|
-
* How many quick retries we will do while starting up the SDK.
|
|
275
|
-
* @property {number} retriesOnFailureBeforeReady
|
|
276
|
-
* @default 1
|
|
277
|
-
*/
|
|
278
|
-
retriesOnFailureBeforeReady?: number,
|
|
279
|
-
/**
|
|
280
|
-
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
281
|
-
* to better control on browsers. This number defines that window before the first events push.
|
|
282
|
-
*
|
|
283
|
-
* @property {number} eventsFirstPushWindow
|
|
284
|
-
* @default 0
|
|
285
|
-
*/
|
|
286
|
-
eventsFirstPushWindow?: number,
|
|
287
|
-
},
|
|
288
|
-
/**
|
|
289
|
-
* SDK scheduler settings.
|
|
290
|
-
* @property {Object} scheduler
|
|
291
|
-
*/
|
|
292
|
-
scheduler?: {
|
|
293
|
-
/**
|
|
294
|
-
* The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
|
|
295
|
-
* @property {number} featuresRefreshRate
|
|
296
|
-
* @default 5
|
|
297
|
-
*/
|
|
298
|
-
featuresRefreshRate?: number,
|
|
299
|
-
/**
|
|
300
|
-
* 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.
|
|
301
|
-
* @property {number} impressionsRefreshRate
|
|
302
|
-
* @default 300
|
|
303
|
-
*/
|
|
304
|
-
impressionsRefreshRate?: number,
|
|
305
|
-
/**
|
|
306
|
-
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
307
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
308
|
-
* @property {number} impressionsQueueSize
|
|
309
|
-
* @default 30000
|
|
310
|
-
*/
|
|
311
|
-
impressionsQueueSize?: number,
|
|
312
|
-
/**
|
|
313
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
314
|
-
* @property {number} metricsRefreshRate
|
|
315
|
-
* @default 120
|
|
316
|
-
* @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
|
|
317
|
-
*/
|
|
318
|
-
metricsRefreshRate?: number,
|
|
319
|
-
/**
|
|
320
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
321
|
-
* @property {number} telemetryRefreshRate
|
|
322
|
-
* @default 3600
|
|
323
|
-
*/
|
|
324
|
-
telemetryRefreshRate?: number,
|
|
325
|
-
/**
|
|
326
|
-
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
327
|
-
* @property {number} segmentsRefreshRate
|
|
328
|
-
* @default 60
|
|
329
|
-
*/
|
|
330
|
-
segmentsRefreshRate?: number,
|
|
331
|
-
/**
|
|
332
|
-
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
333
|
-
* @property {number} eventsPushRate
|
|
334
|
-
* @default 60
|
|
335
|
-
*/
|
|
336
|
-
eventsPushRate?: number,
|
|
337
|
-
/**
|
|
338
|
-
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
339
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
340
|
-
* @property {number} eventsQueueSize
|
|
341
|
-
* @default 500
|
|
342
|
-
*/
|
|
343
|
-
eventsQueueSize?: number,
|
|
344
|
-
/**
|
|
345
|
-
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
346
|
-
* For more information @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
|
|
347
|
-
* @property {number} offlineRefreshRate
|
|
348
|
-
* @default 15
|
|
349
|
-
*/
|
|
350
|
-
offlineRefreshRate?: number
|
|
351
|
-
/**
|
|
352
|
-
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
353
|
-
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
354
|
-
* @property {number} pushRetryBackoffBase
|
|
355
|
-
* @default 1
|
|
356
|
-
*/
|
|
357
|
-
pushRetryBackoffBase?: number,
|
|
358
|
-
},
|
|
359
|
-
/**
|
|
360
|
-
* SDK Core settings for NodeJS.
|
|
361
|
-
* @property {Object} core
|
|
362
|
-
*/
|
|
363
|
-
core: {
|
|
364
|
-
/**
|
|
365
|
-
* Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
366
|
-
* @property {string} authorizationKey
|
|
367
|
-
*/
|
|
368
|
-
authorizationKey: string,
|
|
369
|
-
/**
|
|
370
|
-
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
371
|
-
* @property {boolean} labelsEnabled
|
|
372
|
-
* @default true
|
|
373
|
-
*/
|
|
374
|
-
labelsEnabled?: boolean
|
|
375
|
-
/**
|
|
376
|
-
* Disable machine IP and Name from being sent to Split backend.
|
|
377
|
-
* @property {boolean} IPAddressesEnabled
|
|
378
|
-
* @default true
|
|
379
|
-
*/
|
|
380
|
-
IPAddressesEnabled?: boolean
|
|
381
|
-
},
|
|
382
|
-
/**
|
|
383
|
-
* Defines which kind of storage we should instantiate.
|
|
384
|
-
* @property {Object} storage
|
|
385
|
-
*/
|
|
386
|
-
storage?: {
|
|
387
|
-
/**
|
|
388
|
-
* Storage type to be instantiated by the SDK.
|
|
389
|
-
* @property {StorageType} type
|
|
390
|
-
* @default MEMORY
|
|
391
|
-
*/
|
|
392
|
-
type?: StorageType,
|
|
393
|
-
/**
|
|
394
|
-
* Options to be passed to the selected storage.
|
|
395
|
-
* @property {Object} options
|
|
396
|
-
*/
|
|
397
|
-
options?: Object,
|
|
398
|
-
/**
|
|
399
|
-
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
400
|
-
* @property {string} prefix
|
|
401
|
-
* @default SPLITIO
|
|
402
|
-
*/
|
|
403
|
-
prefix?: string
|
|
404
|
-
},
|
|
405
|
-
/**
|
|
406
|
-
* The SDK mode. Possible values are "standalone", which is the default when using a synchronous storage, like 'MEMORY' and 'LOCALSTORAGE',
|
|
407
|
-
* and "consumer", which must be set when using an asynchronous storage, like 'REDIS'. For "localhost" mode, use "localhost" as authorizationKey.
|
|
408
|
-
* @property {SDKMode} mode
|
|
409
|
-
* @default standalone
|
|
410
|
-
*/
|
|
411
|
-
mode?: SDKMode,
|
|
412
|
-
/**
|
|
413
|
-
* Mocked features file path. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
|
|
414
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#localhost-mode}
|
|
415
|
-
* @property {MockedFeaturesFilePath} features
|
|
416
|
-
* @default $HOME/.split
|
|
417
|
-
*/
|
|
418
|
-
features?: SplitIO.MockedFeaturesFilePath,
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Common API for entities that expose status handlers.
|
|
422
|
-
* @interface IStatusInterface
|
|
423
|
-
* @extends EventEmitter
|
|
424
|
-
*/
|
|
425
|
-
interface IStatusInterface extends EventEmitter {
|
|
426
|
-
/**
|
|
427
|
-
* Constant object containing the SDK events for you to use.
|
|
428
|
-
* @property {EventConsts} Event
|
|
429
|
-
*/
|
|
430
|
-
Event: EventConsts,
|
|
431
|
-
/**
|
|
432
|
-
* Returns a promise that will be resolved once the SDK has finished loading (SDK_READY event emitted) or rejected if the SDK has timedout (SDK_READY_TIMED_OUT event emitted).
|
|
433
|
-
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, calling the `ready` method after the
|
|
434
|
-
* SDK had timed out will return a new promise that should eventually resolve if the SDK gets ready.
|
|
435
|
-
*
|
|
436
|
-
* 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.
|
|
437
|
-
* However, when using async/await syntax, the rejection should be explicitly propagated like in the following example:
|
|
438
|
-
* ```
|
|
439
|
-
* try {
|
|
440
|
-
* await client.ready().catch((e) => { throw e; });
|
|
441
|
-
* // SDK is ready
|
|
442
|
-
* } catch(e) {
|
|
443
|
-
* // SDK has timedout
|
|
444
|
-
* }
|
|
445
|
-
* ```
|
|
446
|
-
*
|
|
447
|
-
* @function ready
|
|
448
|
-
* @returns {Promise<void>}
|
|
449
|
-
*/
|
|
450
|
-
ready(): Promise<void>
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Common definitions between clients for different environments interface.
|
|
454
|
-
* @interface IBasicClient
|
|
455
|
-
* @extends IStatusInterface
|
|
456
|
-
*/
|
|
457
|
-
interface IBasicClient extends IStatusInterface {
|
|
458
|
-
/**
|
|
459
|
-
* Destroy the client instance.
|
|
460
|
-
* @function destroy
|
|
461
|
-
* @returns {Promise<void>}
|
|
462
|
-
*/
|
|
463
|
-
destroy(): Promise<void>
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Common definitions between SDK instances for different environments interface.
|
|
467
|
-
* @interface IBasicSDK
|
|
468
|
-
*/
|
|
469
|
-
interface IBasicSDK {
|
|
470
|
-
/**
|
|
471
|
-
* Current settings of the SDK instance.
|
|
472
|
-
* @property settings
|
|
473
|
-
*/
|
|
474
|
-
settings: ISettings,
|
|
475
|
-
/**
|
|
476
|
-
* Logger API.
|
|
477
|
-
* @property Logger
|
|
478
|
-
*/
|
|
479
|
-
Logger: ILoggerAPI
|
|
480
|
-
}
|
|
481
7
|
/****** Exposed namespace ******/
|
|
482
8
|
/**
|
|
483
|
-
* Types and interfaces for @splitsoftware/splitio package for usage when integrating
|
|
9
|
+
* Types and interfaces for @splitsoftware/splitio package for usage when integrating Javascript SDK on Typescript apps.
|
|
484
10
|
* For the SDK package information
|
|
485
11
|
* @see {@link https://www.npmjs.com/package/@splitsoftware/splitio}
|
|
486
12
|
*/
|
|
487
13
|
declare namespace SplitIO {
|
|
488
|
-
/**
|
|
489
|
-
* Split treatment value, returned by getTreatment.
|
|
490
|
-
* @typedef {string} Treatment
|
|
491
|
-
*/
|
|
492
|
-
type Treatment = string;
|
|
493
|
-
/**
|
|
494
|
-
* Split treatment promise that will resolve to actual treatment value.
|
|
495
|
-
* @typedef {Promise<string>} AsyncTreatment
|
|
496
|
-
*/
|
|
497
|
-
type AsyncTreatment = Promise<string>;
|
|
498
|
-
/**
|
|
499
|
-
* An object with the treatments for a bulk of splits, returned by getTreatments. For example:
|
|
500
|
-
* {
|
|
501
|
-
* feature1: 'on',
|
|
502
|
-
* feature2: 'off
|
|
503
|
-
* }
|
|
504
|
-
* @typedef {Object.<Treatment>} Treatments
|
|
505
|
-
*/
|
|
506
|
-
type Treatments = {
|
|
507
|
-
[featureName: string]: Treatment
|
|
508
|
-
};
|
|
509
|
-
/**
|
|
510
|
-
* Split treatments promise that will resolve to the actual SplitIO.Treatments object.
|
|
511
|
-
* @typedef {Promise<Treatments>} AsyncTreatments
|
|
512
|
-
*/
|
|
513
|
-
type AsyncTreatments = Promise<Treatments>;
|
|
514
|
-
/**
|
|
515
|
-
* Split evaluation result with treatment and configuration, returned by getTreatmentWithConfig.
|
|
516
|
-
* @typedef {Object} TreatmentWithConfig
|
|
517
|
-
* @property {string} treatment The treatment result
|
|
518
|
-
* @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.
|
|
519
|
-
*/
|
|
520
|
-
type TreatmentWithConfig = {
|
|
521
|
-
treatment: string,
|
|
522
|
-
config: string | null
|
|
523
|
-
};
|
|
524
|
-
/**
|
|
525
|
-
* Split treatment promise that will resolve to actual treatment with config value.
|
|
526
|
-
* @typedef {Promise<TreatmentWithConfig>} AsyncTreatmentWithConfig
|
|
527
|
-
*/
|
|
528
|
-
type AsyncTreatmentWithConfig = Promise<TreatmentWithConfig>;
|
|
529
|
-
/**
|
|
530
|
-
* An object with the treatments with configs for a bulk of splits, returned by getTreatmentsWithConfig.
|
|
531
|
-
* Each existing configuration is a stringified version of the JSON you defined on the Split web console. For example:
|
|
532
|
-
* {
|
|
533
|
-
* feature1: { treatment: 'on', config: null }
|
|
534
|
-
* feature2: { treatment: 'off', config: '{"bannerText":"Click here."}' }
|
|
535
|
-
* }
|
|
536
|
-
* @typedef {Object.<TreatmentWithConfig>} Treatments
|
|
537
|
-
*/
|
|
538
|
-
type TreatmentsWithConfig = {
|
|
539
|
-
[featureName: string]: TreatmentWithConfig
|
|
540
|
-
};
|
|
541
|
-
/**
|
|
542
|
-
* Split treatments promise that will resolve to the actual SplitIO.TreatmentsWithConfig object.
|
|
543
|
-
* @typedef {Promise<TreatmentsWithConfig>} AsyncTreatmentsWithConfig
|
|
544
|
-
*/
|
|
545
|
-
type AsyncTreatmentsWithConfig = Promise<TreatmentsWithConfig>;
|
|
546
|
-
/**
|
|
547
|
-
* Possible Split SDK events.
|
|
548
|
-
* @typedef {string} Event
|
|
549
|
-
*/
|
|
550
|
-
type Event = 'init::timeout' | 'init::ready' | 'init::cache-ready' | 'state::update';
|
|
551
|
-
/**
|
|
552
|
-
* Split 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.
|
|
553
|
-
* @typedef {Object.<AttributeType>} Attributes
|
|
554
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#attribute-syntax}
|
|
555
|
-
*/
|
|
556
|
-
type Attributes = {
|
|
557
|
-
[attributeName: string]: AttributeType
|
|
558
|
-
};
|
|
559
|
-
/**
|
|
560
|
-
* Type of an attribute value
|
|
561
|
-
* @typedef {string | number | boolean | Array<string | number>} AttributeType
|
|
562
|
-
*/
|
|
563
|
-
type AttributeType = string | number | boolean | Array<string | number>;
|
|
564
|
-
/**
|
|
565
|
-
* Split properties should be an object with values of type string, number, boolean or null. Size limit of ~31kb.
|
|
566
|
-
* @typedef {Object.<number, string, boolean, null>} Properties
|
|
567
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#track
|
|
568
|
-
*/
|
|
569
|
-
type Properties = {
|
|
570
|
-
[propertyName: string]: string | number | boolean | null
|
|
571
|
-
};
|
|
572
|
-
/**
|
|
573
|
-
* The SplitKey object format.
|
|
574
|
-
* @typedef {Object.<string>} SplitKeyObject
|
|
575
|
-
*/
|
|
576
|
-
type SplitKeyObject = {
|
|
577
|
-
matchingKey: string,
|
|
578
|
-
bucketingKey: string
|
|
579
|
-
};
|
|
580
|
-
/**
|
|
581
|
-
* The customer identifier. Could be a SplitKeyObject or a string.
|
|
582
|
-
* @typedef {SplitKeyObject|string} SplitKey
|
|
583
|
-
*/
|
|
584
|
-
type SplitKey = SplitKeyObject | string;
|
|
585
|
-
/**
|
|
586
|
-
* Path to file with mocked features (for node).
|
|
587
|
-
* @typedef {string} MockedFeaturesFilePath
|
|
588
|
-
*/
|
|
589
|
-
type MockedFeaturesFilePath = string;
|
|
590
|
-
/**
|
|
591
|
-
* Object with mocked features mapping (for browser). We need to specify the featureName as key, and the mocked treatment as value.
|
|
592
|
-
* @typedef {Object} MockedFeaturesMap
|
|
593
|
-
*/
|
|
594
|
-
type MockedFeaturesMap = {
|
|
595
|
-
[featureName: string]: string | TreatmentWithConfig
|
|
596
|
-
};
|
|
597
|
-
/**
|
|
598
|
-
* Object with information about an impression. It contains the generated impression DTO as well as
|
|
599
|
-
* complementary information around where and how it was generated in that way.
|
|
600
|
-
* @typedef {Object} ImpressionData
|
|
601
|
-
*/
|
|
602
|
-
type ImpressionData = {
|
|
603
|
-
impression: {
|
|
604
|
-
feature: string,
|
|
605
|
-
keyName: string,
|
|
606
|
-
treatment: string,
|
|
607
|
-
time: number,
|
|
608
|
-
bucketingKey?: string,
|
|
609
|
-
label: string,
|
|
610
|
-
changeNumber: number,
|
|
611
|
-
pt?: number,
|
|
612
|
-
},
|
|
613
|
-
attributes?: SplitIO.Attributes,
|
|
614
|
-
ip: string,
|
|
615
|
-
hostname: string,
|
|
616
|
-
sdkLanguageVersion: string
|
|
617
|
-
};
|
|
618
|
-
/**
|
|
619
|
-
* Data corresponding to one Split view.
|
|
620
|
-
* @typedef {Object} SplitView
|
|
621
|
-
*/
|
|
622
|
-
type SplitView = {
|
|
623
|
-
/**
|
|
624
|
-
* The name of the split.
|
|
625
|
-
* @property {string} name
|
|
626
|
-
*/
|
|
627
|
-
name: string,
|
|
628
|
-
/**
|
|
629
|
-
* The traffic type of the split.
|
|
630
|
-
* @property {string} trafficType
|
|
631
|
-
*/
|
|
632
|
-
trafficType: string,
|
|
633
|
-
/**
|
|
634
|
-
* Whether the split is killed or not.
|
|
635
|
-
* @property {boolean} killed
|
|
636
|
-
*/
|
|
637
|
-
killed: boolean,
|
|
638
|
-
/**
|
|
639
|
-
* The list of treatments available for the split.
|
|
640
|
-
* @property {Array<string>} treatments
|
|
641
|
-
*/
|
|
642
|
-
treatments: Array<string>,
|
|
643
|
-
/**
|
|
644
|
-
* Current change number of the split.
|
|
645
|
-
* @property {number} changeNumber
|
|
646
|
-
*/
|
|
647
|
-
changeNumber: number,
|
|
648
|
-
/**
|
|
649
|
-
* Map of configurations per treatment.
|
|
650
|
-
* Each existing configuration is a stringified version of the JSON you defined on the Split web console.
|
|
651
|
-
* @property {Object.<string>} configs
|
|
652
|
-
*/
|
|
653
|
-
configs: {
|
|
654
|
-
[treatmentName: string]: string
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
/**
|
|
658
|
-
* A promise that will be resolved with that SplitView.
|
|
659
|
-
* @typedef {Promise<SplitView>} SplitView
|
|
660
|
-
*/
|
|
661
|
-
type SplitViewAsync = Promise<SplitView>;
|
|
662
|
-
/**
|
|
663
|
-
* An array containing the SplitIO.SplitView elements.
|
|
664
|
-
*/
|
|
665
|
-
type SplitViews = Array<SplitView>;
|
|
666
|
-
/**
|
|
667
|
-
* A promise that will be resolved with an SplitIO.SplitViews array.
|
|
668
|
-
* @typedef {Promise<SplitViews>} SplitViewsAsync
|
|
669
|
-
*/
|
|
670
|
-
type SplitViewsAsync = Promise<SplitViews>;
|
|
671
|
-
/**
|
|
672
|
-
* An array of split names.
|
|
673
|
-
* @typedef {Array<string>} SplitNames
|
|
674
|
-
*/
|
|
675
|
-
type SplitNames = Array<string>;
|
|
676
|
-
/**
|
|
677
|
-
* A promise that will be resolved with an array of split names.
|
|
678
|
-
* @typedef {Promise<SplitNames>} SplitNamesAsync
|
|
679
|
-
*/
|
|
680
|
-
type SplitNamesAsync = Promise<SplitNames>;
|
|
681
|
-
/**
|
|
682
|
-
* Synchronous storage valid types for NodeJS.
|
|
683
|
-
* @typedef {string} NodeSyncStorage
|
|
684
|
-
*/
|
|
685
|
-
type NodeSyncStorage = 'MEMORY';
|
|
686
|
-
/**
|
|
687
|
-
* Asynchronous storages valid types for NodeJS.
|
|
688
|
-
* @typedef {string} NodeAsyncStorage
|
|
689
|
-
*/
|
|
690
|
-
type NodeAsyncStorage = 'REDIS';
|
|
691
|
-
/**
|
|
692
|
-
* Storage valid types for the browser.
|
|
693
|
-
* @typedef {string} BrowserStorage
|
|
694
|
-
*/
|
|
695
|
-
type BrowserStorage = 'MEMORY' | 'LOCALSTORAGE';
|
|
696
|
-
/**
|
|
697
|
-
* Impression listener interface. This is the interface that needs to be implemented
|
|
698
|
-
* by the element you provide to the SDK as impression listener.
|
|
699
|
-
* @interface IImpressionListener
|
|
700
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#listener}
|
|
701
|
-
*/
|
|
702
|
-
interface IImpressionListener {
|
|
703
|
-
logImpression(data: SplitIO.ImpressionData): void
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* A pair of user key and it's trafficType, required for tracking valid Split events.
|
|
707
|
-
* @typedef {Object} Identity
|
|
708
|
-
* @property {string} key The user key.
|
|
709
|
-
* @property {string} trafficType The key traffic type.
|
|
710
|
-
*/
|
|
711
|
-
type Identity = {
|
|
712
|
-
key: string;
|
|
713
|
-
trafficType: string;
|
|
714
|
-
};
|
|
715
|
-
/**
|
|
716
|
-
* Object with information about a Split event.
|
|
717
|
-
* @typedef {Object} EventData
|
|
718
|
-
*/
|
|
719
|
-
type EventData = {
|
|
720
|
-
eventTypeId: string;
|
|
721
|
-
value?: number;
|
|
722
|
-
properties?: Properties;
|
|
723
|
-
trafficTypeName?: string;
|
|
724
|
-
key?: string;
|
|
725
|
-
timestamp?: number;
|
|
726
|
-
};
|
|
727
|
-
/**
|
|
728
|
-
* Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
|
|
729
|
-
*
|
|
730
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
|
|
731
|
-
*/
|
|
732
|
-
interface IGoogleAnalyticsToSplitConfig {
|
|
733
|
-
type: 'GOOGLE_ANALYTICS_TO_SPLIT',
|
|
734
|
-
/**
|
|
735
|
-
* Optional flag to filter GA hits from being tracked as Split events.
|
|
736
|
-
* @property {boolean} hits
|
|
737
|
-
* @default true
|
|
738
|
-
*/
|
|
739
|
-
hits?: boolean,
|
|
740
|
-
/**
|
|
741
|
-
* Optional predicate used to define a custom filter for tracking GA hits as Split events.
|
|
742
|
-
* For example, the following filter allows to track only 'event' hits:
|
|
743
|
-
* `(model) => model.get('hitType') === 'event'`
|
|
744
|
-
* By default, all hits are tracked as Split events.
|
|
745
|
-
*/
|
|
746
|
-
filter?: (model: UniversalAnalytics.Model) => boolean,
|
|
747
|
-
/**
|
|
748
|
-
* Optional function useful when you need to modify the Split event before tracking it.
|
|
749
|
-
* This function is invoked with two arguments:
|
|
750
|
-
* 1. the GA model object representing the hit.
|
|
751
|
-
* 2. the default format of the mapped Split event instance.
|
|
752
|
-
* The return value must be a Split event, that can be the second argument or a new object.
|
|
753
|
-
*
|
|
754
|
-
* For example, the following mapper adds a custom property to events:
|
|
755
|
-
* `(model, defaultMapping) => {
|
|
756
|
-
* defaultMapping.properties.someProperty = SOME_VALUE;
|
|
757
|
-
* return defaultMapping;
|
|
758
|
-
* }`
|
|
759
|
-
*/
|
|
760
|
-
mapper?: (model: UniversalAnalytics.Model, defaultMapping: SplitIO.EventData) => SplitIO.EventData,
|
|
761
|
-
/**
|
|
762
|
-
* Optional prefix for EventTypeId, to prevent any kind of data collision between events.
|
|
763
|
-
* @property {string} prefix
|
|
764
|
-
* @default 'ga'
|
|
765
|
-
*/
|
|
766
|
-
prefix?: string,
|
|
767
|
-
/**
|
|
768
|
-
* List of Split identities (key & traffic type pairs) used to track events.
|
|
769
|
-
* If not provided, events are sent using the key and traffic type provided at SDK config
|
|
770
|
-
*/
|
|
771
|
-
identities?: Identity[],
|
|
772
|
-
/**
|
|
773
|
-
* Optional flag to log an error if the `auto-require` script is not detected.
|
|
774
|
-
* The auto-require script automatically requires the `splitTracker` plugin for created trackers,
|
|
775
|
-
* and should be placed right after your Google Analytics, Google Tag Manager or gtag.js script tag.
|
|
776
|
-
*
|
|
777
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360040838752#set-up-with-gtm-and-gtag.js}
|
|
778
|
-
*
|
|
779
|
-
* @property {boolean} autoRequire
|
|
780
|
-
* @default false
|
|
781
|
-
*/
|
|
782
|
-
autoRequire?: boolean,
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Object representing the data sent by Split (events and impressions).
|
|
786
|
-
* @typedef {Object} IntegrationData
|
|
787
|
-
* @property {string} type The type of Split data, either 'IMPRESSION' or 'EVENT'.
|
|
788
|
-
* @property {ImpressionData | EventData} payload The data instance itself.
|
|
789
|
-
*/
|
|
790
|
-
type IntegrationData = { type: 'IMPRESSION', payload: SplitIO.ImpressionData } | { type: 'EVENT', payload: SplitIO.EventData };
|
|
791
|
-
/**
|
|
792
|
-
* Enable 'Split to Google Analytics' integration, to track Split impressions and events as Google Analytics hits.
|
|
793
|
-
*
|
|
794
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
|
|
795
|
-
*/
|
|
796
|
-
interface ISplitToGoogleAnalyticsConfig {
|
|
797
|
-
type: 'SPLIT_TO_GOOGLE_ANALYTICS',
|
|
798
|
-
/**
|
|
799
|
-
* Optional flag to filter Split impressions from being tracked as GA hits.
|
|
800
|
-
* @property {boolean} impressions
|
|
801
|
-
* @default true
|
|
802
|
-
*/
|
|
803
|
-
impressions?: boolean,
|
|
804
|
-
/**
|
|
805
|
-
* Optional flag to filter Split events from being tracked as GA hits.
|
|
806
|
-
* @property {boolean} events
|
|
807
|
-
* @default true
|
|
808
|
-
*/
|
|
809
|
-
events?: boolean,
|
|
810
|
-
/**
|
|
811
|
-
* Optional predicate used to define a custom filter for tracking Split data (events and impressions) as GA hits.
|
|
812
|
-
* For example, the following filter allows to track only impressions, equivalent to setting events to false:
|
|
813
|
-
* `(data) => data.type === 'IMPRESSION'`
|
|
814
|
-
*/
|
|
815
|
-
filter?: (data: SplitIO.IntegrationData) => boolean,
|
|
816
|
-
/**
|
|
817
|
-
* Optional function useful when you need to modify the GA hit before sending it.
|
|
818
|
-
* This function is invoked with two arguments:
|
|
819
|
-
* 1. the input data (Split event or impression).
|
|
820
|
-
* 2. the default format of the mapped FieldsObject instance (GA hit).
|
|
821
|
-
* The return value must be a FieldsObject, that can be the second argument or a new object.
|
|
822
|
-
*
|
|
823
|
-
* For example, the following mapper adds a custom dimension to hits:
|
|
824
|
-
* `(data, defaultMapping) => {
|
|
825
|
-
* defaultMapping.dimension1 = SOME_VALUE;
|
|
826
|
-
* return defaultMapping;
|
|
827
|
-
* }`
|
|
828
|
-
*
|
|
829
|
-
* Default FieldsObject instance for data.type === 'IMPRESSION':
|
|
830
|
-
* `{
|
|
831
|
-
* hitType: 'event',
|
|
832
|
-
* eventCategory: 'split-impression',
|
|
833
|
-
* eventAction: 'Evaluate ' + data.payload.impression.feature,
|
|
834
|
-
* eventLabel: 'Treatment: ' + data.payload.impression.treatment + '. Targeting rule: ' + data.payload.impression.label + '.',
|
|
835
|
-
* nonInteraction: true,
|
|
836
|
-
* }`
|
|
837
|
-
* Default FieldsObject instance for data.type === 'EVENT':
|
|
838
|
-
* `{
|
|
839
|
-
* hitType: 'event',
|
|
840
|
-
* eventCategory: 'split-event',
|
|
841
|
-
* eventAction: data.payload.eventTypeId,
|
|
842
|
-
* eventValue: data.payload.value,
|
|
843
|
-
* nonInteraction: true,
|
|
844
|
-
* }`
|
|
845
|
-
*/
|
|
846
|
-
mapper?: (data: SplitIO.IntegrationData, defaultMapping: UniversalAnalytics.FieldsObject) => UniversalAnalytics.FieldsObject,
|
|
847
|
-
/**
|
|
848
|
-
* List of tracker names to send the hit. An empty string represents the default tracker.
|
|
849
|
-
* If not provided, hits are only sent to default tracker.
|
|
850
|
-
*/
|
|
851
|
-
trackerNames?: string[],
|
|
852
|
-
}
|
|
853
|
-
/**
|
|
854
|
-
* Available URL settings for the SDKs.
|
|
855
|
-
*/
|
|
856
|
-
type UrlSettings = {
|
|
857
|
-
/**
|
|
858
|
-
* String property to override the base URL where the SDK will get feature flagging related data like a Split rollout plan or segments information.
|
|
859
|
-
* @property {string} sdk
|
|
860
|
-
* @default 'https://sdk.split.io/api'
|
|
861
|
-
*/
|
|
862
|
-
sdk?: string,
|
|
863
|
-
/**
|
|
864
|
-
* String property to override the base URL where the SDK will post event-related information like impressions.
|
|
865
|
-
* @property {string} events
|
|
866
|
-
* @default 'https://events.split.io/api'
|
|
867
|
-
*/
|
|
868
|
-
events?: string,
|
|
869
|
-
/**
|
|
870
|
-
* String property to override the base URL where the SDK will get authorization tokens to be used with functionality that requires it, like streaming.
|
|
871
|
-
* @property {string} auth
|
|
872
|
-
* @default 'https://auth.split.io/api'
|
|
873
|
-
*/
|
|
874
|
-
auth?: string,
|
|
875
|
-
/**
|
|
876
|
-
* String property to override the base URL where the SDK will connect to receive streaming updates.
|
|
877
|
-
* @property {string} streaming
|
|
878
|
-
* @default 'https://streaming.split.io'
|
|
879
|
-
*/
|
|
880
|
-
streaming?: string,
|
|
881
|
-
/**
|
|
882
|
-
* String property to override the base URL where the SDK will post telemetry data.
|
|
883
|
-
* @property {string} telemetry
|
|
884
|
-
* @default 'https://telemetry.split.io/api'
|
|
885
|
-
*/
|
|
886
|
-
telemetry?: string
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Available integration options for the browser
|
|
891
|
-
*/
|
|
892
|
-
type BrowserIntegration = ISplitToGoogleAnalyticsConfig | IGoogleAnalyticsToSplitConfig;
|
|
893
|
-
/**
|
|
894
|
-
* SplitFilter type.
|
|
895
|
-
* @typedef {string} SplitFilterType
|
|
896
|
-
*/
|
|
897
|
-
type SplitFilterType = 'byName' | 'byPrefix';
|
|
898
|
-
/**
|
|
899
|
-
* Defines a split filter, described by a type and list of values.
|
|
900
|
-
*/
|
|
901
|
-
interface SplitFilter {
|
|
902
|
-
/**
|
|
903
|
-
* Type of the filter.
|
|
904
|
-
* @property {SplitFilterType} type
|
|
905
|
-
*/
|
|
906
|
-
type: SplitFilterType,
|
|
907
|
-
/**
|
|
908
|
-
* List of values: split names for 'byName' filter type, and split prefixes for 'byPrefix' type.
|
|
909
|
-
* @property {string[]} values
|
|
910
|
-
*/
|
|
911
|
-
values: string[],
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* ImpressionsMode type
|
|
915
|
-
* @typedef {string} ImpressionsMode
|
|
916
|
-
*/
|
|
917
|
-
type ImpressionsMode = 'OPTIMIZED' | 'DEBUG';
|
|
918
|
-
/**
|
|
919
|
-
* User consent status.
|
|
920
|
-
* @typedef {string} ConsentStatus
|
|
921
|
-
*/
|
|
922
|
-
type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
|
|
923
14
|
/**
|
|
924
15
|
* Settings interface for SDK instances created on the browser
|
|
925
16
|
* @interface IBrowserSettings
|
|
926
|
-
* @extends ISharedSettings
|
|
927
17
|
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
|
|
928
18
|
*/
|
|
929
|
-
interface IBrowserSettings extends
|
|
930
|
-
/**
|
|
931
|
-
* SDK Startup settings for the Browser.
|
|
932
|
-
* @property {Object} startup
|
|
933
|
-
*/
|
|
934
|
-
startup?: {
|
|
935
|
-
/**
|
|
936
|
-
* Maximum amount of time used before notify a timeout.
|
|
937
|
-
* @property {number} readyTimeout
|
|
938
|
-
* @default 1.5
|
|
939
|
-
*/
|
|
940
|
-
readyTimeout?: number,
|
|
941
|
-
/**
|
|
942
|
-
* 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'.
|
|
943
|
-
* @property {number} requestTimeoutBeforeReady
|
|
944
|
-
* @default 1.5
|
|
945
|
-
*/
|
|
946
|
-
requestTimeoutBeforeReady?: number,
|
|
947
|
-
/**
|
|
948
|
-
* How many quick retries we will do while starting up the SDK.
|
|
949
|
-
* @property {number} retriesOnFailureBeforeReady
|
|
950
|
-
* @default 1
|
|
951
|
-
*/
|
|
952
|
-
retriesOnFailureBeforeReady?: number,
|
|
953
|
-
/**
|
|
954
|
-
* For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
|
|
955
|
-
* to better control on browsers. This number defines that window before the first events push.
|
|
956
|
-
*
|
|
957
|
-
* @property {number} eventsFirstPushWindow
|
|
958
|
-
* @default 10
|
|
959
|
-
*/
|
|
960
|
-
eventsFirstPushWindow?: number,
|
|
961
|
-
},
|
|
962
|
-
/**
|
|
963
|
-
* SDK scheduler settings.
|
|
964
|
-
* @property {Object} scheduler
|
|
965
|
-
*/
|
|
966
|
-
scheduler?: {
|
|
967
|
-
/**
|
|
968
|
-
* The SDK polls Split servers for changes to feature roll-out plans. This parameter controls this polling period in seconds.
|
|
969
|
-
* @property {number} featuresRefreshRate
|
|
970
|
-
* @default 30
|
|
971
|
-
*/
|
|
972
|
-
featuresRefreshRate?: number,
|
|
973
|
-
/**
|
|
974
|
-
* 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.
|
|
975
|
-
* @property {number} impressionsRefreshRate
|
|
976
|
-
* @default 60
|
|
977
|
-
*/
|
|
978
|
-
impressionsRefreshRate?: number,
|
|
979
|
-
/**
|
|
980
|
-
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
981
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
982
|
-
* @property {number} impressionsQueueSize
|
|
983
|
-
* @default 30000
|
|
984
|
-
*/
|
|
985
|
-
impressionsQueueSize?: number,
|
|
986
|
-
/**
|
|
987
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
988
|
-
* @property {number} metricsRefreshRate
|
|
989
|
-
* @default 120
|
|
990
|
-
* @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
|
|
991
|
-
*/
|
|
992
|
-
metricsRefreshRate?: number,
|
|
993
|
-
/**
|
|
994
|
-
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
995
|
-
* @property {number} telemetryRefreshRate
|
|
996
|
-
* @default 3600
|
|
997
|
-
*/
|
|
998
|
-
telemetryRefreshRate?: number,
|
|
999
|
-
/**
|
|
1000
|
-
* The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
|
|
1001
|
-
* @property {number} segmentsRefreshRate
|
|
1002
|
-
* @default 60
|
|
1003
|
-
*/
|
|
1004
|
-
segmentsRefreshRate?: number,
|
|
1005
|
-
/**
|
|
1006
|
-
* The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
|
|
1007
|
-
* @property {number} eventsPushRate
|
|
1008
|
-
* @default 60
|
|
1009
|
-
*/
|
|
1010
|
-
eventsPushRate?: number,
|
|
1011
|
-
/**
|
|
1012
|
-
* The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
1013
|
-
* If you use a 0 here, the queue will have no maximum size.
|
|
1014
|
-
* @property {number} eventsQueueSize
|
|
1015
|
-
* @default 500
|
|
1016
|
-
*/
|
|
1017
|
-
eventsQueueSize?: number,
|
|
1018
|
-
/**
|
|
1019
|
-
* For mocking/testing only. The SDK will refresh the features mocked data when mode is set to "localhost" by defining the key.
|
|
1020
|
-
* For more information @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#localhost-mode}
|
|
1021
|
-
* @property {number} offlineRefreshRate
|
|
1022
|
-
* @default 15
|
|
1023
|
-
*/
|
|
1024
|
-
offlineRefreshRate?: number,
|
|
1025
|
-
/**
|
|
1026
|
-
* When using streaming mode, seconds to wait before re attempting to connect for push notifications.
|
|
1027
|
-
* Next attempts follow intervals in power of two: base seconds, base x 2 seconds, base x 4 seconds, ...
|
|
1028
|
-
* @property {number} pushRetryBackoffBase
|
|
1029
|
-
* @default 1
|
|
1030
|
-
*/
|
|
1031
|
-
pushRetryBackoffBase?: number,
|
|
1032
|
-
},
|
|
19
|
+
interface IBrowserSettings extends IClientSideSharedSettings, IStaticSettings {
|
|
1033
20
|
/**
|
|
1034
21
|
* SDK Core settings for the browser.
|
|
1035
22
|
* @property {Object} core
|
|
1036
23
|
*/
|
|
1037
|
-
core: {
|
|
1038
|
-
/**
|
|
1039
|
-
* Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
|
|
1040
|
-
* @property {string} authorizationKey
|
|
1041
|
-
*/
|
|
1042
|
-
authorizationKey: string,
|
|
1043
|
-
/**
|
|
1044
|
-
* Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1045
|
-
* @property {SplitKey} key
|
|
1046
|
-
*/
|
|
1047
|
-
key: SplitKey,
|
|
24
|
+
core: IClientSideSharedSettings['core'] & {
|
|
1048
25
|
/**
|
|
1049
26
|
* Traffic type associated with the customer identifier. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1050
27
|
* If no provided as a setting it will be required on the client.track() calls.
|
|
1051
28
|
* @property {string} trafficType
|
|
1052
29
|
*/
|
|
1053
30
|
trafficType?: string,
|
|
1054
|
-
/**
|
|
1055
|
-
* Disable labels from being sent to Split backend. Labels may contain sensitive information.
|
|
1056
|
-
* @property {boolean} labelsEnabled
|
|
1057
|
-
* @default true
|
|
1058
|
-
*/
|
|
1059
|
-
labelsEnabled?: boolean
|
|
1060
31
|
},
|
|
1061
32
|
/**
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
33
|
+
* The SDK mode. When using the default in memory storage or `LOCALSTORAGE` as storage, the only possible value is "standalone", which is the default.
|
|
34
|
+
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
35
|
+
*
|
|
36
|
+
* @property {'standalone'} mode
|
|
37
|
+
* @default standalone
|
|
1064
38
|
*/
|
|
1065
|
-
|
|
39
|
+
mode?: 'standalone',
|
|
1066
40
|
/**
|
|
1067
41
|
* Defines which kind of storage we can instantiate on the browser.
|
|
1068
42
|
* Possible storage types are 'MEMORY', which is the default, and 'LOCALSTORAGE'.
|
|
@@ -1083,42 +57,26 @@ declare namespace SplitIO {
|
|
|
1083
57
|
prefix?: string
|
|
1084
58
|
},
|
|
1085
59
|
/**
|
|
1086
|
-
*
|
|
1087
|
-
* Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
|
|
1088
|
-
* @property {Object} urls
|
|
1089
|
-
*/
|
|
1090
|
-
urls?: UrlSettings,
|
|
1091
|
-
/**
|
|
1092
|
-
* SDK integration settings for the Browser.
|
|
60
|
+
* SDK integration settings for the browser.
|
|
1093
61
|
* @property {Object} integrations
|
|
1094
62
|
*/
|
|
1095
63
|
integrations?: BrowserIntegration[],
|
|
1096
|
-
/**
|
|
1097
|
-
* User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
|
|
1098
|
-
* - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
|
|
1099
|
-
* - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
|
|
1100
|
-
* - `'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
|
|
1101
|
-
* 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.
|
|
1102
|
-
*
|
|
1103
|
-
* @typedef {string} userConsent
|
|
1104
|
-
* @default 'GRANTED'
|
|
1105
|
-
*/
|
|
1106
|
-
userConsent?: ConsentStatus
|
|
1107
64
|
}
|
|
1108
65
|
/**
|
|
1109
66
|
* Settings interface for SDK instances created on NodeJS.
|
|
1110
67
|
* If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
|
|
1111
68
|
* @interface INodeSettings
|
|
1112
|
-
* @extends INodeBasicSettings
|
|
1113
69
|
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
|
|
1114
70
|
*/
|
|
1115
|
-
interface INodeSettings extends
|
|
71
|
+
interface INodeSettings extends IServerSideSharedSettings, IStaticSettings {
|
|
1116
72
|
/**
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
73
|
+
* The SDK mode. When using the default 'MEMORY' storage, the only possible value is "standalone", which is the default.
|
|
74
|
+
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
75
|
+
*
|
|
76
|
+
* @property {'standalone'} mode
|
|
77
|
+
* @default standalone
|
|
1120
78
|
*/
|
|
1121
|
-
|
|
79
|
+
mode?: 'standalone',
|
|
1122
80
|
/**
|
|
1123
81
|
* Defines which kind of storage we can instantiate on NodeJS for 'standalone' mode.
|
|
1124
82
|
* The only possible storage type is 'MEMORY', which is the default.
|
|
@@ -1138,23 +96,22 @@ declare namespace SplitIO {
|
|
|
1138
96
|
*/
|
|
1139
97
|
prefix?: string
|
|
1140
98
|
},
|
|
1141
|
-
/**
|
|
1142
|
-
* The SDK mode. When using the default 'MEMORY' storage, the only possible value is "standalone", which is the default.
|
|
1143
|
-
* For "localhost" mode, use "localhost" as authorizationKey.
|
|
1144
|
-
*
|
|
1145
|
-
* @property {'standalone'} mode
|
|
1146
|
-
* @default standalone
|
|
1147
|
-
*/
|
|
1148
|
-
mode?: 'standalone'
|
|
1149
99
|
}
|
|
1150
100
|
/**
|
|
1151
101
|
* Settings interface with async storage for SDK instances created on NodeJS.
|
|
1152
102
|
* If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.INodeSettings instead.
|
|
1153
103
|
* @interface INodeAsyncSettings
|
|
1154
|
-
* @extends INodeBasicSettings
|
|
1155
104
|
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
|
|
1156
105
|
*/
|
|
1157
|
-
interface INodeAsyncSettings extends
|
|
106
|
+
interface INodeAsyncSettings extends IServerSideSharedSettings, IStaticSettings {
|
|
107
|
+
/**
|
|
108
|
+
* The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
|
|
111
|
+
*
|
|
112
|
+
* @property {'consumer'} mode
|
|
113
|
+
*/
|
|
114
|
+
mode: 'consumer'
|
|
1158
115
|
/**
|
|
1159
116
|
* Defines which kind of async storage we can instantiate on NodeJS for 'consumer' mode.
|
|
1160
117
|
* The only possible storage type is 'REDIS'.
|
|
@@ -1227,7 +184,7 @@ declare namespace SplitIO {
|
|
|
1227
184
|
* @property {Object=} tls
|
|
1228
185
|
* @default undefined
|
|
1229
186
|
*/
|
|
1230
|
-
tls?:
|
|
187
|
+
tls?: any,
|
|
1231
188
|
},
|
|
1232
189
|
/**
|
|
1233
190
|
* Optional prefix to prevent any kind of data collision between SDK versions.
|
|
@@ -1236,365 +193,61 @@ declare namespace SplitIO {
|
|
|
1236
193
|
*/
|
|
1237
194
|
prefix?: string
|
|
1238
195
|
},
|
|
1239
|
-
/**
|
|
1240
|
-
* The SDK mode. When using 'REDIS' storage type, the only possible value is "consumer", which is required.
|
|
1241
|
-
*
|
|
1242
|
-
* @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#state-sharing-redis-integration}
|
|
1243
|
-
*
|
|
1244
|
-
* @property {'consumer'} mode
|
|
1245
|
-
*/
|
|
1246
|
-
mode: 'consumer'
|
|
1247
196
|
}
|
|
1248
197
|
/**
|
|
1249
|
-
*
|
|
1250
|
-
* @interface
|
|
1251
|
-
* @extends IBasicSDK
|
|
1252
|
-
*/
|
|
1253
|
-
interface ISDK extends IBasicSDK {
|
|
1254
|
-
/**
|
|
1255
|
-
* Returns the default client instance of the SDK.
|
|
1256
|
-
* @function client
|
|
1257
|
-
* @returns {IClient} The client instance.
|
|
1258
|
-
*/
|
|
1259
|
-
client(): IClient,
|
|
1260
|
-
/**
|
|
1261
|
-
* Returns a shared client of the SDK. For usage on the browser.
|
|
1262
|
-
* @function client
|
|
1263
|
-
* @param {SplitKey} key The key for the new client instance.
|
|
1264
|
-
* @param {string=} trafficType The traffic type of the provided key.
|
|
1265
|
-
* @returns {IClient} The client instance.
|
|
1266
|
-
*/
|
|
1267
|
-
client(key: SplitKey, trafficType?: string): IClient,
|
|
1268
|
-
/**
|
|
1269
|
-
* Returns a manager instance of the SDK to explore available information.
|
|
1270
|
-
* @function manager
|
|
1271
|
-
* @returns {IManager} The manager instance.
|
|
1272
|
-
*/
|
|
1273
|
-
manager(): IManager
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* This represents the interface for the SDK instance with synchronous storage.
|
|
1277
|
-
* @interface ISDK
|
|
1278
|
-
* @extends IBasicSDK
|
|
198
|
+
* Representation of a manager instance with synchronous storage of the SDK.
|
|
199
|
+
* @interface IManager
|
|
1279
200
|
*/
|
|
1280
|
-
interface
|
|
1281
|
-
/**
|
|
1282
|
-
* Returns the default client instance of the SDK.
|
|
1283
|
-
* @function client
|
|
1284
|
-
* @returns {IBrowserClient} The client instance.
|
|
1285
|
-
*/
|
|
1286
|
-
client(): IBrowserClient,
|
|
1287
|
-
/**
|
|
1288
|
-
* Returns a shared client of the SDK. For usage on the browser.
|
|
1289
|
-
* @function client
|
|
1290
|
-
* @param {SplitKey} key The key for the new client instance.
|
|
1291
|
-
* @param {string=} trafficType The traffic type of the provided key.
|
|
1292
|
-
* @returns {IBrowserClient} The client instance.
|
|
1293
|
-
*/
|
|
1294
|
-
client(key: SplitKey, trafficType?: string): IBrowserClient
|
|
1295
|
-
/**
|
|
1296
|
-
* User consent API.
|
|
1297
|
-
* @property UserConsent
|
|
1298
|
-
*/
|
|
1299
|
-
UserConsent: IUserConsentAPI
|
|
1300
|
-
}
|
|
201
|
+
interface IManager extends EventEmitter { }
|
|
1301
202
|
/**
|
|
1302
|
-
*
|
|
1303
|
-
* @interface
|
|
1304
|
-
* @extends IBasicSDK
|
|
203
|
+
* Representation of a manager instance with asynchronous storage of the SDK.
|
|
204
|
+
* @interface IAsyncManager
|
|
1305
205
|
*/
|
|
1306
|
-
interface
|
|
1307
|
-
/**
|
|
1308
|
-
* Returns the default client instance of the SDK.
|
|
1309
|
-
* @function client
|
|
1310
|
-
* @returns {IAsyncClient} The asynchronous client instance.
|
|
1311
|
-
*/
|
|
1312
|
-
client(): IAsyncClient,
|
|
1313
|
-
/**
|
|
1314
|
-
* Returns a manager instance of the SDK to explore available information.
|
|
1315
|
-
* @function manager
|
|
1316
|
-
* @returns {IManager} The manager instance.
|
|
1317
|
-
*/
|
|
1318
|
-
manager(): IAsyncManager
|
|
1319
|
-
}
|
|
206
|
+
interface IAsyncManager extends EventEmitter { }
|
|
1320
207
|
/**
|
|
1321
|
-
* This represents the interface for the Client instance with synchronous
|
|
208
|
+
* This represents the interface for the Client instance with synchronous method calls and server-side API, where we don't have only one key.
|
|
1322
209
|
* @interface IClient
|
|
1323
|
-
* @extends IBasicClient
|
|
1324
210
|
*/
|
|
1325
|
-
interface IClient extends
|
|
1326
|
-
/**
|
|
1327
|
-
* Returns a Treatment value, which is the treatment string for the given feature.
|
|
1328
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1329
|
-
* @function getTreatment
|
|
1330
|
-
* @param {string} key - The string key representing the consumer.
|
|
1331
|
-
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1332
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1333
|
-
* @returns {Treatment} The treatment string.
|
|
1334
|
-
*/
|
|
1335
|
-
getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
|
|
1336
|
-
/**
|
|
1337
|
-
* Returns a Treatment value, which is the treatment string for the given feature.
|
|
1338
|
-
* For usage on the Browser as we defined the key on the settings.
|
|
1339
|
-
* @function getTreatment
|
|
1340
|
-
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1341
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1342
|
-
* @returns {Treatment} The treatment string.
|
|
1343
|
-
*/
|
|
1344
|
-
getTreatment(splitName: string, attributes?: Attributes): Treatment,
|
|
1345
|
-
/**
|
|
1346
|
-
* Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
|
|
1347
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1348
|
-
* @function getTreatmentWithConfig
|
|
1349
|
-
* @param {string} key - The string key representing the consumer.
|
|
1350
|
-
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1351
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1352
|
-
* @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
|
|
1353
|
-
* configuration stringified JSON (or null if there was no config for that treatment).
|
|
1354
|
-
*/
|
|
1355
|
-
getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
|
|
1356
|
-
/**
|
|
1357
|
-
* Returns a TreatmentWithConfig value, which an object with both treatment and config string for the given feature.
|
|
1358
|
-
* For usage on the Browser as we defined the key on the settings.
|
|
1359
|
-
* @function getTreatment
|
|
1360
|
-
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1361
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1362
|
-
* @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
|
|
1363
|
-
* configuration stringified JSON (or null if there was no config for that treatment).
|
|
1364
|
-
*/
|
|
1365
|
-
getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
|
|
1366
|
-
/**
|
|
1367
|
-
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1368
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1369
|
-
* NOTE: Treatment will be a promise only in async storages, like REDIS.
|
|
1370
|
-
* @function getTreatments
|
|
1371
|
-
* @param {string} key - The string key representing the consumer.
|
|
1372
|
-
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1373
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1374
|
-
* @returns {Treatments} The treatments object map.
|
|
1375
|
-
*/
|
|
1376
|
-
getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
|
|
1377
|
-
/**
|
|
1378
|
-
* Returns a Treatments value, which is an object map with the treatments for the given features.
|
|
1379
|
-
* For usage on the Browser as we defined the key on the settings.
|
|
1380
|
-
* NOTE: Treatment will be a promise only in async storages, like REDIS.
|
|
1381
|
-
* @function getTreatments
|
|
1382
|
-
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1383
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1384
|
-
* @returns {Treatments} The treatments object map.
|
|
1385
|
-
*/
|
|
1386
|
-
getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
|
|
1387
|
-
/**
|
|
1388
|
-
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1389
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1390
|
-
* @function getTreatmentsWithConfig
|
|
1391
|
-
* @param {string} key - The string key representing the consumer.
|
|
1392
|
-
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1393
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1394
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1395
|
-
*/
|
|
1396
|
-
getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
|
|
1397
|
-
/**
|
|
1398
|
-
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
|
|
1399
|
-
* For usage on the Browser as we defined the key on the settings.
|
|
1400
|
-
* @function getTreatmentsWithConfig
|
|
1401
|
-
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1402
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1403
|
-
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1404
|
-
*/
|
|
1405
|
-
getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): TreatmentsWithConfig,
|
|
1406
|
-
/**
|
|
1407
|
-
* Tracks an event to be fed to the results product on Split Webconsole.
|
|
1408
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1409
|
-
* @function track
|
|
1410
|
-
* @param {SplitKey} key - The key that identifies the entity related to this event.
|
|
1411
|
-
* @param {string} trafficType - The traffic type of the entity related to this event.
|
|
1412
|
-
* @param {string} eventType - The event type corresponding to this event.
|
|
1413
|
-
* @param {number=} value - The value of this event.
|
|
1414
|
-
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1415
|
-
* @returns {boolean} Whether the event was added to the queue successfully or not.
|
|
1416
|
-
*/
|
|
1417
|
-
track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
|
|
1418
|
-
/**
|
|
1419
|
-
* Tracks an event to be fed to the results product on Split Webconsole.
|
|
1420
|
-
* For usage on the Browser as we defined the key on the settings.
|
|
1421
|
-
* @function track
|
|
1422
|
-
* @param {string} trafficType - The traffic type of the entity related to this event.
|
|
1423
|
-
* @param {string} eventType - The event type corresponding to this event.
|
|
1424
|
-
* @param {number=} value - The value of this event.
|
|
1425
|
-
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1426
|
-
* @returns {boolean} Whether the event was added to the queue successfully or not.
|
|
1427
|
-
*/
|
|
1428
|
-
track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
|
|
1429
|
-
/**
|
|
1430
|
-
* Tracks an event to be fed to the results product on Split Webconsole.
|
|
1431
|
-
* For usage on the Browser if we defined the key and also the trafficType on the settings.
|
|
1432
|
-
* @function track
|
|
1433
|
-
* @param {string} eventType - The event type corresponding to this event.
|
|
1434
|
-
* @param {number=} value - The value of this event.
|
|
1435
|
-
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1436
|
-
* @returns {boolean} Whether the event was added to the queue successfully or not.
|
|
1437
|
-
*/
|
|
1438
|
-
track(eventType: string, value?: number, properties?: Properties): boolean
|
|
1439
|
-
}
|
|
211
|
+
interface IClient extends IClientSS, EventEmitter { }
|
|
1440
212
|
/**
|
|
1441
|
-
* This represents the interface for the
|
|
1442
|
-
* @interface
|
|
1443
|
-
* @Extends IClient
|
|
213
|
+
* This represents the interface for the SDK instance with synchronous method calls and server-side API, where we don't have only one key.
|
|
214
|
+
* @interface ISDK
|
|
1444
215
|
*/
|
|
1445
|
-
interface
|
|
1446
|
-
/**
|
|
1447
|
-
* Add an attribute to client's in memory attributes storage.
|
|
1448
|
-
*
|
|
1449
|
-
* @param {string} attributeName Attribute name
|
|
1450
|
-
* @param {AttributeType} attributeValue Attribute value
|
|
1451
|
-
* @returns {boolean} true if the attribute was stored and false otherwise
|
|
1452
|
-
*/
|
|
1453
|
-
setAttribute(attributeName: string, attributeValue: AttributeType): boolean,
|
|
1454
|
-
/**
|
|
1455
|
-
* Returns the attribute with the given key.
|
|
1456
|
-
*
|
|
1457
|
-
* @param {string} attributeName Attribute name
|
|
1458
|
-
* @returns {AttributeType} Attribute with the given key
|
|
1459
|
-
*/
|
|
1460
|
-
getAttribute(attributeName: string): AttributeType,
|
|
1461
|
-
/**
|
|
1462
|
-
* Removes from client's in memory attributes storage the attribute with the given key.
|
|
1463
|
-
*
|
|
1464
|
-
* @param {string} attributeName
|
|
1465
|
-
* @returns {boolean} true if attribute was removed and false otherwise
|
|
1466
|
-
*/
|
|
1467
|
-
removeAttribute(attributeName: string): boolean,
|
|
1468
|
-
/**
|
|
1469
|
-
* Add to client's in memory attributes storage the attributes in 'attributes'.
|
|
1470
|
-
*
|
|
1471
|
-
* @param {Attributes} attributes Object with attributes to store
|
|
1472
|
-
* @returns true if attributes were stored an false otherwise
|
|
1473
|
-
*/
|
|
1474
|
-
setAttributes(attributes: Attributes): boolean,
|
|
1475
|
-
/**
|
|
1476
|
-
* Return all the attributes stored in client's in memory attributes storage.
|
|
1477
|
-
*
|
|
1478
|
-
* @returns {Attributes} returns all the stored attributes
|
|
1479
|
-
*/
|
|
1480
|
-
getAttributes(): Attributes,
|
|
1481
|
-
/**
|
|
1482
|
-
* Remove all the stored attributes in the client's in memory attribute storage.
|
|
1483
|
-
*
|
|
1484
|
-
* @returns {boolean} true if all attribute were removed and false otherwise
|
|
1485
|
-
*/
|
|
1486
|
-
clearAttributes(): boolean
|
|
1487
|
-
}
|
|
216
|
+
interface ISDK extends IBasicSDK<IClient, IManager> { }
|
|
1488
217
|
/**
|
|
1489
|
-
* This represents the interface for the Client instance with asynchronous
|
|
218
|
+
* This represents the interface for the Client instance with asynchronous method calls and server-side SDK, where we don't have only one key.
|
|
1490
219
|
* @interface IAsyncClient
|
|
1491
220
|
* @extends IBasicClient
|
|
1492
221
|
*/
|
|
1493
|
-
interface IAsyncClient extends
|
|
1494
|
-
/**
|
|
1495
|
-
* Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
|
|
1496
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1497
|
-
* NOTE: Treatment will be a promise only in async storages, like REDIS.
|
|
1498
|
-
* @function getTreatment
|
|
1499
|
-
* @param {string} key - The string key representing the consumer.
|
|
1500
|
-
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1501
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1502
|
-
* @returns {AsyncTreatment} Treatment promise which will resolve to the treatment string.
|
|
1503
|
-
*/
|
|
1504
|
-
getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
|
|
1505
|
-
/**
|
|
1506
|
-
* Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
|
|
1507
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1508
|
-
* NOTE: Treatment will be a promise only in async storages, like REDIS.
|
|
1509
|
-
* @function getTreatmentWithConfig
|
|
1510
|
-
* @param {string} key - The string key representing the consumer.
|
|
1511
|
-
* @param {string} splitName - The string that represents the split we wan't to get the treatment.
|
|
1512
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1513
|
-
* @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise which will resolve to the TreatmentWithConfig object.
|
|
1514
|
-
*/
|
|
1515
|
-
getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
|
|
1516
|
-
/**
|
|
1517
|
-
* Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
|
|
1518
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1519
|
-
* @function getTreatments
|
|
1520
|
-
* @param {string} key - The string key representing the consumer.
|
|
1521
|
-
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1522
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1523
|
-
* @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
|
|
1524
|
-
*/
|
|
1525
|
-
getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
|
|
1526
|
-
/**
|
|
1527
|
-
* 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.
|
|
1528
|
-
* For usage on NodeJS as we don't have only one key.
|
|
1529
|
-
* @function getTreatmentsWithConfig
|
|
1530
|
-
* @param {string} key - The string key representing the consumer.
|
|
1531
|
-
* @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
|
|
1532
|
-
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1533
|
-
* @returns {AsyncTreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
|
|
1534
|
-
*/
|
|
1535
|
-
getTreatmentsWithConfig(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
|
|
1536
|
-
/**
|
|
1537
|
-
* Tracks an event to be fed to the results product on Split Webconsole and returns a promise to signal when the event was successfully queued (or not).
|
|
1538
|
-
* @function track
|
|
1539
|
-
* @param {SplitKey} key - The key that identifies the entity related to this event.
|
|
1540
|
-
* @param {string} trafficType - The traffic type of the entity related to this event.
|
|
1541
|
-
* @param {string} eventType - The event type corresponding to this event.
|
|
1542
|
-
* @param {number=} value - The value of this event.
|
|
1543
|
-
* @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
|
|
1544
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
|
|
1545
|
-
*/
|
|
1546
|
-
track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
|
|
1547
|
-
}
|
|
222
|
+
interface IAsyncClient extends IAsyncClientSS, EventEmitter { }
|
|
1548
223
|
/**
|
|
1549
|
-
*
|
|
1550
|
-
* @interface
|
|
1551
|
-
* @extends IStatusInterface
|
|
224
|
+
* This represents the interface for the SDK instance with asynchronous method calls and server-side API, where we don't have only one key.
|
|
225
|
+
* @interface IAsyncSDK
|
|
1552
226
|
*/
|
|
1553
|
-
interface
|
|
1554
|
-
/**
|
|
1555
|
-
* Get the array of Split names.
|
|
1556
|
-
* @function names
|
|
1557
|
-
* @returns {SplitNames} The lists of Split names.
|
|
1558
|
-
*/
|
|
1559
|
-
names(): SplitNames;
|
|
1560
|
-
/**
|
|
1561
|
-
* Get the array of splits data in SplitView format.
|
|
1562
|
-
* @function splits
|
|
1563
|
-
* @returns {SplitViews} The list of SplitIO.SplitView.
|
|
1564
|
-
*/
|
|
1565
|
-
splits(): SplitViews;
|
|
1566
|
-
/**
|
|
1567
|
-
* Get the data of a split in SplitView format.
|
|
1568
|
-
* @function split
|
|
1569
|
-
* @param {string} splitName The name of the split we wan't to get info of.
|
|
1570
|
-
* @returns {SplitView | null} The SplitIO.SplitView of the given split or null if the split is not found.
|
|
1571
|
-
*/
|
|
1572
|
-
split(splitName: string): SplitView | null;
|
|
1573
|
-
}
|
|
227
|
+
interface IAsyncSDK extends IBasicSDK<IAsyncClient, IAsyncManager> { }
|
|
1574
228
|
/**
|
|
1575
|
-
*
|
|
1576
|
-
* @interface
|
|
1577
|
-
* @extends IStatusInterface
|
|
229
|
+
* This represents the interface for the Client instance with attributes binding, synchronous method calls, and client-side API, where each client has a key associated and optionally a traffic type.
|
|
230
|
+
* @interface IBrowserClient
|
|
1578
231
|
*/
|
|
1579
|
-
interface
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
names(): SplitNamesAsync;
|
|
232
|
+
interface IBrowserClient extends IClientWithKeyLegacy, EventEmitter { }
|
|
233
|
+
/**
|
|
234
|
+
* This represents the interface for the SDK instance with synchronous method calls and client-side API, where client instances have a key associated and optionally a traffic type.
|
|
235
|
+
* @interface IBrowserSDK
|
|
236
|
+
*/
|
|
237
|
+
interface IBrowserSDK extends ISDKWithUserConsent<IBrowserClient, IManager> {
|
|
1586
238
|
/**
|
|
1587
|
-
*
|
|
1588
|
-
* @function
|
|
1589
|
-
* @returns {
|
|
239
|
+
* Returns the default client instance of the SDK, associated with the key and optional traffic type provided on settings.
|
|
240
|
+
* @function client
|
|
241
|
+
* @returns {IClient} The client instance.
|
|
1590
242
|
*/
|
|
1591
|
-
|
|
243
|
+
client(): IBrowserClient,
|
|
1592
244
|
/**
|
|
1593
|
-
*
|
|
1594
|
-
* @function
|
|
1595
|
-
* @param {
|
|
1596
|
-
* @
|
|
245
|
+
* Returns a shared client of the SDK, associated with the given key and optional traffic type.
|
|
246
|
+
* @function client
|
|
247
|
+
* @param {SplitKey} key The key for the new client instance.
|
|
248
|
+
* @param {string=} trafficType The traffic type of the provided key.
|
|
249
|
+
* @returns {IClientWithKeyLegacy} The client instance.
|
|
1597
250
|
*/
|
|
1598
|
-
|
|
251
|
+
client(key: SplitKey, trafficType?: string): IBrowserClient,
|
|
1599
252
|
}
|
|
1600
253
|
}
|