@splitsoftware/splitio-commons 1.6.2-rc.2 → 1.6.2-rc.3

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