@splitsoftware/splitio-commons 1.6.2-rc.0 → 1.6.2-rc.10

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