@splitsoftware/splitio-commons 1.2.0 → 1.2.1-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 (376) hide show
  1. package/cjs/evaluator/Engine.js +6 -6
  2. package/cjs/evaluator/combiners/and.js +1 -1
  3. package/cjs/evaluator/combiners/ifelseif.js +2 -2
  4. package/cjs/evaluator/condition/engineUtils.js +2 -2
  5. package/cjs/evaluator/condition/index.js +4 -4
  6. package/cjs/evaluator/index.js +5 -5
  7. package/cjs/evaluator/matchers/cont_all.js +1 -1
  8. package/cjs/evaluator/matchers/cont_any.js +1 -1
  9. package/cjs/evaluator/matchers/cont_str.js +1 -1
  10. package/cjs/evaluator/matchers/dependency.js +1 -1
  11. package/cjs/evaluator/matchers/eq_set.js +1 -1
  12. package/cjs/evaluator/matchers/ew.js +3 -3
  13. package/cjs/evaluator/matchers/part_of.js +1 -1
  14. package/cjs/evaluator/matchers/segment.js +1 -1
  15. package/cjs/evaluator/matchers/sw.js +1 -1
  16. package/cjs/evaluator/matchers/whitelist.js +1 -1
  17. package/cjs/evaluator/matchersTransform/index.js +12 -12
  18. package/cjs/evaluator/parser/index.js +6 -6
  19. package/cjs/evaluator/treatments/index.js +1 -1
  20. package/cjs/evaluator/value/index.js +1 -1
  21. package/cjs/evaluator/value/sanitize.js +4 -4
  22. package/cjs/integrations/browser.js +3 -3
  23. package/cjs/integrations/ga/GaToSplit.js +14 -14
  24. package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +5 -3
  25. package/cjs/integrations/ga/SplitToGa.js +1 -1
  26. package/cjs/integrations/ga/SplitToGoogleAnalytics.js +4 -2
  27. package/cjs/listeners/browser.js +15 -11
  28. package/cjs/listeners/node.js +1 -1
  29. package/cjs/logger/constants.js +8 -3
  30. package/cjs/logger/index.js +2 -2
  31. package/cjs/logger/messages/debug.js +4 -4
  32. package/cjs/logger/messages/error.js +5 -4
  33. package/cjs/logger/messages/info.js +10 -8
  34. package/cjs/logger/messages/warn.js +1 -1
  35. package/cjs/logger/sdkLogger.js +1 -1
  36. package/cjs/readiness/readinessManager.js +2 -2
  37. package/cjs/readiness/sdkReadinessManager.js +4 -4
  38. package/cjs/sdkClient/client.js +13 -11
  39. package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
  40. package/cjs/sdkClient/clientCS.js +4 -3
  41. package/cjs/sdkClient/clientInputValidation.js +20 -22
  42. package/cjs/sdkClient/sdkClient.js +3 -6
  43. package/cjs/sdkClient/sdkClientMethod.js +1 -1
  44. package/cjs/sdkClient/sdkClientMethodCS.js +6 -10
  45. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +7 -15
  46. package/cjs/sdkFactory/index.js +14 -12
  47. package/cjs/sdkFactory/userConsentProps.js +37 -0
  48. package/cjs/sdkManager/index.js +11 -11
  49. package/cjs/services/splitApi.js +3 -2
  50. package/cjs/services/splitHttpClient.js +3 -3
  51. package/cjs/storages/KeyBuilder.js +2 -6
  52. package/cjs/storages/KeyBuilderCS.js +13 -3
  53. package/cjs/storages/KeyBuilderSS.js +1 -1
  54. package/cjs/storages/findLatencyIndex.js +1 -1
  55. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +24 -4
  56. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
  57. package/cjs/storages/inLocalStorage/index.js +4 -4
  58. package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
  59. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  60. package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
  61. package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
  62. package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
  63. package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
  64. package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
  65. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
  66. package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
  67. package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
  68. package/cjs/storages/inRedis/RedisAdapter.js +24 -11
  69. package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
  70. package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
  71. package/cjs/storages/inRedis/index.js +1 -1
  72. package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
  73. package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
  74. package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
  75. package/cjs/storages/pluggable/index.js +6 -6
  76. package/cjs/sync/offline/LocalhostFromFile.js +1 -1
  77. package/cjs/sync/offline/LocalhostFromObject.js +1 -1
  78. package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
  79. package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
  80. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
  81. package/cjs/sync/offline/syncManagerOffline.js +1 -1
  82. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
  83. package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
  84. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
  85. package/cjs/sync/polling/pollingManagerCS.js +8 -7
  86. package/cjs/sync/polling/pollingManagerSS.js +5 -4
  87. package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
  88. package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
  89. package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
  90. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  91. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
  92. package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
  93. package/cjs/sync/streaming/AuthClient/index.js +4 -5
  94. package/cjs/sync/streaming/SSEClient/index.js +2 -1
  95. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
  96. package/cjs/sync/streaming/SSEHandler/index.js +3 -3
  97. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
  98. package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
  99. package/cjs/sync/streaming/pushManager.js +46 -35
  100. package/cjs/sync/submitters/eventsSyncTask.js +17 -5
  101. package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
  102. package/cjs/sync/submitters/impressionsSyncTask.js +15 -3
  103. package/cjs/sync/submitters/metricsSyncTask.js +3 -3
  104. package/cjs/sync/submitters/submitterManager.js +6 -5
  105. package/cjs/sync/submitters/submitterSyncTask.js +1 -1
  106. package/cjs/sync/syncManagerOnline.js +21 -17
  107. package/cjs/trackers/eventTracker.js +11 -4
  108. package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
  109. package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
  110. package/cjs/trackers/impressionObserver/utils.js +8 -1
  111. package/cjs/trackers/impressionsTracker.js +9 -8
  112. package/cjs/utils/MinEvents.js +2 -1
  113. package/cjs/utils/consent.js +10 -0
  114. package/cjs/utils/constants/index.js +5 -1
  115. package/cjs/utils/inputValidation/apiKey.js +1 -1
  116. package/cjs/utils/inputValidation/attribute.js +4 -4
  117. package/cjs/utils/inputValidation/attributes.js +2 -2
  118. package/cjs/utils/inputValidation/event.js +1 -1
  119. package/cjs/utils/inputValidation/eventProperties.js +7 -5
  120. package/cjs/utils/inputValidation/eventValue.js +1 -1
  121. package/cjs/utils/inputValidation/key.js +6 -5
  122. package/cjs/utils/inputValidation/preloadedData.js +8 -8
  123. package/cjs/utils/inputValidation/split.js +1 -1
  124. package/cjs/utils/inputValidation/splits.js +2 -2
  125. package/cjs/utils/inputValidation/trafficType.js +1 -1
  126. package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
  127. package/cjs/utils/jwt/index.js +1 -1
  128. package/cjs/utils/key/index.js +3 -3
  129. package/cjs/utils/lang/index.js +13 -16
  130. package/cjs/utils/lang/maps.js +16 -2
  131. package/cjs/utils/murmur3/common.js +1 -1
  132. package/cjs/utils/murmur3/legacy.js +44 -0
  133. package/cjs/utils/murmur3/murmur3.js +10 -10
  134. package/cjs/utils/murmur3/murmur3_128.js +1 -1
  135. package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
  136. package/cjs/utils/murmur3/murmur3_64.js +1 -1
  137. package/cjs/utils/promise/timeout.js +1 -1
  138. package/cjs/utils/settingsValidation/consent.js +16 -0
  139. package/cjs/utils/settingsValidation/impressionsMode.js +6 -6
  140. package/cjs/utils/settingsValidation/index.js +32 -14
  141. package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
  142. package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
  143. package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
  144. package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
  145. package/cjs/utils/settingsValidation/logger/commons.js +1 -1
  146. package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
  147. package/cjs/utils/settingsValidation/runtime.js +11 -0
  148. package/cjs/utils/settingsValidation/splitFilters.js +1 -1
  149. package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
  150. package/cjs/utils/timeTracker/index.js +3 -3
  151. package/esm/evaluator/matchers/ew.js +4 -4
  152. package/esm/integrations/ga/GoogleAnalyticsToSplit.js +4 -2
  153. package/esm/integrations/ga/SplitToGoogleAnalytics.js +4 -2
  154. package/esm/listeners/browser.js +14 -10
  155. package/esm/logger/constants.js +5 -2
  156. package/esm/logger/messages/debug.js +3 -3
  157. package/esm/logger/messages/error.js +4 -3
  158. package/esm/logger/messages/info.js +9 -7
  159. package/esm/sdkClient/client.js +4 -2
  160. package/esm/sdkClient/clientCS.js +2 -1
  161. package/esm/sdkClient/clientInputValidation.js +6 -8
  162. package/esm/sdkClient/sdkClient.js +1 -4
  163. package/esm/sdkClient/sdkClientMethodCS.js +1 -5
  164. package/esm/sdkClient/sdkClientMethodCSWithTT.js +1 -9
  165. package/esm/sdkFactory/index.js +8 -6
  166. package/esm/sdkFactory/userConsentProps.js +33 -0
  167. package/esm/services/splitApi.js +2 -1
  168. package/esm/services/splitHttpClient.js +1 -1
  169. package/esm/storages/KeyBuilder.js +2 -6
  170. package/esm/storages/KeyBuilderCS.js +11 -1
  171. package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +23 -3
  172. package/esm/storages/inLocalStorage/index.js +1 -1
  173. package/esm/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
  174. package/esm/storages/inMemory/InMemoryStorage.js +1 -1
  175. package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
  176. package/esm/storages/inRedis/RedisAdapter.js +15 -2
  177. package/esm/storages/pluggable/index.js +2 -2
  178. package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
  179. package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
  180. package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
  181. package/esm/sync/polling/pollingManagerCS.js +2 -1
  182. package/esm/sync/polling/pollingManagerSS.js +2 -1
  183. package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
  184. package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
  185. package/esm/sync/streaming/AuthClient/index.js +1 -2
  186. package/esm/sync/streaming/SSEClient/index.js +2 -1
  187. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
  188. package/esm/sync/streaming/pushManager.js +34 -23
  189. package/esm/sync/submitters/eventsSyncTask.js +18 -6
  190. package/esm/sync/submitters/impressionsSyncTask.js +13 -1
  191. package/esm/sync/submitters/submitterManager.js +2 -1
  192. package/esm/sync/syncManagerOnline.js +21 -17
  193. package/esm/trackers/eventTracker.js +8 -1
  194. package/esm/trackers/impressionObserver/utils.js +7 -1
  195. package/esm/trackers/impressionsTracker.js +6 -5
  196. package/esm/utils/consent.js +6 -0
  197. package/esm/utils/constants/index.js +4 -0
  198. package/esm/utils/inputValidation/attributes.js +1 -1
  199. package/esm/utils/inputValidation/eventProperties.js +4 -2
  200. package/esm/utils/inputValidation/key.js +2 -1
  201. package/esm/utils/lang/index.js +12 -15
  202. package/esm/utils/lang/maps.js +14 -1
  203. package/esm/utils/murmur3/legacy.js +39 -0
  204. package/esm/utils/promise/timeout.js +1 -1
  205. package/esm/utils/settingsValidation/consent.js +12 -0
  206. package/esm/utils/settingsValidation/impressionsMode.js +7 -7
  207. package/esm/utils/settingsValidation/index.js +28 -10
  208. package/esm/utils/settingsValidation/runtime.js +7 -0
  209. package/package.json +7 -7
  210. package/src/evaluator/matchers/ew.ts +4 -4
  211. package/src/evaluator/parser/index.ts +1 -1
  212. package/src/evaluator/types.ts +2 -2
  213. package/src/evaluator/value/index.ts +2 -2
  214. package/src/evaluator/value/sanitize.ts +2 -2
  215. package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
  216. package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
  217. package/src/integrations/pluggable.ts +2 -2
  218. package/src/integrations/types.ts +5 -0
  219. package/src/listeners/browser.ts +13 -9
  220. package/src/logger/.DS_Store +0 -0
  221. package/src/logger/constants.ts +5 -2
  222. package/src/logger/messages/debug.ts +3 -3
  223. package/src/logger/messages/error.ts +4 -3
  224. package/src/logger/messages/info.ts +9 -7
  225. package/src/logger/types.ts +4 -0
  226. package/src/sdkClient/client.ts +4 -2
  227. package/src/sdkClient/clientCS.ts +3 -1
  228. package/src/sdkClient/clientInputValidation.ts +8 -7
  229. package/src/sdkClient/sdkClient.ts +2 -5
  230. package/src/sdkClient/sdkClientMethodCS.ts +1 -6
  231. package/src/sdkClient/sdkClientMethodCSWithTT.ts +2 -11
  232. package/src/sdkFactory/index.ts +9 -7
  233. package/src/sdkFactory/types.ts +2 -1
  234. package/src/sdkFactory/userConsentProps.ts +40 -0
  235. package/src/services/splitHttpClient.ts +1 -1
  236. package/src/storages/KeyBuilder.ts +2 -6
  237. package/src/storages/KeyBuilderCS.ts +13 -1
  238. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +23 -3
  239. package/src/storages/inLocalStorage/index.ts +1 -1
  240. package/src/storages/inMemory/ImpressionsCacheInMemory.ts +22 -1
  241. package/src/storages/inMemory/InMemoryStorage.ts +1 -1
  242. package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
  243. package/src/storages/inRedis/RedisAdapter.ts +8 -2
  244. package/src/storages/pluggable/index.ts +2 -2
  245. package/src/storages/types.ts +6 -2
  246. package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
  247. package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
  248. package/src/sync/polling/fetchers/types.ts +1 -0
  249. package/src/sync/polling/pollingManagerCS.ts +3 -6
  250. package/src/sync/polling/pollingManagerSS.ts +3 -8
  251. package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -1
  252. package/src/sync/polling/types.ts +0 -12
  253. package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -1
  254. package/src/sync/streaming/AuthClient/index.ts +1 -2
  255. package/src/sync/streaming/SSEClient/index.ts +2 -1
  256. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
  257. package/src/sync/streaming/pushManager.ts +39 -37
  258. package/src/sync/streaming/types.ts +5 -25
  259. package/src/sync/submitters/eventsSyncTask.ts +19 -6
  260. package/src/sync/submitters/impressionsSyncTask.ts +16 -1
  261. package/src/sync/submitters/submitterManager.ts +4 -8
  262. package/src/sync/syncManagerOnline.ts +27 -27
  263. package/src/sync/types.ts +4 -1
  264. package/src/trackers/eventTracker.ts +11 -3
  265. package/src/trackers/impressionObserver/utils.ts +8 -1
  266. package/src/trackers/impressionsTracker.ts +7 -8
  267. package/src/types.ts +26 -1
  268. package/src/utils/consent.ts +8 -0
  269. package/src/utils/constants/index.ts +5 -0
  270. package/src/utils/inputValidation/attributes.ts +1 -2
  271. package/src/utils/inputValidation/eventProperties.ts +4 -2
  272. package/src/utils/lang/index.ts +15 -18
  273. package/src/utils/lang/maps.ts +15 -1
  274. package/src/utils/murmur3/legacy.ts +48 -0
  275. package/src/utils/promise/timeout.ts +1 -1
  276. package/src/utils/settingsValidation/consent.ts +16 -0
  277. package/src/utils/settingsValidation/impressionsMode.ts +8 -8
  278. package/src/utils/settingsValidation/index.ts +29 -10
  279. package/src/utils/settingsValidation/runtime.ts +9 -0
  280. package/src/utils/settingsValidation/types.ts +12 -6
  281. package/types/evaluator/types.d.ts +2 -2
  282. package/types/evaluator/value/index.d.ts +1 -1
  283. package/types/evaluator/value/sanitize.d.ts +1 -1
  284. package/types/integrations/ga/GaToSplitPlugin.d.ts +3 -0
  285. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +2 -2
  286. package/types/integrations/ga/SplitToGaPlugin.d.ts +4 -0
  287. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +2 -3
  288. package/types/integrations/types.d.ts +4 -0
  289. package/types/logger/browser/{DebugLogger.d.ts → debugLogger.d.ts} +0 -0
  290. package/types/logger/browser/{ErrorLogger.d.ts → errorLogger.d.ts} +0 -0
  291. package/types/logger/browser/{InfoLogger.d.ts → infoLogger.d.ts} +0 -0
  292. package/types/logger/browser/{WarnLogger.d.ts → warnLogger.d.ts} +0 -0
  293. package/types/logger/codes.d.ts +2 -0
  294. package/types/logger/codesConstants.d.ts +117 -0
  295. package/types/logger/codesConstantsBrowser.d.ts +2 -0
  296. package/types/logger/codesConstantsNode.d.ts +14 -0
  297. package/types/logger/codesDebug.d.ts +1 -0
  298. package/types/logger/codesDebugBrowser.d.ts +1 -0
  299. package/types/logger/codesDebugNode.d.ts +1 -0
  300. package/types/logger/codesError.d.ts +1 -0
  301. package/types/logger/codesErrorNode.d.ts +1 -0
  302. package/types/logger/codesInfo.d.ts +1 -0
  303. package/types/logger/codesWarn.d.ts +1 -0
  304. package/types/logger/codesWarnNode.d.ts +1 -0
  305. package/types/logger/constants.d.ts +5 -2
  306. package/types/logger/debugLogger.d.ts +2 -0
  307. package/types/logger/errorLogger.d.ts +2 -0
  308. package/types/logger/infoLogger.d.ts +2 -0
  309. package/types/logger/messages/debugBrowser.d.ts +1 -0
  310. package/types/logger/messages/debugNode.d.ts +1 -0
  311. package/types/logger/messages/errorNode.d.ts +1 -0
  312. package/types/logger/messages/warnNode.d.ts +1 -0
  313. package/types/logger/noopLogger.d.ts +2 -0
  314. package/types/logger/types.d.ts +4 -0
  315. package/types/logger/warnLogger.d.ts +2 -0
  316. package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
  317. package/types/sdkClient/clientInputValidation.d.ts +2 -3
  318. package/types/sdkFactory/types.d.ts +1 -1
  319. package/types/sdkFactory/userConsentProps.d.ts +6 -0
  320. package/types/sdkManager/sdkManagerMethod.d.ts +6 -0
  321. package/types/storages/KeyBuilderCS.d.ts +2 -0
  322. package/types/storages/getRegisteredSegments.d.ts +10 -0
  323. package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
  324. package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +51 -0
  325. package/types/storages/inMemory/index.d.ts +10 -0
  326. package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
  327. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -0
  328. package/types/storages/parseSegments.d.ts +6 -0
  329. package/types/storages/pluggable/TelemetryCachePluggable.d.ts +2 -0
  330. package/types/storages/types.d.ts +3 -1
  331. package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
  332. package/types/sync/polling/fetchers/types.d.ts +1 -1
  333. package/types/sync/polling/pollingManagerCS.d.ts +2 -5
  334. package/types/sync/polling/pollingManagerSS.d.ts +2 -5
  335. package/types/sync/polling/syncTasks/splitsSyncTask.copy.d.ts +35 -0
  336. package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +35 -0
  337. package/types/sync/polling/types.d.ts +0 -11
  338. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
  339. package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
  340. package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
  341. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
  342. package/types/sync/streaming/pushManager.d.ts +3 -7
  343. package/types/sync/streaming/pushManagerCS.d.ts +1 -0
  344. package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
  345. package/types/sync/streaming/pushManagerSS.d.ts +1 -0
  346. package/types/sync/streaming/types.d.ts +3 -23
  347. package/types/sync/submitters/submitterManager.d.ts +2 -4
  348. package/types/sync/submitters/telemetrySyncTask.d.ts +17 -0
  349. package/types/sync/syncManagerFromFile.d.ts +2 -0
  350. package/types/sync/syncManagerFromObject.d.ts +2 -0
  351. package/types/sync/syncManagerOffline.d.ts +9 -0
  352. package/types/sync/syncManagerOnline.d.ts +3 -3
  353. package/types/sync/types.d.ts +3 -0
  354. package/types/trackers/eventTracker.d.ts +2 -2
  355. package/types/trackers/impressionObserver/utils.d.ts +4 -0
  356. package/types/trackers/impressionsTracker.d.ts +2 -3
  357. package/types/trackers/telemetryRecorder.d.ts +0 -0
  358. package/types/types.d.ts +22 -0
  359. package/types/utils/EventEmitter.d.ts +4 -0
  360. package/types/utils/consent.d.ts +2 -0
  361. package/types/utils/constants/index.d.ts +3 -0
  362. package/types/utils/lang/errors.d.ts +10 -0
  363. package/types/utils/lang/index.d.ts +6 -5
  364. package/types/utils/lang/maps.d.ts +7 -0
  365. package/types/utils/murmur3/commons.d.ts +12 -0
  366. package/types/utils/murmur3/legacy.d.ts +2 -0
  367. package/types/utils/settingsValidation/buildMetadata.d.ts +3 -0
  368. package/types/utils/settingsValidation/consent.d.ts +6 -0
  369. package/types/utils/settingsValidation/impressionsMode.d.ts +1 -1
  370. package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
  371. package/types/utils/settingsValidation/logger.d.ts +11 -0
  372. package/types/utils/settingsValidation/runtime/browser.d.ts +2 -0
  373. package/types/utils/settingsValidation/runtime/node.d.ts +2 -0
  374. package/types/utils/settingsValidation/runtime.d.ts +2 -0
  375. package/types/utils/settingsValidation/types.d.ts +12 -6
  376. package/types/utils/settingsValidation/userConsent.d.ts +5 -0
@@ -11,7 +11,8 @@ import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
11
11
  */
12
12
  // @TODO missing time tracking to collect telemetry
13
13
  export function clientFactory(params) {
14
- var readinessManager = params.sdkReadinessManager.readinessManager, storage = params.storage, _a = params.settings, log = _a.log, mode = _a.mode, impressionsTracker = params.impressionsTracker, eventTracker = params.eventTracker;
14
+ var readinessManager = params.sdkReadinessManager.readinessManager, storage = params.storage, settings = params.settings, impressionsTracker = params.impressionsTracker, eventTracker = params.eventTracker;
15
+ var log = settings.log, mode = settings.mode;
15
16
  function getTreatment(key, splitName, attributes, withConfig) {
16
17
  if (withConfig === void 0) { withConfig = false; }
17
18
  var wrapUp = function (evaluationResult) {
@@ -95,6 +96,7 @@ export function clientFactory(params) {
95
96
  getTreatmentWithConfig: getTreatmentWithConfig,
96
97
  getTreatments: getTreatments,
97
98
  getTreatmentsWithConfig: getTreatmentsWithConfig,
98
- track: track
99
+ track: track,
100
+ isClientSide: false
99
101
  };
100
102
  }
@@ -16,6 +16,7 @@ export function clientCSDecorator(log, client, key, trafficType) {
16
16
  getTreatments: clientCS.getTreatments.bind(clientCS, key),
17
17
  getTreatmentsWithConfig: clientCS.getTreatmentsWithConfig.bind(clientCS, key),
18
18
  // Key is bound to the `track` method. Same thing happens with trafficType but only if provided
19
- track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key)
19
+ track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
20
+ isClientSide: true
20
21
  });
21
22
  }
@@ -2,12 +2,14 @@ import { objectAssign } from '../utils/lang/objectAssign';
2
2
  import { validateAttributes, validateEvent, validateEventValue, validateEventProperties, validateKey, validateSplit, validateSplits, validateTrafficType, validateIfNotDestroyed, validateIfOperational } from '../utils/inputValidation';
3
3
  import { startsWith } from '../utils/lang';
4
4
  import { CONTROL, CONTROL_WITH_CONFIG } from '../utils/constants';
5
+ import { isStorageSync } from '../trackers/impressionObserver/utils';
5
6
  /**
6
7
  * Decorator that validates the input before actually executing the client methods.
7
8
  * We should "guard" the client here, while not polluting the "real" implementation of those methods.
8
9
  */
9
- export function clientInputValidationDecorator(log, client, readinessManager, isStorageSync) {
10
- if (isStorageSync === void 0) { isStorageSync = false; }
10
+ export function clientInputValidationDecorator(settings, client, readinessManager) {
11
+ var log = settings.log;
12
+ var isSync = isStorageSync(settings);
11
13
  /**
12
14
  * Avoid repeating this validations code
13
15
  */
@@ -27,9 +29,7 @@ export function clientInputValidationDecorator(log, client, readinessManager, is
27
29
  };
28
30
  }
29
31
  function wrapResult(value) {
30
- if (isStorageSync)
31
- return value;
32
- return Promise.resolve(value);
32
+ return isSync ? value : Promise.resolve(value);
33
33
  }
34
34
  function getTreatment(maybeKey, maybeSplit, maybeAttributes) {
35
35
  var params = validateEvaluationParams(maybeKey, maybeSplit, maybeAttributes, 'getTreatment');
@@ -84,9 +84,7 @@ export function clientInputValidationDecorator(log, client, readinessManager, is
84
84
  return client.track(key, tt, event, eventValue, properties, size);
85
85
  }
86
86
  else {
87
- if (isStorageSync)
88
- return false;
89
- return Promise.resolve(false);
87
+ return isSync ? false : Promise.resolve(false);
90
88
  }
91
89
  }
92
90
  return {
@@ -1,5 +1,4 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
- import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE } from '../utils/constants';
3
2
  import { releaseApiKey } from '../utils/inputValidation/apiKey';
4
3
  import { clientFactory } from './client';
5
4
  import { clientInputValidationDecorator } from './clientInputValidation';
@@ -12,9 +11,7 @@ export function sdkClientFactory(params) {
12
11
  // Proto-linkage of the readiness Event Emitter
13
12
  Object.create(sdkReadinessManager.sdkStatus),
14
13
  // Client API (getTreatment* & track methods)
15
- clientInputValidationDecorator(settings.log, clientFactory(params), sdkReadinessManager.readinessManager,
16
- // storage is async if and only if mode is consumer or partial consumer
17
- [CONSUMER_MODE, CONSUMER_PARTIAL_MODE].indexOf(settings.mode) === -1 ? true : false),
14
+ clientInputValidationDecorator(settings, clientFactory(params), sdkReadinessManager.readinessManager),
18
15
  // Sdk destroy
19
16
  {
20
17
  destroy: function () {
@@ -16,12 +16,8 @@ var method = 'Client instantiation';
16
16
  */
17
17
  export function sdkClientMethodCSFactory(params) {
18
18
  var storage = params.storage, syncManager = params.syncManager, sdkReadinessManager = params.sdkReadinessManager, _a = params.settings, key = _a.core.key, readyTimeout = _a.startup.readyTimeout, log = _a.log;
19
- // Keeping similar behaviour as in the isomorphic JS SDK: if settings key is invalid,
20
- // `false` value is used as binded key of the default client, but trafficType is ignored
21
- // @TODO handle as a non-recoverable error
22
- var validKey = validateKey(log, key, method);
23
19
  var mainClientInstance = clientCSDecorator(log, sdkClientFactory(params), // @ts-ignore
24
- validKey);
20
+ key);
25
21
  var parsedDefaultKey = keyParser(key);
26
22
  var defaultInstanceId = buildInstanceId(parsedDefaultKey);
27
23
  // Cache instances created per factory.
@@ -18,16 +18,8 @@ var method = 'Client instantiation';
18
18
  */
19
19
  export function sdkClientMethodCSFactory(params) {
20
20
  var storage = params.storage, syncManager = params.syncManager, sdkReadinessManager = params.sdkReadinessManager, _a = params.settings, _b = _a.core, key = _b.key, trafficType = _b.trafficType, readyTimeout = _a.startup.readyTimeout, log = _a.log;
21
- // Keeping the behaviour as in the isomorphic JS SDK: if settings key or TT are invalid,
22
- // `false` value is used as binded key/TT of the default client, which leads to several issues.
23
- // @TODO update when supporting non-recoverable errors
24
- var validKey = validateKey(log, key, method);
25
- var validTrafficType;
26
- if (trafficType !== undefined) {
27
- validTrafficType = validateTrafficType(log, trafficType, method);
28
- }
29
21
  var mainClientInstance = clientCSDecorator(log, sdkClientFactory(params), // @ts-ignore
30
- validKey, validTrafficType);
22
+ key, trafficType);
31
23
  var parsedDefaultKey = keyParser(key);
32
24
  var defaultInstanceId = buildInstanceId(parsedDefaultKey, trafficType);
33
25
  // Cache instances created per factory.
@@ -8,11 +8,12 @@ import { createLoggerAPI } from '../logger/sdkLogger';
8
8
  import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
9
9
  import { metadataBuilder } from '../storages/metadataBuilder';
10
10
  import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
11
+ import { objectAssign } from '../utils/lang/objectAssign';
11
12
  /**
12
13
  * Modular SDK factory
13
14
  */
14
15
  export function sdkFactory(params) {
15
- var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener, impressionsObserverFactory = params.impressionsObserverFactory, impressionListener = params.impressionListener, integrationsManagerFactory = params.integrationsManagerFactory, sdkManagerFactory = params.sdkManagerFactory, sdkClientMethodFactory = params.sdkClientMethodFactory;
16
+ var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, extraProps = params.extraProps, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener, impressionsObserverFactory = params.impressionsObserverFactory, integrationsManagerFactory = params.integrationsManagerFactory, sdkManagerFactory = params.sdkManagerFactory, sdkClientMethodFactory = params.sdkClientMethodFactory;
16
17
  var log = settings.log;
17
18
  // @TODO handle non-recoverable errors: not start sync, mark the SDK as destroyed, etc.
18
19
  // We will just log and allow for the SDK to end up throwing an SDK_TIMEOUT event for devs to handle.
@@ -22,6 +23,7 @@ export function sdkFactory(params) {
22
23
  var readinessManager = sdkReadinessManager.readinessManager;
23
24
  // @TODO consider passing the settings object, so that each storage access only what it needs
24
25
  var storageFactoryParams = {
26
+ impressionsQueueSize: settings.scheduler.impressionsQueueSize,
25
27
  eventsQueueSize: settings.scheduler.eventsQueueSize,
26
28
  optimize: shouldBeOptimized(settings),
27
29
  // ATM, only used by InLocalStorage
@@ -54,8 +56,8 @@ export function sdkFactory(params) {
54
56
  var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage });
55
57
  // trackers
56
58
  var observer = impressionsObserverFactory && impressionsObserverFactory();
57
- var impressionsTracker = impressionsTrackerFactory(log, storage.impressions, settings, impressionListener, integrationsManager, observer, storage.impressionCounts);
58
- var eventTracker = eventTrackerFactory(log, storage.events, integrationsManager);
59
+ var impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, integrationsManager, observer, storage.impressionCounts);
60
+ var eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager);
59
61
  // signal listener
60
62
  var signalListener = SignalListener && new SignalListener(syncManager, settings, storage, splitApi);
61
63
  // Sdk client and manager
@@ -64,11 +66,11 @@ export function sdkFactory(params) {
64
66
  syncManager && syncManager.start();
65
67
  signalListener && signalListener.start();
66
68
  log.info(NEW_FACTORY);
67
- return {
69
+ // @ts-ignore
70
+ return objectAssign({
68
71
  // Split evaluation and event tracking engine
69
72
  client: clientMethod,
70
73
  // Manager API to explore available information
71
- // @ts-ignore
72
74
  manager: function () {
73
75
  log.debug(RETRIEVE_MANAGER);
74
76
  return managerInstance;
@@ -76,5 +78,5 @@ export function sdkFactory(params) {
76
78
  // Logger wrapper API
77
79
  Logger: createLoggerAPI(settings.log),
78
80
  settings: settings,
79
- };
81
+ }, extraProps && extraProps(settings, syncManager));
80
82
  }
@@ -0,0 +1,33 @@
1
+ import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
2
+ import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
3
+ import { isBoolean } from '../utils/lang';
4
+ // Extend client-side factory instances with user consent getter/setter
5
+ export function userConsentProps(settings, syncManager) {
6
+ var log = settings.log;
7
+ return {
8
+ setUserConsent: function (consent) {
9
+ var _a, _b;
10
+ // validate input param
11
+ if (!isBoolean(consent)) {
12
+ log.warn(ERROR_NOT_BOOLEAN, ['setUserConsent']);
13
+ return false;
14
+ }
15
+ var newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
16
+ if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
17
+ settings.userConsent = newConsentStatus;
18
+ if (consent)
19
+ (_a = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _a === void 0 ? void 0 : _a.start(); // resumes submitters if transitioning to GRANTED
20
+ else
21
+ (_b = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _b === void 0 ? void 0 : _b.stop(); // pauses submitters if transitioning to DECLINED
22
+ log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
23
+ }
24
+ else {
25
+ log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
26
+ }
27
+ return true;
28
+ },
29
+ getUserConsent: function () {
30
+ return settings.userConsent;
31
+ }
32
+ };
33
+ }
@@ -72,7 +72,8 @@ export function splitApiFactory(settings, platform) {
72
72
  return splitHttpClient(url, {
73
73
  // Adding extra headers to send impressions in OPTIMIZED or DEBUG modes.
74
74
  method: 'POST',
75
- body: body, headers: objectAssign({ SplitSDKImpressionsMode: SplitSDKImpressionsMode }, headers)
75
+ body: body,
76
+ headers: objectAssign({ SplitSDKImpressionsMode: SplitSDKImpressionsMode }, headers)
76
77
  });
77
78
  },
78
79
  /**
@@ -43,7 +43,7 @@ export function splitHttpClientFactory(settings, getFetch, getOptions) {
43
43
  return response;
44
44
  })
45
45
  .catch(function (error) {
46
- var resp = error.response;
46
+ var resp = error && error.response;
47
47
  var msg = '';
48
48
  if (resp) { // An HTTP error
49
49
  switch (resp.status) {
@@ -1,12 +1,8 @@
1
- import { endsWith, startsWith } from '../utils/lang';
1
+ import { startsWith } from '../utils/lang';
2
2
  var everythingAtTheEnd = /[^.]+$/;
3
3
  var DEFAULT_PREFIX = 'SPLITIO';
4
4
  export function validatePrefix(prefix) {
5
- return prefix && typeof prefix === 'string' ?
6
- endsWith(prefix, '.' + DEFAULT_PREFIX) ?
7
- prefix : // suffix already appended
8
- prefix + '.' + DEFAULT_PREFIX : // append suffix
9
- DEFAULT_PREFIX; // use default prefix if none is provided
5
+ return prefix ? prefix + '.SPLITIO' : 'SPLITIO';
10
6
  }
11
7
  var KeyBuilder = /** @class */ (function () {
12
8
  function KeyBuilder(prefix) {
@@ -13,9 +13,19 @@ var KeyBuilderCS = /** @class */ (function (_super) {
13
13
  * @override
14
14
  */
15
15
  KeyBuilderCS.prototype.buildSegmentNameKey = function (segmentName) {
16
- return this.matchingKey + "." + this.prefix + ".segment." + segmentName;
16
+ return this.prefix + "." + this.matchingKey + ".segment." + segmentName;
17
17
  };
18
18
  KeyBuilderCS.prototype.extractSegmentName = function (builtSegmentKeyName) {
19
+ var prefix = this.prefix + "." + this.matchingKey + ".segment.";
20
+ if (startsWith(builtSegmentKeyName, prefix))
21
+ return builtSegmentKeyName.substr(prefix.length);
22
+ };
23
+ // @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
24
+ KeyBuilderCS.prototype.buildOldSegmentNameKey = function (segmentName) {
25
+ return this.matchingKey + "." + this.prefix + ".segment." + segmentName;
26
+ };
27
+ // @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
28
+ KeyBuilderCS.prototype.extractOldSegmentKey = function (builtSegmentKeyName) {
19
29
  var prefix = this.matchingKey + "." + this.prefix + ".segment.";
20
30
  if (startsWith(builtSegmentKeyName, prefix))
21
31
  return builtSegmentKeyName.substr(prefix.length);
@@ -57,9 +57,29 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
57
57
  var index;
58
58
  // Scan current values from localStorage
59
59
  var storedSegmentNames = Object.keys(localStorage).reduce(function (accum, key) {
60
- var name = _this.keys.extractSegmentName(key);
61
- if (name)
62
- accum.push(name);
60
+ var segmentName = _this.keys.extractSegmentName(key);
61
+ if (segmentName) {
62
+ accum.push(segmentName);
63
+ }
64
+ else {
65
+ // @BREAKING: This is only to clean up "old" keys. Remove this whole else code block.
66
+ segmentName = _this.keys.extractOldSegmentKey(key);
67
+ if (segmentName) { // this was an old segment key, let's clean up.
68
+ var newSegmentKey = _this.keys.buildSegmentNameKey(segmentName);
69
+ try {
70
+ // If the new format key is not there, create it.
71
+ if (!localStorage.getItem(newSegmentKey) && names.indexOf(segmentName) > -1) {
72
+ localStorage.setItem(newSegmentKey, DEFINED);
73
+ // we are migrating a segment, let's track it.
74
+ accum.push(segmentName);
75
+ }
76
+ localStorage.removeItem(key); // we migrated the current key, let's delete it.
77
+ }
78
+ catch (e) {
79
+ _this.log.error(e);
80
+ }
81
+ }
82
+ }
63
83
  return accum;
64
84
  }, []);
65
85
  // Extreme fast => everything is empty
@@ -30,7 +30,7 @@ export function InLocalStorage(options) {
30
30
  return {
31
31
  splits: new SplitsCacheInLocal(log, keys, expirationTimestamp, params.splitFiltersValidation),
32
32
  segments: new MySegmentsCacheInLocal(log, keys),
33
- impressions: new ImpressionsCacheInMemory(),
33
+ impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
34
34
  impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
35
35
  events: new EventsCacheInMemory(params.eventsQueueSize),
36
36
  destroy: function () {
@@ -1,13 +1,27 @@
1
1
  var ImpressionsCacheInMemory = /** @class */ (function () {
2
- function ImpressionsCacheInMemory() {
2
+ /**
3
+ *
4
+ * @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
5
+ * Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
6
+ */
7
+ function ImpressionsCacheInMemory(impressionsQueueSize) {
8
+ if (impressionsQueueSize === void 0) { impressionsQueueSize = 0; }
9
+ this.maxQueue = impressionsQueueSize;
3
10
  this.queue = [];
4
11
  }
12
+ ImpressionsCacheInMemory.prototype.setOnFullQueueCb = function (cb) {
13
+ this.onFullQueue = cb;
14
+ };
5
15
  /**
6
16
  * Store impressions in sequential order
7
17
  */
8
18
  ImpressionsCacheInMemory.prototype.track = function (data) {
9
19
  var _a;
10
20
  (_a = this.queue).push.apply(_a, data);
21
+ // Check if the cache queue is full and we need to flush it.
22
+ if (this.maxQueue > 0 && this.queue.length >= this.maxQueue && this.onFullQueue) {
23
+ this.onFullQueue();
24
+ }
11
25
  };
12
26
  /**
13
27
  * Clear the data stored on the cache.
@@ -13,7 +13,7 @@ export function InMemoryStorageFactory(params) {
13
13
  return {
14
14
  splits: new SplitsCacheInMemory(),
15
15
  segments: new SegmentsCacheInMemory(),
16
- impressions: new ImpressionsCacheInMemory(),
16
+ impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
17
17
  impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
18
18
  events: new EventsCacheInMemory(params.eventsQueueSize),
19
19
  // When using MEMORY we should clean all the caches to leave them empty
@@ -13,7 +13,7 @@ export function InMemoryStorageCSFactory(params) {
13
13
  return {
14
14
  splits: new SplitsCacheInMemory(),
15
15
  segments: new MySegmentsCacheInMemory(),
16
- impressions: new ImpressionsCacheInMemory(),
16
+ impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
17
17
  impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
18
18
  events: new EventsCacheInMemory(params.eventsQueueSize),
19
19
  // When using MEMORY we should clean all the caches to leave them empty
@@ -143,15 +143,28 @@ var RedisAdapter = /** @class */ (function (_super) {
143
143
  else { // If it IS the string URL, that'll be the first param for ioredis.
144
144
  result.unshift(options.url);
145
145
  }
146
+ if (options.connectionTimeout) {
147
+ merge(opts, { connectTimeout: options.connectionTimeout });
148
+ }
149
+ if (options.tls) {
150
+ merge(opts, { tls: options.tls });
151
+ }
146
152
  return result;
147
153
  };
148
154
  /**
149
155
  * Parses the options into what we care about.
150
156
  */
151
157
  RedisAdapter._defineOptions = function (_a) {
152
- var connectionTimeout = _a.connectionTimeout, operationTimeout = _a.operationTimeout, url = _a.url, host = _a.host, port = _a.port, db = _a.db, pass = _a.pass;
158
+ var connectionTimeout = _a.connectionTimeout, operationTimeout = _a.operationTimeout, url = _a.url, host = _a.host, port = _a.port, db = _a.db, pass = _a.pass, tls = _a.tls;
153
159
  var parsedOptions = {
154
- connectionTimeout: connectionTimeout, operationTimeout: operationTimeout, url: url, host: host, port: port, db: db, pass: pass
160
+ connectionTimeout: connectionTimeout,
161
+ operationTimeout: operationTimeout,
162
+ url: url,
163
+ host: host,
164
+ port: port,
165
+ db: db,
166
+ pass: pass,
167
+ tls: tls
155
168
  };
156
169
  return merge({}, DEFAULT_OPTIONS, parsedOptions);
157
170
  };
@@ -51,7 +51,7 @@ export function PluggableStorage(options) {
51
51
  validatePluggableStorageOptions(options);
52
52
  var prefix = validatePrefix(options.prefix);
53
53
  function PluggableStorageFactory(_a) {
54
- var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb, mode = _a.mode, eventsQueueSize = _a.eventsQueueSize, optimize = _a.optimize;
54
+ var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb, mode = _a.mode, eventsQueueSize = _a.eventsQueueSize, impressionsQueueSize = _a.impressionsQueueSize, optimize = _a.optimize;
55
55
  var keys = new KeyBuilderSS(prefix, metadata);
56
56
  var wrapper = wrapperAdapter(log, options.wrapper);
57
57
  var isPartialConsumer = mode === CONSUMER_PARTIAL_MODE;
@@ -60,7 +60,7 @@ export function PluggableStorage(options) {
60
60
  return {
61
61
  splits: new SplitsCachePluggable(log, keys, wrapper),
62
62
  segments: new SegmentsCachePluggable(log, keys, wrapper),
63
- impressions: isPartialConsumer ? new ImpressionsCacheInMemory() : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
63
+ impressions: isPartialConsumer ? new ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
64
64
  impressionCounts: optimize ? new ImpressionCountsCacheInMemory() : undefined,
65
65
  events: isPartialConsumer ? promisifyEventsTrack(new EventsCacheInMemory(eventsQueueSize)) : new EventsCachePluggable(log, keys.buildEventsKey(), wrapper, metadata),
66
66
  // @TODO add telemetry cache when required
@@ -62,7 +62,7 @@ export function splitsParserFromFileFactory() {
62
62
  data = fs.readFileSync(filePath, 'utf-8');
63
63
  }
64
64
  catch (e) {
65
- log.error(e.message);
65
+ log.error(e && e.message);
66
66
  return {};
67
67
  }
68
68
  if (data === previousMock)
@@ -2,8 +2,8 @@
2
2
  * Factory of MySegments fetcher.
3
3
  * MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors.
4
4
  */
5
- export function mySegmentsFetcherFactory(fetchMySegments, userMatchingKey) {
6
- return function mySegmentsFetcher(noCache,
5
+ export function mySegmentsFetcherFactory(fetchMySegments) {
6
+ return function mySegmentsFetcher(userMatchingKey, noCache,
7
7
  // Optional decorator for `fetchMySegments` promise, such as timeout or time tracker
8
8
  decorator) {
9
9
  var mySegmentsPromise = fetchMySegments(userMatchingKey, noCache);
@@ -1,4 +1,4 @@
1
- import { __spreadArrays } from "tslib";
1
+ import { __spreadArray } from "tslib";
2
2
  function greedyFetch(fetchSegmentChanges, since, segmentName, noCache) {
3
3
  return fetchSegmentChanges(since, segmentName, noCache)
4
4
  .then(function (resp) { return resp.json(); })
@@ -9,7 +9,7 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache) {
9
9
  }
10
10
  else {
11
11
  return Promise.all([json, greedyFetch(fetchSegmentChanges, till, segmentName, noCache)]).then(function (flatMe) {
12
- return __spreadArrays([flatMe[0]], flatMe[1]);
12
+ return __spreadArray([flatMe[0]], flatMe[1], true);
13
13
  });
14
14
  }
15
15
  });
@@ -8,7 +8,8 @@ import { POLLING_SMART_PAUSING, POLLING_START, POLLING_STOP } from '../../logger
8
8
  * Expose start / stop mechanism for polling data from services.
9
9
  * For client-side API with multiple clients.
10
10
  */
11
- export function pollingManagerCSFactory(splitApi, storage, readiness, settings) {
11
+ export function pollingManagerCSFactory(params) {
12
+ var splitApi = params.splitApi, storage = params.storage, readiness = params.readiness, settings = params.settings;
12
13
  var log = settings.log;
13
14
  var splitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
14
15
  // Map of matching keys to their corresponding MySegmentsSyncTask.
@@ -5,7 +5,8 @@ import { POLLING_START, POLLING_STOP, LOG_PREFIX_SYNC_POLLING } from '../../logg
5
5
  /**
6
6
  * Expose start / stop mechanism for pulling data from services.
7
7
  */
8
- export function pollingManagerSSFactory(splitApi, storage, readiness, settings) {
8
+ export function pollingManagerSSFactory(params) {
9
+ var splitApi = params.splitApi, storage = params.storage, readiness = params.readiness, settings = params.settings;
9
10
  var log = settings.log;
10
11
  var splitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
11
12
  var segmentsSyncTask = segmentsSyncTaskFactory(splitApi.fetchSegmentChanges, storage, readiness, settings);
@@ -5,5 +5,5 @@ import { mySegmentsUpdaterFactory } from '../updaters/mySegmentsUpdater';
5
5
  * Creates a sync task that periodically executes a `mySegmentsUpdater` task
6
6
  */
7
7
  export function mySegmentsSyncTaskFactory(fetchMySegments, storage, readiness, settings, matchingKey) {
8
- return syncTaskFactory(settings.log, mySegmentsUpdaterFactory(settings.log, mySegmentsFetcherFactory(fetchMySegments, matchingKey), storage.splits, storage.segments, readiness.segments, settings.startup.requestTimeoutBeforeReady, settings.startup.retriesOnFailureBeforeReady), settings.scheduler.segmentsRefreshRate, 'mySegmentsUpdater');
8
+ return syncTaskFactory(settings.log, mySegmentsUpdaterFactory(settings.log, mySegmentsFetcherFactory(fetchMySegments), storage.splits, storage.segments, readiness.segments, settings.startup.requestTimeoutBeforeReady, settings.startup.retriesOnFailureBeforeReady, matchingKey), settings.scheduler.segmentsRefreshRate, 'mySegmentsUpdater');
9
9
  }
@@ -7,7 +7,7 @@ import { SYNC_MYSEGMENTS_FETCH_RETRY } from '../../../logger/constants';
7
7
  * - updates `mySegmentsCache`
8
8
  * - uses `segmentsEventEmitter` to emit events related to segments data updates
9
9
  */
10
- export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegmentsCache, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady) {
10
+ export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegmentsCache, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady, matchingKey) {
11
11
  var readyOnAlreadyExistentState = true;
12
12
  var startingUp = true;
13
13
  /** timeout and telemetry decorator for `splitChangesFetcher` promise */
@@ -51,7 +51,7 @@ export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, my
51
51
  // If segmentsData is provided, there is no need to fetch mySegments
52
52
  new Promise(function (res) { updateSegments(segmentsData); res(true); }) :
53
53
  // If not provided, fetch mySegments
54
- mySegmentsFetcher(noCache, _promiseDecorator).then(function (segments) {
54
+ mySegmentsFetcher(matchingKey, noCache, _promiseDecorator).then(function (segments) {
55
55
  // Only when we have downloaded segments completely, we should not keep retrying anymore
56
56
  startingUp = false;
57
57
  updateSegments(segments);
@@ -13,8 +13,7 @@ export function authenticateFactory(fetchAuth) {
13
13
  * @param {string[] | undefined} userKeys set of user Keys to track MY_SEGMENTS_CHANGES. It is undefined for server-side API.
14
14
  */
15
15
  return function authenticate(userKeys) {
16
- var authPromise = fetchAuth(userKeys); // errors handled by fetchAuth service
17
- return authPromise
16
+ return fetchAuth(userKeys)
18
17
  .then(function (resp) { return resp.json(); })
19
18
  .then(function (json) {
20
19
  if (json.token) { // empty token when `"pushEnabled": false`
@@ -1,3 +1,4 @@
1
+ import { isString } from '../../../utils/lang';
1
2
  var VERSION = '1.1';
2
3
  var CONTROL_CHANNEL_REGEX = /^control_/;
3
4
  /**
@@ -8,7 +9,7 @@ var CONTROL_CHANNEL_REGEX = /^control_/;
8
9
  */
9
10
  function buildSSEHeaders(settings) {
10
11
  var headers = {
11
- SplitSDKClientKey: settings.core.authorizationKey.slice(-4),
12
+ SplitSDKClientKey: isString(settings.core.authorizationKey) ? settings.core.authorizationKey.slice(-4) : '',
12
13
  SplitSDKVersion: settings.version,
13
14
  };
14
15
  // ip and hostname are false if IPAddressesEnabled is false
@@ -7,7 +7,7 @@ var SegmentsUpdateWorker = /** @class */ (function () {
7
7
  * @param {Object} segmentsCache segments data cache
8
8
  * @param {Object} segmentsSyncTask task for syncing segments data
9
9
  */
10
- function SegmentsUpdateWorker(segmentsCache, segmentsSyncTask) {
10
+ function SegmentsUpdateWorker(segmentsSyncTask, segmentsCache) {
11
11
  this.segmentsCache = segmentsCache;
12
12
  this.segmentsSyncTask = segmentsSyncTask;
13
13
  this.maxChangeNumbers = {};