@splitsoftware/splitio-commons 1.2.1-rc.0 → 1.2.1-rc.4

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 (238) 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 +1 -1
  28. package/cjs/listeners/node.js +1 -1
  29. package/cjs/logger/constants.js +4 -2
  30. package/cjs/logger/index.js +2 -2
  31. package/cjs/logger/messages/debug.js +1 -1
  32. package/cjs/logger/messages/error.js +2 -2
  33. package/cjs/logger/messages/info.js +3 -3
  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 +9 -9
  39. package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
  40. package/cjs/sdkClient/clientCS.js +2 -2
  41. package/cjs/sdkClient/clientInputValidation.js +14 -14
  42. package/cjs/sdkClient/sdkClient.js +3 -3
  43. package/cjs/sdkClient/sdkClientMethod.js +1 -1
  44. package/cjs/sdkClient/sdkClientMethodCS.js +6 -6
  45. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +8 -8
  46. package/cjs/sdkFactory/index.js +9 -8
  47. package/cjs/sdkManager/index.js +11 -11
  48. package/cjs/services/splitApi.js +3 -2
  49. package/cjs/services/splitHttpClient.js +2 -2
  50. package/cjs/storages/KeyBuilder.js +2 -2
  51. package/cjs/storages/KeyBuilderCS.js +2 -2
  52. package/cjs/storages/KeyBuilderSS.js +1 -1
  53. package/cjs/storages/findLatencyIndex.js +1 -1
  54. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
  55. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
  56. package/cjs/storages/inLocalStorage/index.js +4 -4
  57. package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
  58. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  59. package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
  60. package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
  61. package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
  62. package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
  63. package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
  64. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
  65. package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
  66. package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
  67. package/cjs/storages/inRedis/RedisAdapter.js +16 -10
  68. package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
  69. package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
  70. package/cjs/storages/inRedis/index.js +1 -1
  71. package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
  72. package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
  73. package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
  74. package/cjs/storages/pluggable/index.js +6 -6
  75. package/cjs/sync/offline/LocalhostFromFile.js +1 -1
  76. package/cjs/sync/offline/LocalhostFromObject.js +1 -1
  77. package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
  78. package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
  79. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
  80. package/cjs/sync/offline/syncManagerOffline.js +1 -1
  81. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
  82. package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
  83. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
  84. package/cjs/sync/polling/pollingManagerCS.js +8 -7
  85. package/cjs/sync/polling/pollingManagerSS.js +5 -4
  86. package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
  87. package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
  88. package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
  89. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  90. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
  91. package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
  92. package/cjs/sync/streaming/AuthClient/index.js +3 -3
  93. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
  94. package/cjs/sync/streaming/SSEHandler/index.js +3 -3
  95. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
  96. package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
  97. package/cjs/sync/streaming/pushManager.js +27 -19
  98. package/cjs/sync/submitters/eventsSyncTask.js +4 -3
  99. package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
  100. package/cjs/sync/submitters/impressionsSyncTask.js +11 -3
  101. package/cjs/sync/submitters/metricsSyncTask.js +3 -3
  102. package/cjs/sync/submitters/submitterManager.js +6 -5
  103. package/cjs/sync/submitters/submitterSyncTask.js +1 -1
  104. package/cjs/sync/syncManagerOnline.js +8 -13
  105. package/cjs/trackers/eventTracker.js +3 -3
  106. package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
  107. package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
  108. package/cjs/trackers/impressionsTracker.js +3 -3
  109. package/cjs/utils/MinEvents.js +2 -1
  110. package/cjs/utils/inputValidation/apiKey.js +1 -1
  111. package/cjs/utils/inputValidation/attribute.js +4 -4
  112. package/cjs/utils/inputValidation/attributes.js +2 -2
  113. package/cjs/utils/inputValidation/event.js +1 -1
  114. package/cjs/utils/inputValidation/eventProperties.js +7 -5
  115. package/cjs/utils/inputValidation/eventValue.js +1 -1
  116. package/cjs/utils/inputValidation/key.js +6 -5
  117. package/cjs/utils/inputValidation/preloadedData.js +8 -8
  118. package/cjs/utils/inputValidation/split.js +1 -1
  119. package/cjs/utils/inputValidation/splits.js +2 -2
  120. package/cjs/utils/inputValidation/trafficType.js +1 -1
  121. package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
  122. package/cjs/utils/jwt/index.js +1 -1
  123. package/cjs/utils/key/index.js +3 -3
  124. package/cjs/utils/lang/index.js +2 -14
  125. package/cjs/utils/murmur3/common.js +1 -1
  126. package/cjs/utils/murmur3/murmur3.js +10 -10
  127. package/cjs/utils/murmur3/murmur3_128.js +1 -1
  128. package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
  129. package/cjs/utils/murmur3/murmur3_64.js +1 -1
  130. package/cjs/utils/settingsValidation/index.js +7 -10
  131. package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
  132. package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
  133. package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
  134. package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
  135. package/cjs/utils/settingsValidation/logger/commons.js +1 -1
  136. package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
  137. package/cjs/utils/settingsValidation/runtime.js +11 -0
  138. package/cjs/utils/settingsValidation/splitFilters.js +1 -1
  139. package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
  140. package/cjs/utils/timeTracker/index.js +3 -3
  141. package/esm/evaluator/matchers/ew.js +4 -4
  142. package/esm/integrations/ga/GoogleAnalyticsToSplit.js +4 -2
  143. package/esm/integrations/ga/SplitToGoogleAnalytics.js +4 -2
  144. package/esm/logger/constants.js +1 -1
  145. package/esm/logger/messages/error.js +1 -1
  146. package/esm/logger/messages/info.js +2 -2
  147. package/esm/sdkFactory/index.js +1 -0
  148. package/esm/services/splitApi.js +2 -1
  149. package/esm/storages/inLocalStorage/index.js +1 -1
  150. package/esm/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
  151. package/esm/storages/inMemory/InMemoryStorage.js +1 -1
  152. package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
  153. package/esm/storages/inRedis/RedisAdapter.js +7 -1
  154. package/esm/storages/pluggable/index.js +2 -2
  155. package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
  156. package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
  157. package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
  158. package/esm/sync/polling/pollingManagerCS.js +2 -1
  159. package/esm/sync/polling/pollingManagerSS.js +2 -1
  160. package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
  161. package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
  162. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
  163. package/esm/sync/streaming/pushManager.js +13 -5
  164. package/esm/sync/submitters/eventsSyncTask.js +5 -4
  165. package/esm/sync/submitters/impressionsSyncTask.js +9 -1
  166. package/esm/sync/submitters/submitterManager.js +2 -1
  167. package/esm/sync/syncManagerOnline.js +8 -13
  168. package/esm/utils/inputValidation/eventProperties.js +4 -2
  169. package/esm/utils/inputValidation/key.js +2 -1
  170. package/esm/utils/lang/index.js +2 -13
  171. package/esm/utils/settingsValidation/index.js +3 -6
  172. package/esm/utils/settingsValidation/runtime.js +7 -0
  173. package/package.json +6 -6
  174. package/src/evaluator/matchers/ew.ts +4 -4
  175. package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
  176. package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
  177. package/src/integrations/types.ts +5 -0
  178. package/src/logger/constants.ts +1 -1
  179. package/src/logger/messages/error.ts +1 -1
  180. package/src/logger/messages/info.ts +2 -2
  181. package/src/logger/types.ts +4 -0
  182. package/src/sdkFactory/index.ts +1 -0
  183. package/src/storages/inLocalStorage/index.ts +1 -1
  184. package/src/storages/inMemory/ImpressionsCacheInMemory.ts +22 -1
  185. package/src/storages/inMemory/InMemoryStorage.ts +1 -1
  186. package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
  187. package/src/storages/pluggable/index.ts +2 -2
  188. package/src/storages/types.ts +6 -2
  189. package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
  190. package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
  191. package/src/sync/polling/fetchers/types.ts +1 -0
  192. package/src/sync/polling/pollingManagerCS.ts +3 -6
  193. package/src/sync/polling/pollingManagerSS.ts +3 -8
  194. package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -1
  195. package/src/sync/polling/types.ts +0 -12
  196. package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -1
  197. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
  198. package/src/sync/streaming/pushManager.ts +19 -16
  199. package/src/sync/streaming/types.ts +5 -25
  200. package/src/sync/submitters/eventsSyncTask.ts +6 -4
  201. package/src/sync/submitters/impressionsSyncTask.ts +12 -1
  202. package/src/sync/submitters/submitterManager.ts +4 -8
  203. package/src/sync/syncManagerOnline.ts +14 -24
  204. package/src/types.ts +15 -0
  205. package/src/utils/inputValidation/eventProperties.ts +4 -2
  206. package/src/utils/lang/index.ts +0 -14
  207. package/src/utils/settingsValidation/index.ts +3 -6
  208. package/src/utils/settingsValidation/runtime.ts +9 -0
  209. package/src/utils/settingsValidation/types.ts +6 -6
  210. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +2 -2
  211. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +2 -3
  212. package/types/integrations/types.d.ts +4 -0
  213. package/types/logger/constants.d.ts +1 -1
  214. package/types/logger/types.d.ts +4 -0
  215. package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
  216. package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
  217. package/types/storages/inMemory/index.d.ts +10 -0
  218. package/types/storages/parseSegments.d.ts +6 -0
  219. package/types/storages/types.d.ts +3 -1
  220. package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
  221. package/types/sync/polling/fetchers/types.d.ts +1 -1
  222. package/types/sync/polling/pollingManagerCS.d.ts +2 -5
  223. package/types/sync/polling/pollingManagerSS.d.ts +2 -5
  224. package/types/sync/polling/types.d.ts +0 -11
  225. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
  226. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
  227. package/types/sync/streaming/pushManager.d.ts +3 -7
  228. package/types/sync/streaming/pushManagerCS.d.ts +1 -12
  229. package/types/sync/streaming/pushManagerSS.d.ts +1 -11
  230. package/types/sync/streaming/types.d.ts +3 -23
  231. package/types/sync/submitters/submitterManager.d.ts +2 -4
  232. package/types/sync/syncManagerOnline.d.ts +3 -3
  233. package/types/types.d.ts +15 -0
  234. package/types/utils/lang/index.d.ts +0 -4
  235. package/types/utils/settingsValidation/runtime/browser.d.ts +2 -0
  236. package/types/utils/settingsValidation/runtime/node.d.ts +2 -0
  237. package/types/utils/settingsValidation/runtime.d.ts +2 -0
  238. package/types/utils/settingsValidation/types.d.ts +6 -6
@@ -19,7 +19,8 @@ import { hash64 } from '../../utils/murmur3/murmur3_64';
19
19
  * - for server-side if key is not provided in settings.
20
20
  * - for client-side, with support for multiple clients, if key is provided in settings
21
21
  */
22
- export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth, platform, settings) {
22
+ export function pushManagerFactory(params, pollingManager) {
23
+ var settings = params.settings, storage = params.storage, splitApi = params.splitApi, readiness = params.readiness, platform = params.platform;
23
24
  // `userKey` is the matching key of main client in client-side SDK.
24
25
  // It can be used to check if running on client-side or server-side SDK.
25
26
  var userKey = settings.core.key ? getMatching(settings.core.key) : undefined;
@@ -33,14 +34,14 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
33
34
  log.warn(STREAMING_FALLBACK, [e]);
34
35
  return;
35
36
  }
36
- var authenticate = authenticateFactory(fetchAuth);
37
+ var authenticate = authenticateFactory(splitApi.fetchAuth);
37
38
  // init feedback loop
38
39
  var pushEmitter = new platform.EventEmitter();
39
40
  var sseHandler = SSEHandlerFactory(log, pushEmitter);
40
41
  sseClient.setEventHandler(sseHandler);
41
42
  // init workers
42
43
  // MySegmentsUpdateWorker (client-side) are initiated in `add` method
43
- var segmentsUpdateWorker = userKey ? undefined : new SegmentsUpdateWorker(storage.segments, pollingManager.segmentsSyncTask);
44
+ var segmentsUpdateWorker = userKey ? undefined : new SegmentsUpdateWorker(pollingManager.segmentsSyncTask, storage.segments);
44
45
  // For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
45
46
  var splitsUpdateWorker = new SplitsUpdateWorker(storage.splits, pollingManager.splitsSyncTask, readiness.splits, userKey ? undefined : pollingManager.segmentsSyncTask);
46
47
  // [Only for client-side] map of hashes to user keys, to dispatch MY_SEGMENTS_UPDATE events to the corresponding MySegmentsUpdateWorker
@@ -54,6 +55,7 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
54
55
  // It is used to halt the `connectPush` process if it was in progress.
55
56
  var disconnected;
56
57
  // flag that indicates a PUSH_NONRETRYABLE_ERROR, condition with which starting pushManager again is ignored.
58
+ // true if STREAMING_DISABLED control event, or 'pushEnabled: false', or non-recoverable SSE or Auth errors.
57
59
  var disabled; // `disabled` implies `disconnected === true`
58
60
  /** PushManager functions related to initialization */
59
61
  var connectPushRetryBackoff = new Backoff(connectPush, settings.scheduler.pushRetryBackoffBase);
@@ -254,13 +256,15 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
254
256
  return objectAssign(
255
257
  // Expose Event Emitter functionality and Event constants
256
258
  Object.create(pushEmitter), {
257
- // Stop/pause push mode
259
+ // Stop/pause push mode.
260
+ // It doesn't emit events. Neither PUSH_SUBSYSTEM_DOWN to start polling.
258
261
  stop: function () {
259
262
  disconnectPush(); // `handleNonRetryableError` cannot be used as `stop`, because it emits PUSH_SUBSYSTEM_DOWN event, which starts polling.
260
263
  if (userKey)
261
264
  this.remove(userKey); // Necessary to properly resume streaming in client-side (e.g., RN SDK transition to foreground).
262
265
  },
263
- // Start/resume push mode
266
+ // Start/resume push mode.
267
+ // It eventually emits PUSH_SUBSYSTEM_DOWN, that starts polling, or PUSH_SUBSYSTEM_UP, that executes a syncAll
264
268
  start: function () {
265
269
  // Guard condition to avoid calling `connectPush` again if the `start` method is called multiple times or if push has been disabled.
266
270
  if (disabled || disconnected === false)
@@ -271,6 +275,10 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
271
275
  else
272
276
  setTimeout(connectPush); // server-side runs in next cycle as in client-side, for consistency with client-side
273
277
  },
278
+ // true/false if start or stop was called last respectively
279
+ isRunning: function () {
280
+ return disconnected === false;
281
+ },
274
282
  // [Only for client-side]
275
283
  add: function (userKey, mySegmentsSyncTask) {
276
284
  var hash = hashUserKey(userKey);
@@ -1,11 +1,12 @@
1
1
  import { submitterSyncTaskFactory } from './submitterSyncTask';
2
- import { SUBMITTERS_PUSH_FULL_EVENTS_QUEUE } from '../../logger/constants';
2
+ import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
3
+ var DATA_NAME = 'events';
3
4
  /**
4
5
  * Sync task that periodically posts tracked events
5
6
  */
6
7
  export function eventsSyncTaskFactory(log, postEventsBulk, eventsCache, eventsPushRate, eventsFirstPushWindow, latencyTracker) {
7
8
  // don't retry events.
8
- var syncTask = submitterSyncTaskFactory(log, postEventsBulk, eventsCache, eventsPushRate, 'queued events', latencyTracker);
9
+ var syncTask = submitterSyncTaskFactory(log, postEventsBulk, eventsCache, eventsPushRate, DATA_NAME, latencyTracker);
9
10
  // Set a timer for the first push of events,
10
11
  if (eventsFirstPushWindow > 0) {
11
12
  var stopEventPublisherTimeout_1;
@@ -19,9 +20,9 @@ export function eventsSyncTaskFactory(log, postEventsBulk, eventsCache, eventsPu
19
20
  originalStop_1();
20
21
  };
21
22
  }
22
- // register eventsSubmitter to be executed when events cache is full
23
+ // register events submitter to be executed when events cache is full
23
24
  eventsCache.setOnFullQueueCb(function () {
24
- log.info(SUBMITTERS_PUSH_FULL_EVENTS_QUEUE);
25
+ log.info(SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
25
26
  syncTask.execute();
26
27
  });
27
28
  return syncTask;
@@ -1,5 +1,7 @@
1
1
  import { groupBy, forOwn } from '../../utils/lang';
2
2
  import { submitterSyncTaskFactory } from './submitterSyncTask';
3
+ import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
4
+ var DATA_NAME = 'impressions';
3
5
  /**
4
6
  * Converts `impressions` data from cache into request payload.
5
7
  */
@@ -32,5 +34,11 @@ export function fromImpressionsCollector(sendLabels, data) {
32
34
  export function impressionsSyncTaskFactory(log, postTestImpressionsBulk, impressionsCache, impressionsRefreshRate, sendLabels, latencyTracker) {
33
35
  if (sendLabels === void 0) { sendLabels = false; }
34
36
  // retry impressions only once.
35
- return submitterSyncTaskFactory(log, postTestImpressionsBulk, impressionsCache, impressionsRefreshRate, 'impressions', latencyTracker, fromImpressionsCollector.bind(undefined, sendLabels), 1);
37
+ var syncTask = submitterSyncTaskFactory(log, postTestImpressionsBulk, impressionsCache, impressionsRefreshRate, DATA_NAME, latencyTracker, fromImpressionsCollector.bind(undefined, sendLabels), 1);
38
+ // register impressions submitter to be executed when impressions cache is full
39
+ impressionsCache.setOnFullQueueCb(function () {
40
+ log.info(SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
41
+ syncTask.execute();
42
+ });
43
+ return syncTask;
36
44
  }
@@ -2,7 +2,8 @@ import { syncTaskComposite } from '../syncTaskComposite';
2
2
  import { eventsSyncTaskFactory } from './eventsSyncTask';
3
3
  import { impressionsSyncTaskFactory } from './impressionsSyncTask';
4
4
  import { impressionCountsSyncTaskFactory } from './impressionCountsSyncTask';
5
- export function submitterManagerFactory(settings, storage, splitApi) {
5
+ export function submitterManagerFactory(params) {
6
+ var settings = params.settings, storage = params.storage, splitApi = params.splitApi;
6
7
  var log = settings.log;
7
8
  var submitters = [
8
9
  impressionsSyncTaskFactory(log, splitApi.postTestImpressionsBulk, storage.impressions, settings.scheduler.impressionsRefreshRate, settings.core.labelsEnabled),
@@ -13,18 +13,17 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
13
13
  /**
14
14
  * SyncManager factory for modular SDK
15
15
  */
16
- return function (_a) {
17
- var settings = _a.settings, platform = _a.platform, splitApi = _a.splitApi, storage = _a.storage, readiness = _a.readiness;
18
- var log = settings.log;
16
+ return function (params) {
17
+ var _a = params.settings, log = _a.log, streamingEnabled = _a.streamingEnabled;
19
18
  /** Polling Manager */
20
- var pollingManager = pollingManagerFactory && pollingManagerFactory(splitApi, storage, readiness, settings);
19
+ var pollingManager = pollingManagerFactory && pollingManagerFactory(params);
21
20
  /** Push Manager */
22
- var pushManager = settings.streamingEnabled && pollingManager && pushManagerFactory ?
23
- pushManagerFactory(pollingManager, storage, readiness, splitApi.fetchAuth, platform, settings) :
21
+ var pushManager = streamingEnabled && pollingManager && pushManagerFactory ?
22
+ pushManagerFactory(params, pollingManager) :
24
23
  undefined;
25
24
  /** Submitter Manager */
26
25
  // It is not inyected as push and polling managers, because at the moment it is required
27
- var submitter = submitterManagerFactory(settings, storage, splitApi);
26
+ var submitter = submitterManagerFactory(params);
28
27
  /** Sync Manager logic */
29
28
  function startPolling() {
30
29
  if (pollingManager.isRunning()) {
@@ -55,9 +54,6 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
55
54
  * Method used to start the syncManager for the first time, or resume it after being stopped.
56
55
  */
57
56
  start: function () {
58
- if (running)
59
- return;
60
- running = true;
61
57
  // start syncing splits and segments
62
58
  if (pollingManager) {
63
59
  if (pushManager) {
@@ -75,14 +71,12 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
75
71
  // start periodic data recording (events, impressions, telemetry).
76
72
  if (submitter)
77
73
  submitter.start();
74
+ running = true;
78
75
  },
79
76
  /**
80
77
  * Method used to stop/pause the syncManager.
81
78
  */
82
79
  stop: function () {
83
- if (!running)
84
- return;
85
- running = false;
86
80
  // stop syncing
87
81
  if (pushManager)
88
82
  pushManager.stop();
@@ -91,6 +85,7 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
91
85
  // stop periodic data recording (events, impressions, telemetry).
92
86
  if (submitter)
93
87
  submitter.stop();
88
+ running = false;
94
89
  },
95
90
  isRunning: function () {
96
91
  return running;
@@ -1,4 +1,5 @@
1
- import { isObject, shallowClone, isString, isFiniteNumber, isBoolean } from '../lang';
1
+ import { isObject, isString, isFiniteNumber, isBoolean } from '../lang';
2
+ import { objectAssign } from '../lang/objectAssign';
2
3
  import { ERROR_NOT_PLAIN_OBJECT, ERROR_SIZE_EXCEEDED, WARN_SETTING_NULL, WARN_TRIMMING_PROPERTIES } from '../../logger/constants';
3
4
  var ECMA_SIZES = {
4
5
  NULL: 0,
@@ -17,7 +18,8 @@ export function validateEventProperties(log, maybeProperties, method) {
17
18
  return { properties: false, size: BASE_EVENT_SIZE };
18
19
  }
19
20
  var keys = Object.keys(maybeProperties);
20
- var clone = shallowClone(maybeProperties);
21
+ // Shallow clone
22
+ var clone = objectAssign({}, maybeProperties);
21
23
  // To avoid calculating the size twice we'll return it from here.
22
24
  var output = {
23
25
  properties: clone,
@@ -35,7 +35,8 @@ export function validateKey(log, maybeKey, method) {
35
35
  var bucketingKey = validateKeyValue(log, maybeKey.bucketingKey, method, 'bucketingKey');
36
36
  if (matchingKey && bucketingKey)
37
37
  return {
38
- matchingKey: matchingKey, bucketingKey: bucketingKey
38
+ matchingKey: matchingKey,
39
+ bucketingKey: bucketingKey
39
40
  };
40
41
  log.error(ERROR_INVALID_KEY_OBJECT, [method]);
41
42
  return false;
@@ -1,4 +1,4 @@
1
- import { __spreadArrays } from "tslib";
1
+ import { __spreadArray } from "tslib";
2
2
  /**
3
3
  * Checks if the target string ends with the sub string.
4
4
  */
@@ -179,21 +179,10 @@ export function merge(target, source) {
179
179
  });
180
180
  if (rest && rest.length) {
181
181
  var nextSource = rest.splice(0, 1)[0];
182
- res = merge.apply(void 0, __spreadArrays([res, nextSource], rest));
182
+ res = merge.apply(void 0, __spreadArray([res, nextSource], rest, false));
183
183
  }
184
184
  return res;
185
185
  }
186
- /**
187
- * Shallow clone an object
188
- */
189
- export function shallowClone(obj) {
190
- var keys = Object.keys(obj);
191
- var output = {};
192
- for (var i = 0; i < keys.length; i++) {
193
- output[keys[i]] = obj[keys[i]];
194
- }
195
- return output;
196
- }
197
186
  /**
198
187
  * Checks if the target string starts with the sub string.
199
188
  */
@@ -33,6 +33,8 @@ var base = {
33
33
  eventsPushRate: 60,
34
34
  // how many events will be queued before flushing
35
35
  eventsQueueSize: 500,
36
+ // how many impressions will be queued before flushing
37
+ impressionsQueueSize: 30000,
36
38
  // backoff base seconds to wait before re attempting to connect to push notifications
37
39
  pushRetryBackoffBase: 1,
38
40
  },
@@ -64,10 +66,6 @@ var base = {
64
66
  impressionsMode: OPTIMIZED,
65
67
  localhostMode: undefined
66
68
  },
67
- runtime: {
68
- ip: false,
69
- hostname: false
70
- },
71
69
  // Logger
72
70
  log: undefined
73
71
  };
@@ -114,8 +112,7 @@ export function settingsValidation(config, validationParams) {
114
112
  }
115
113
  // Current ip/hostname information
116
114
  // @ts-ignore, modify readonly prop
117
- if (runtime)
118
- withDefaults.runtime = runtime(withDefaults);
115
+ withDefaults.runtime = runtime(withDefaults);
119
116
  // ensure a valid list of integrations.
120
117
  // `integrations` returns an array of valid integration items.
121
118
  // @ts-ignore, modify readonly prop
@@ -0,0 +1,7 @@
1
+ // For client-side SDKs, machine IP and Hostname are not captured and sent to Split backend.
2
+ export function validateRuntime() {
3
+ return {
4
+ ip: false,
5
+ hostname: false
6
+ };
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.2.1-rc.0",
3
+ "version": "1.2.1-rc.4",
4
4
  "description": "Split Javascript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -20,8 +20,8 @@
20
20
  "check:lint": "eslint src --ext .js,.ts",
21
21
  "check:types": "tsc --noEmit",
22
22
  "build": "npm run build:cjs && npm run build:esm",
23
- "build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types --importHelpers",
24
- "build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs --importHelpers",
23
+ "build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types",
24
+ "build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs",
25
25
  "test": "jest",
26
26
  "test:coverage": "jest --coverage",
27
27
  "publish:rc": "npm run check && npm run test && npm run build && npm publish --tag rc",
@@ -44,7 +44,7 @@
44
44
  "bugs": "https://github.com/splitio/javascript-commons/issues",
45
45
  "homepage": "https://github.com/splitio/javascript-commons#readme",
46
46
  "dependencies": {
47
- "tslib": "^2.1.0"
47
+ "tslib": "^2.3.1"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/google.analytics": "0.0.40",
@@ -58,7 +58,7 @@
58
58
  "eslint": "^7.32.0",
59
59
  "eslint-plugin-compat": "3.7.0",
60
60
  "eslint-plugin-import": "^2.25.3",
61
- "fetch-mock": "^9.10.7",
61
+ "fetch-mock": "^9.11.0",
62
62
  "ioredis": "^4.28.0",
63
63
  "jest": "^27.2.3",
64
64
  "jest-localstorage-mock": "^2.4.3",
@@ -68,7 +68,7 @@
68
68
  "redis-server": "1.2.2",
69
69
  "rimraf": "^3.0.2",
70
70
  "ts-jest": "^27.0.5",
71
- "typescript": "^4.0.2"
71
+ "typescript": "4.4.4"
72
72
  },
73
73
  "sideEffects": false
74
74
  }
@@ -1,13 +1,13 @@
1
1
  import { ENGINE_MATCHER_ENDS_WITH } from '../../logger/constants';
2
2
  import { ILogger } from '../../logger/types';
3
- import { endsWith as strEndsWith } from '../../utils/lang';
3
+ import { endsWith } from '../../utils/lang';
4
4
 
5
5
  export function endsWithMatcherContext(log: ILogger, ruleAttr: string[]) /*: Function */ {
6
6
  return function endsWithMatcher(runtimeAttr: string): boolean {
7
- let endsWith = ruleAttr.some(e => strEndsWith(runtimeAttr, e));
7
+ let strEndsWith = ruleAttr.some(e => endsWith(runtimeAttr, e));
8
8
 
9
- log.debug(ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr, endsWith]);
9
+ log.debug(ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr, strEndsWith]);
10
10
 
11
- return endsWith;
11
+ return strEndsWith;
12
12
  };
13
13
  }
@@ -1,11 +1,14 @@
1
- import { IIntegrationFactoryParams } from '../types';
1
+ import { IIntegrationFactoryParams, IntegrationFactory } from '../types';
2
2
  import { GaToSplit } from './GaToSplit';
3
3
  import { GoogleAnalyticsToSplitOptions } from './types';
4
4
 
5
- export function GoogleAnalyticsToSplit(options: GoogleAnalyticsToSplitOptions) {
5
+ export function GoogleAnalyticsToSplit(options: GoogleAnalyticsToSplitOptions): IntegrationFactory {
6
6
 
7
7
  // GaToSplit integration factory
8
- return (params: IIntegrationFactoryParams) => {
8
+ function GoogleAnalyticsToSplitFactory(params: IIntegrationFactoryParams) {
9
9
  return GaToSplit(options, params);
10
- };
10
+ }
11
+
12
+ GoogleAnalyticsToSplitFactory.type = 'GOOGLE_ANALYTICS_TO_SPLIT';
13
+ return GoogleAnalyticsToSplitFactory;
11
14
  }
@@ -1,11 +1,14 @@
1
- import { IIntegrationFactoryParams } from '../types';
1
+ import { IIntegrationFactoryParams, IntegrationFactory } from '../types';
2
2
  import { SplitToGa } from './SplitToGa';
3
3
  import { SplitToGoogleAnalyticsOptions } from './types';
4
4
 
5
- export function SplitToGoogleAnalytics(options: SplitToGoogleAnalyticsOptions = {}) {
5
+ export function SplitToGoogleAnalytics(options: SplitToGoogleAnalyticsOptions = {}): IntegrationFactory {
6
6
 
7
7
  // SplitToGa integration factory
8
- return (params: IIntegrationFactoryParams) => {
8
+ function SplitToGoogleAnalyticsFactory(params: IIntegrationFactoryParams) {
9
9
  return new SplitToGa(params.settings.log, options);
10
- };
10
+ }
11
+
12
+ SplitToGoogleAnalyticsFactory.type = 'SPLIT_TO_GOOGLE_ANALYTICS';
13
+ return SplitToGoogleAnalyticsFactory;
11
14
  }
@@ -12,3 +12,8 @@ export interface IIntegrationFactoryParams {
12
12
  storage: { events: IEventsCacheBase }
13
13
  settings: ISettings
14
14
  }
15
+
16
+ export type IntegrationFactory = {
17
+ readonly type: string
18
+ (params: IIntegrationFactoryParams): IIntegration | void
19
+ }
@@ -61,7 +61,7 @@ export const STREAMING_RECONNECT = 111;
61
61
  export const STREAMING_CONNECTING = 112;
62
62
  export const STREAMING_DISABLED = 113;
63
63
  export const STREAMING_DISCONNECTING = 114;
64
- export const SUBMITTERS_PUSH_FULL_EVENTS_QUEUE = 115;
64
+ export const SUBMITTERS_PUSH_FULL_QUEUE = 115;
65
65
  export const SUBMITTERS_PUSH = 116;
66
66
  export const SYNC_START_POLLING = 117;
67
67
  export const SYNC_CONTINUE_POLLING = 118;
@@ -13,7 +13,7 @@ export const codesError: [number, string][] = [
13
13
  [c.ERROR_SYNC_OFFLINE_LOADING, c.LOG_PREFIX_SYNC_OFFLINE + 'There was an issue loading the mock Splits data, no changes will be applied to the current cache. %s'],
14
14
  [c.ERROR_STREAMING_SSE, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to connect or error on streaming connection, with error message: %s'],
15
15
  [c.ERROR_STREAMING_AUTH, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to authenticate for streaming. Error: %s.'],
16
- [c.ERROR_HTTP, ' Response status is not OK. Status: %s. URL: %s. Message: %s'],
16
+ [c.ERROR_HTTP, 'Response status is not OK. Status: %s. URL: %s. Message: %s'],
17
17
  // client status
18
18
  [c.ERROR_CLIENT_LISTENER, 'A listener was added for %s on the SDK, which has already fired and won\'t be emitted again. The callback won\'t be executed.'],
19
19
  [c.ERROR_CLIENT_DESTROYED, '%s: Client has already been destroyed - no calls possible.'],
@@ -20,7 +20,7 @@ export const codesInfo: [number, string][] = codesWarn.concat([
20
20
  [c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
21
21
  [c.POLLING_STOP, c.LOG_PREFIX_SYNC_POLLING + 'Stopping polling'],
22
22
  [c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying download of splits #%s. Reason: %s'],
23
- [c.SUBMITTERS_PUSH_FULL_EVENTS_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full events queue and reseting timer.'],
23
+ [c.SUBMITTERS_PUSH_FULL_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full %s queue and reseting timer.'],
24
24
  [c.SUBMITTERS_PUSH, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Pushing %s %s.'],
25
25
  [c.STREAMING_REFRESH_TOKEN, c.LOG_PREFIX_SYNC_STREAMING + 'Refreshing streaming token in %s seconds, and connecting streaming in %s seconds.'],
26
26
  [c.STREAMING_RECONNECT, c.LOG_PREFIX_SYNC_STREAMING + 'Attempting to reconnect streaming in %s seconds.'],
@@ -29,5 +29,5 @@ export const codesInfo: [number, string][] = codesWarn.concat([
29
29
  [c.STREAMING_DISCONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Disconnecting streaming.'],
30
30
  [c.SYNC_START_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming not available. Starting polling.'],
31
31
  [c.SYNC_CONTINUE_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming couldn\'t connect. Continue polling.'],
32
- [c.SYNC_STOP_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming (re)connected. Syncing and stopping polling.'],
32
+ [c.SYNC_STOP_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming connected. Syncing and stopping polling.'],
33
33
  ]);
@@ -9,11 +9,15 @@ export interface ILoggerOptions {
9
9
  export interface ILogger {
10
10
  setLogLevel(logLevel: LogLevel): void
11
11
 
12
+ debug(msg: any): void
12
13
  debug(msg: string | number, args?: any[]): void
13
14
 
15
+ info(msg: any): void
14
16
  info(msg: string | number, args?: any[]): void
15
17
 
18
+ warn(msg: any): void
16
19
  warn(msg: string | number, args?: any[]): void
17
20
 
21
+ error(msg: any): void
18
22
  error(msg: string | number, args?: any[]): void
19
23
  }
@@ -33,6 +33,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
33
33
 
34
34
  // @TODO consider passing the settings object, so that each storage access only what it needs
35
35
  const storageFactoryParams: IStorageFactoryParams = {
36
+ impressionsQueueSize: settings.scheduler.impressionsQueueSize,
36
37
  eventsQueueSize: settings.scheduler.eventsQueueSize,
37
38
  optimize: shouldBeOptimized(settings),
38
39
 
@@ -40,7 +40,7 @@ export function InLocalStorage(options: InLocalStorageOptions = {}): IStorageSyn
40
40
  return {
41
41
  splits: new SplitsCacheInLocal(log, keys, expirationTimestamp, params.splitFiltersValidation),
42
42
  segments: new MySegmentsCacheInLocal(log, keys),
43
- impressions: new ImpressionsCacheInMemory(),
43
+ impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
44
44
  impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
45
45
  events: new EventsCacheInMemory(params.eventsQueueSize),
46
46
 
@@ -3,13 +3,34 @@ import { ImpressionDTO } from '../../types';
3
3
 
4
4
  export class ImpressionsCacheInMemory implements IImpressionsCacheSync {
5
5
 
6
- private queue: ImpressionDTO[] = [];
6
+ private onFullQueue?: () => void;
7
+ private readonly maxQueue: number;
8
+ private queue: ImpressionDTO[];
9
+
10
+ /**
11
+ *
12
+ * @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
13
+ * Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
14
+ */
15
+ constructor(impressionsQueueSize: number = 0) {
16
+ this.maxQueue = impressionsQueueSize;
17
+ this.queue = [];
18
+ }
19
+
20
+ setOnFullQueueCb(cb: () => void) {
21
+ this.onFullQueue = cb;
22
+ }
7
23
 
8
24
  /**
9
25
  * Store impressions in sequential order
10
26
  */
11
27
  track(data: ImpressionDTO[]) {
12
28
  this.queue.push(...data);
29
+
30
+ // Check if the cache queue is full and we need to flush it.
31
+ if (this.maxQueue > 0 && this.queue.length >= this.maxQueue && this.onFullQueue) {
32
+ this.onFullQueue();
33
+ }
13
34
  }
14
35
 
15
36
  /**
@@ -16,7 +16,7 @@ export function InMemoryStorageFactory(params: IStorageFactoryParams): IStorageS
16
16
  return {
17
17
  splits: new SplitsCacheInMemory(),
18
18
  segments: new SegmentsCacheInMemory(),
19
- impressions: new ImpressionsCacheInMemory(),
19
+ impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
20
20
  impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
21
21
  events: new EventsCacheInMemory(params.eventsQueueSize),
22
22
 
@@ -16,7 +16,7 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
16
16
  return {
17
17
  splits: new SplitsCacheInMemory(),
18
18
  segments: new MySegmentsCacheInMemory(),
19
- impressions: new ImpressionsCacheInMemory(),
19
+ impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
20
20
  impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
21
21
  events: new EventsCacheInMemory(params.eventsQueueSize),
22
22
 
@@ -63,7 +63,7 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
63
63
 
64
64
  const prefix = validatePrefix(options.prefix);
65
65
 
66
- function PluggableStorageFactory({ log, metadata, onReadyCb, mode, eventsQueueSize, optimize }: IStorageFactoryParams): IStorageAsync {
66
+ function PluggableStorageFactory({ log, metadata, onReadyCb, mode, eventsQueueSize, impressionsQueueSize, optimize }: IStorageFactoryParams): IStorageAsync {
67
67
  const keys = new KeyBuilderSS(prefix, metadata);
68
68
  const wrapper = wrapperAdapter(log, options.wrapper);
69
69
  const isPartialConsumer = mode === CONSUMER_PARTIAL_MODE;
@@ -74,7 +74,7 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
74
74
  return {
75
75
  splits: new SplitsCachePluggable(log, keys, wrapper),
76
76
  segments: new SegmentsCachePluggable(log, keys, wrapper),
77
- impressions: isPartialConsumer ? new ImpressionsCacheInMemory() : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
77
+ impressions: isPartialConsumer ? new ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
78
78
  impressionCounts: optimize ? new ImpressionCountsCacheInMemory() : undefined,
79
79
  events: isPartialConsumer ? promisifyEventsTrack(new EventsCacheInMemory(eventsQueueSize)) : new EventsCachePluggable(log, keys.buildEventsKey(), wrapper, metadata),
80
80
  // @TODO add telemetry cache when required
@@ -298,7 +298,7 @@ export interface IRecorderCacheProducerSync<T> {
298
298
  // @TODO names are inconsistent with spec
299
299
  /* Checks if cache is empty. Returns true if the cache was just created or cleared */
300
300
  isEmpty(): boolean
301
- /* clears cache data */
301
+ /* Clears cache data */
302
302
  clear(): void
303
303
  /* Gets cache data */
304
304
  state(): T
@@ -307,10 +307,13 @@ export interface IRecorderCacheProducerSync<T> {
307
307
 
308
308
  export interface IImpressionsCacheSync extends IImpressionsCacheBase, IRecorderCacheProducerSync<ImpressionDTO[]> {
309
309
  track(data: ImpressionDTO[]): void
310
+ /* Registers callback for full queue */
311
+ setOnFullQueueCb(cb: () => void): void
310
312
  }
311
313
 
312
314
  export interface IEventsCacheSync extends IEventsCacheBase, IRecorderCacheProducerSync<SplitIO.EventData[]> {
313
315
  track(data: SplitIO.EventData, size?: number): boolean
316
+ /* Registers callback for full queue */
314
317
  setOnFullQueueCb(cb: () => void): void
315
318
  }
316
319
 
@@ -423,6 +426,7 @@ export type DataLoader = (storage: IStorageSync, matchingKey: string) => void
423
426
 
424
427
  export interface IStorageFactoryParams {
425
428
  log: ILogger,
429
+ impressionsQueueSize?: number,
426
430
  eventsQueueSize?: number,
427
431
  optimize?: boolean /* whether create the `impressionCounts` cache (OPTIMIZED impression mode) or not (DEBUG impression mode) */,
428
432
 
@@ -443,7 +447,7 @@ export interface IStorageFactoryParams {
443
447
  export type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
444
448
 
445
449
  export type IStorageSyncFactory = {
446
- type: StorageType,
450
+ readonly type: StorageType,
447
451
  (params: IStorageFactoryParams): IStorageSync
448
452
  }
449
453
 
@@ -82,7 +82,7 @@ export function splitsParserFromFileFactory(): ISplitsParser {
82
82
  try {
83
83
  data = fs.readFileSync(filePath, 'utf-8');
84
84
  } catch (e) {
85
- log.error(e.message);
85
+ log.error(e && (e as Error).message);
86
86
 
87
87
  return {};
88
88
  }
@@ -6,9 +6,10 @@ import { IMySegmentsFetcher } from './types';
6
6
  * Factory of MySegments fetcher.
7
7
  * MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors.
8
8
  */
9
- export function mySegmentsFetcherFactory(fetchMySegments: IFetchMySegments, userMatchingKey: string): IMySegmentsFetcher {
9
+ export function mySegmentsFetcherFactory(fetchMySegments: IFetchMySegments): IMySegmentsFetcher {
10
10
 
11
11
  return function mySegmentsFetcher(
12
+ userMatchingKey: string,
12
13
  noCache?: boolean,
13
14
  // Optional decorator for `fetchMySegments` promise, such as timeout or time tracker
14
15
  decorator?: (promise: Promise<IResponse>) => Promise<IResponse>
@@ -15,6 +15,7 @@ export type ISegmentChangesFetcher = (
15
15
  ) => Promise<ISegmentChangesResponse[]>
16
16
 
17
17
  export type IMySegmentsFetcher = (
18
+ userMatchingKey: string,
18
19
  noCache?: boolean,
19
20
  decorator?: (promise: Promise<IResponse>) => Promise<IResponse>
20
21
  ) => Promise<string[]>