@splitsoftware/splitio-browserjs 1.0.0-rc.0 → 1.0.0-rc.2

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