@splitsoftware/splitio-commons 2.12.0 → 2.12.1

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 (157) hide show
  1. package/CHANGES.txt +5 -1
  2. package/cjs/evaluator/condition/engineUtils.js +2 -2
  3. package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +3 -3
  4. package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
  5. package/cjs/evaluator/matchers/whitelist.js +1 -1
  6. package/cjs/integrations/pluggable.js +1 -1
  7. package/cjs/listeners/node.js +2 -2
  8. package/cjs/logger/constants.js +3 -4
  9. package/cjs/logger/index.js +1 -1
  10. package/cjs/logger/messages/debug.js +1 -1
  11. package/cjs/logger/messages/error.js +1 -1
  12. package/cjs/logger/messages/info.js +2 -3
  13. package/cjs/logger/messages/warn.js +4 -4
  14. package/cjs/sdkClient/client.js +2 -3
  15. package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
  16. package/cjs/sdkClient/clientInputValidation.js +36 -68
  17. package/cjs/sdkClient/identity.js +1 -1
  18. package/cjs/sdkClient/sdkClient.js +19 -7
  19. package/cjs/sdkFactory/index.js +8 -41
  20. package/cjs/services/splitApi.js +13 -13
  21. package/cjs/services/splitHttpClient.js +1 -1
  22. package/cjs/storages/KeyBuilder.js +12 -12
  23. package/cjs/storages/KeyBuilderCS.js +13 -13
  24. package/cjs/storages/KeyBuilderSS.js +15 -15
  25. package/cjs/storages/getRolloutPlan.js +1 -1
  26. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
  27. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
  28. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  29. package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
  30. package/cjs/storages/inMemory/SplitsCacheInMemory.js +1 -1
  31. package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
  32. package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
  33. package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
  34. package/cjs/storages/inRedis/RedisAdapter.js +8 -8
  35. package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -6
  36. package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
  37. package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
  38. package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
  39. package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
  40. package/cjs/storages/pluggable/SplitsCachePluggable.js +4 -4
  41. package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
  42. package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
  43. package/cjs/storages/pluggable/index.js +3 -3
  44. package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
  45. package/cjs/storages/setRolloutPlan.js +3 -3
  46. package/cjs/storages/utils.js +6 -6
  47. package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
  48. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
  49. package/cjs/sync/polling/pollingManagerSS.js +2 -2
  50. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
  51. package/cjs/sync/polling/updaters/splitChangesUpdater.js +12 -10
  52. package/cjs/sync/streaming/SSEClient/index.js +2 -2
  53. package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
  54. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
  55. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
  56. package/cjs/sync/streaming/parseUtils.js +1 -1
  57. package/cjs/sync/submitters/submitter.js +1 -1
  58. package/cjs/trackers/eventTracker.js +10 -12
  59. package/cjs/trackers/impressionObserver/buildKey.js +1 -1
  60. package/cjs/trackers/impressionsTracker.js +37 -20
  61. package/cjs/trackers/uniqueKeysTracker.js +1 -1
  62. package/cjs/utils/inputValidation/apiKey.js +1 -1
  63. package/cjs/utils/inputValidation/attribute.js +2 -2
  64. package/cjs/utils/inputValidation/eventProperties.js +1 -1
  65. package/cjs/utils/inputValidation/isOperational.js +1 -1
  66. package/cjs/utils/lang/index.js +1 -1
  67. package/cjs/utils/lang/sets.js +4 -4
  68. package/cjs/utils/promise/timeout.js +1 -1
  69. package/cjs/utils/settingsValidation/splitFilters.js +2 -2
  70. package/cjs/utils/settingsValidation/url.js +5 -5
  71. package/esm/evaluator/condition/engineUtils.js +2 -2
  72. package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +3 -3
  73. package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
  74. package/esm/evaluator/matchers/whitelist.js +1 -1
  75. package/esm/integrations/pluggable.js +1 -1
  76. package/esm/listeners/node.js +2 -2
  77. package/esm/logger/constants.js +0 -1
  78. package/esm/logger/index.js +1 -1
  79. package/esm/logger/messages/info.js +1 -2
  80. package/esm/logger/messages/warn.js +3 -3
  81. package/esm/sdkClient/client.js +3 -4
  82. package/esm/sdkClient/clientAttributesDecoration.js +3 -3
  83. package/esm/sdkClient/clientInputValidation.js +36 -68
  84. package/esm/sdkClient/identity.js +1 -1
  85. package/esm/sdkClient/sdkClient.js +20 -8
  86. package/esm/sdkFactory/index.js +8 -41
  87. package/esm/services/splitApi.js +13 -13
  88. package/esm/services/splitHttpClient.js +1 -1
  89. package/esm/storages/KeyBuilder.js +12 -12
  90. package/esm/storages/KeyBuilderCS.js +12 -12
  91. package/esm/storages/KeyBuilderSS.js +14 -14
  92. package/esm/storages/getRolloutPlan.js +1 -1
  93. package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  94. package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
  95. package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
  96. package/esm/storages/inRedis/RedisAdapter.js +7 -7
  97. package/esm/storages/inRedis/SplitsCacheInRedis.js +4 -4
  98. package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
  99. package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
  100. package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
  101. package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
  102. package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
  103. package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
  104. package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
  105. package/esm/storages/pluggable/index.js +2 -2
  106. package/esm/storages/pluggable/wrapperAdapter.js +1 -1
  107. package/esm/storages/setRolloutPlan.js +3 -3
  108. package/esm/storages/utils.js +6 -6
  109. package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
  110. package/esm/sync/polling/pollingManagerSS.js +2 -2
  111. package/esm/sync/polling/updaters/segmentChangesUpdater.js +6 -6
  112. package/esm/sync/polling/updaters/splitChangesUpdater.js +12 -10
  113. package/esm/sync/streaming/SSEClient/index.js +2 -2
  114. package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
  115. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
  116. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
  117. package/esm/sync/streaming/parseUtils.js +1 -1
  118. package/esm/sync/submitters/submitter.js +1 -1
  119. package/esm/trackers/eventTracker.js +10 -12
  120. package/esm/trackers/impressionObserver/buildKey.js +1 -1
  121. package/esm/trackers/impressionsTracker.js +38 -21
  122. package/esm/trackers/uniqueKeysTracker.js +1 -1
  123. package/esm/utils/inputValidation/apiKey.js +1 -1
  124. package/esm/utils/inputValidation/attribute.js +2 -2
  125. package/esm/utils/inputValidation/isOperational.js +1 -1
  126. package/esm/utils/lang/sets.js +4 -4
  127. package/esm/utils/promise/timeout.js +1 -1
  128. package/esm/utils/settingsValidation/splitFilters.js +2 -2
  129. package/esm/utils/settingsValidation/url.js +5 -5
  130. package/package.json +5 -5
  131. package/src/dtos/types.ts +15 -15
  132. package/src/evaluator/condition/engineUtils.ts +2 -2
  133. package/src/evaluator/fallbackTreatmentsCalculator/index.ts +23 -41
  134. package/src/evaluator/matchers/whitelist.ts +2 -2
  135. package/src/evaluator/types.ts +2 -2
  136. package/src/evaluator/value/index.ts +1 -1
  137. package/src/integrations/pluggable.ts +1 -1
  138. package/src/logger/constants.ts +0 -1
  139. package/src/logger/messages/info.ts +1 -2
  140. package/src/logger/messages/warn.ts +3 -3
  141. package/src/sdkClient/client.ts +3 -5
  142. package/src/sdkClient/clientInputValidation.ts +38 -61
  143. package/src/sdkClient/sdkClient.ts +20 -5
  144. package/src/sdkFactory/index.ts +10 -47
  145. package/src/sdkFactory/types.ts +6 -3
  146. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -1
  147. package/src/storages/inMemory/SplitsCacheInMemory.ts +1 -1
  148. package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -1
  149. package/src/storages/pluggable/SplitsCachePluggable.ts +1 -1
  150. package/src/storages/setRolloutPlan.ts +2 -2
  151. package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
  152. package/src/sync/polling/updaters/splitChangesUpdater.ts +11 -9
  153. package/src/trackers/eventTracker.ts +7 -10
  154. package/src/trackers/impressionsTracker.ts +42 -26
  155. package/src/trackers/types.ts +3 -1
  156. package/src/utils/lang/sets.ts +4 -2
  157. package/types/splitio.d.ts +22 -18
package/CHANGES.txt CHANGED
@@ -1,5 +1,9 @@
1
+ 2.12.1 (June 25, 2026)
2
+ - Updated internal modules to handle `null` values from `/splitChanges` response.
3
+ - Updated some dependencies for vulnerability fixes.
4
+
1
5
  2.12.0 (February 24, 2026)
2
- - Added support for ioredis v5.
6
+ - Added support for ioredis v5 (Related to issue https://github.com/splitio/javascript-commons/issues/471).
3
7
 
4
8
  2.11.0 (January 28, 2026)
5
9
  - Added functionality to provide metadata alongside SDK update and READY events. Read more in our docs.
@@ -16,10 +16,10 @@ exports.getTreatment = getTreatment;
16
16
  /**
17
17
  * Evaluates the traffic allocation to see if we should apply rollout conditions or not.
18
18
  */
19
- function shouldApplyRollout(trafficAllocation, key, trafficAllocationSeed) {
19
+ function shouldApplyRollout(trafficAllocation, bucketingKey, trafficAllocationSeed) {
20
20
  // For rollout, if traffic allocation for splits is 100%, we don't need to filter it because everything should evaluate the rollout.
21
21
  if (trafficAllocation < 100) {
22
- var _bucket = (0, murmur3_1.bucket)(key, trafficAllocationSeed);
22
+ var _bucket = (0, murmur3_1.bucket)(bucketingKey, trafficAllocationSeed);
23
23
  if (_bucket > trafficAllocation) {
24
24
  return false;
25
25
  }
@@ -24,7 +24,7 @@ function sanitizeGlobal(logger, treatment) {
24
24
  if (treatment === undefined)
25
25
  return undefined;
26
26
  if (!isValidTreatment(treatment)) {
27
- logger.error("Fallback treatments - Discarded fallback: " + FallbackDiscardReason.Treatment);
27
+ logger.error("Fallback treatments - Discarded fallback: ".concat(FallbackDiscardReason.Treatment));
28
28
  return undefined;
29
29
  }
30
30
  return treatment;
@@ -36,11 +36,11 @@ function sanitizeByFlag(logger, byFlagFallbacks) {
36
36
  Object.keys(byFlagFallbacks).forEach(function (flag) {
37
37
  var t = byFlagFallbacks[flag];
38
38
  if (!isValidFlagName(flag)) {
39
- logger.error("Fallback treatments - Discarded flag '" + flag + "': " + FallbackDiscardReason.FlagName);
39
+ logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(FallbackDiscardReason.FlagName));
40
40
  return;
41
41
  }
42
42
  if (!isValidTreatment(t)) {
43
- logger.error("Fallback treatments - Discarded treatment for flag '" + flag + "': " + FallbackDiscardReason.Treatment);
43
+ logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(FallbackDiscardReason.Treatment));
44
44
  return;
45
45
  }
46
46
  sanitizedByFlag[flag] = t;
@@ -4,40 +4,29 @@ exports.FallbackTreatmentsCalculator = exports.FALLBACK_PREFIX = void 0;
4
4
  var constants_1 = require("../../utils/constants");
5
5
  var lang_1 = require("../../utils/lang");
6
6
  exports.FALLBACK_PREFIX = 'fallback - ';
7
- var FallbackTreatmentsCalculator = /** @class */ (function () {
8
- function FallbackTreatmentsCalculator(fallbacks) {
9
- if (fallbacks === void 0) { fallbacks = {}; }
10
- this.fallbacks = fallbacks;
11
- }
12
- FallbackTreatmentsCalculator.prototype.resolve = function (flagName, label) {
7
+ function FallbackTreatmentsCalculator(fallbacks) {
8
+ if (fallbacks === void 0) { fallbacks = {}; }
9
+ return function (flagName, label) {
13
10
  var _a;
14
- var treatment = (_a = this.fallbacks.byFlag) === null || _a === void 0 ? void 0 : _a[flagName];
15
- if (treatment) {
16
- return this.copyWithLabel(treatment, label);
17
- }
18
- if (this.fallbacks.global) {
19
- return this.copyWithLabel(this.fallbacks.global, label);
20
- }
21
- return {
22
- treatment: constants_1.CONTROL,
23
- config: null,
24
- label: label,
25
- };
26
- };
27
- FallbackTreatmentsCalculator.prototype.copyWithLabel = function (fallback, label) {
28
- if ((0, lang_1.isString)(fallback)) {
29
- return {
30
- treatment: fallback,
11
+ if (label === void 0) { label = ''; }
12
+ var fallback = ((_a = fallbacks.byFlag) === null || _a === void 0 ? void 0 : _a[flagName]) || fallbacks.global;
13
+ return fallback ?
14
+ (0, lang_1.isString)(fallback) ?
15
+ {
16
+ treatment: fallback,
17
+ config: null,
18
+ label: "".concat(exports.FALLBACK_PREFIX).concat(label),
19
+ } :
20
+ {
21
+ treatment: fallback.treatment,
22
+ config: fallback.config,
23
+ label: "".concat(exports.FALLBACK_PREFIX).concat(label),
24
+ } :
25
+ {
26
+ treatment: constants_1.CONTROL,
31
27
  config: null,
32
- label: "" + exports.FALLBACK_PREFIX + label,
28
+ label: label,
33
29
  };
34
- }
35
- return {
36
- treatment: fallback.treatment,
37
- config: fallback.config,
38
- label: "" + exports.FALLBACK_PREFIX + label,
39
- };
40
30
  };
41
- return FallbackTreatmentsCalculator;
42
- }());
31
+ }
43
32
  exports.FallbackTreatmentsCalculator = FallbackTreatmentsCalculator;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.whitelistMatcherContext = void 0;
4
4
  function whitelistMatcherContext(ruleAttr) {
5
- var whitelistSet = new Set(ruleAttr);
5
+ var whitelistSet = new Set(ruleAttr || []);
6
6
  return function whitelistMatcher(runtimeAttr) {
7
7
  var isInWhitelist = whitelistSet.has(runtimeAttr);
8
8
  return isInWhitelist;
@@ -16,7 +16,7 @@ function pluggableIntegrationsManagerFactory(integrations, params) {
16
16
  // No need to check if `settings.integrations` is an array of functions. It was already validated
17
17
  integrations.forEach(function (integrationFactory) {
18
18
  var integration = integrationFactory(params);
19
- if (integration && integration.queue)
19
+ if (integration)
20
20
  listeners.push(integration);
21
21
  });
22
22
  // If `listeners` is empty, not return a integration manager
@@ -47,13 +47,13 @@ var NodeSignalListener = /** @class */ (function () {
47
47
  // eslint-disable-next-line no-undef
48
48
  process.kill(process.pid, SIGTERM);
49
49
  };
50
- this.settings.log.debug(constants_1.LOG_PREFIX_CLEANUP + "Split SDK graceful shutdown after SIGTERM.");
50
+ this.settings.log.debug("".concat(constants_1.LOG_PREFIX_CLEANUP, "Split SDK graceful shutdown after SIGTERM."));
51
51
  var handlerResult = null;
52
52
  try {
53
53
  handlerResult = this.handler();
54
54
  }
55
55
  catch (err) {
56
- this.settings.log.error(constants_1.LOG_PREFIX_CLEANUP + "Error with Split SDK graceful shutdown: " + err);
56
+ this.settings.log.error("".concat(constants_1.LOG_PREFIX_CLEANUP, "Error with Split SDK graceful shutdown: ").concat(err));
57
57
  }
58
58
  if ((0, thenable_1.thenable)(handlerResult)) {
59
59
  // Always exit, even with errors. The promise is returned for UT purposes.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUBMITTERS_PUSH_PAGE_HIDDEN = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_DEFAULT = exports.ENGINE_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_RBS_UPDATE = exports.SYNC_SPLITS_UPDATE = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
4
- exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MEMBERSHIPS_UPDATE = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY_FROM_CACHE = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = void 0;
5
- exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_HTTP = exports.ERROR_INVALID_CONFIG_PARAM = void 0;
3
+ exports.ENGINE_VALUE_INVALID = exports.SUBMITTERS_PUSH_PAGE_HIDDEN = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_DEFAULT = exports.ENGINE_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_RBS_UPDATE = exports.SYNC_SPLITS_UPDATE = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
4
+ exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MEMBERSHIPS_UPDATE = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY_FROM_CACHE = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = void 0;
5
+ exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_HTTP = void 0;
6
6
  /**
7
7
  * Message codes used to trim string log messages from commons and client-side API modules,
8
8
  * in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
@@ -36,7 +36,6 @@ exports.ENGINE_MATCHER_RESULT = 40;
36
36
  exports.ENGINE_DEFAULT = 41;
37
37
  exports.CLIENT_READY_FROM_CACHE = 100;
38
38
  exports.CLIENT_READY = 101;
39
- exports.IMPRESSION = 102;
40
39
  exports.IMPRESSION_QUEUEING = 103;
41
40
  exports.NEW_SHARED_CLIENT = 104;
42
41
  exports.NEW_FACTORY = 105;
@@ -91,7 +91,7 @@ var Logger = /** @class */ (function () {
91
91
  Logger.prototype._log = function (method, msg, args) {
92
92
  if (typeof msg === 'number') {
93
93
  var format = this.codes.get(msg);
94
- msg = format ? _sprintf(format, args) : "Message code " + msg + (args ? ', with args: ' + args.toString() : '');
94
+ msg = format ? _sprintf(format, args) : "Message code ".concat(msg).concat(args ? ', with args: ' + args.toString() : '');
95
95
  }
96
96
  else {
97
97
  if (args)
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.codesDebug = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var c = (0, tslib_1.__importStar)(require("../constants"));
5
+ var c = tslib_1.__importStar(require("../constants"));
6
6
  var info_1 = require("./info");
7
7
  exports.codesDebug = info_1.codesInfo.concat([
8
8
  // evaluator
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.codesError = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var c = (0, tslib_1.__importStar)(require("../constants"));
5
+ var c = tslib_1.__importStar(require("../constants"));
6
6
  exports.codesError = [
7
7
  // evaluator
8
8
  [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported targeting rule type found'],
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.codesInfo = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var c = (0, tslib_1.__importStar)(require("../constants"));
5
+ var c = tslib_1.__importStar(require("../constants"));
6
6
  var warn_1 = require("./warn");
7
7
  var READY_MSG = 'Split SDK client is ready';
8
8
  exports.codesInfo = warn_1.codesWarn.concat([
@@ -10,8 +10,7 @@ exports.codesInfo = warn_1.codesWarn.concat([
10
10
  [c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
11
11
  [c.CLIENT_READY, READY_MSG],
12
12
  // SDK
13
- [c.IMPRESSION, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
14
- [c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing corresponding impression.'],
13
+ [c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression. Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
15
14
  [c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
16
15
  [c.NEW_FACTORY, 'New Split SDK instance created. %s'],
17
16
  [c.EVENTS_TRACKER_SUCCESS, c.LOG_PREFIX_EVENTS_TRACKER + 'Successfully queued %s'],
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.codesWarn = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var c = (0, tslib_1.__importStar)(require("../constants"));
5
+ var c = tslib_1.__importStar(require("../constants"));
6
6
  var error_1 = require("./error");
7
7
  exports.codesWarn = error_1.codesError.concat([
8
8
  // evaluator
@@ -24,9 +24,9 @@ exports.codesWarn = error_1.codesError.concat([
24
24
  [c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
25
25
  [c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
26
26
  [c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
27
- [c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in the Split user interface.'],
27
+ [c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in Harness FME UI.'],
28
28
  [c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
29
- [c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding feature flag in this environment, make sure you\'re tracking your events to a valid traffic type defined in the Split user interface.'],
29
+ [c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding feature flag in this environment, make sure you\'re tracking your events to a valid traffic type defined in Harness FME UI.'],
30
30
  [c.WARN_FLAGSET_NOT_CONFIGURED, '%s: you passed %s which is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
31
31
  // initialization / settings validation
32
32
  [c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS + ': %s integration item(s) at settings is invalid. %s'],
@@ -38,5 +38,5 @@ exports.codesWarn = error_1.codesError.concat([
38
38
  [c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing %s notification: %s'],
39
39
  [c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
40
40
  [c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
41
- [c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in the Split user interface.'],
41
+ [c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in Harness FME UI.'],
42
42
  ]);
@@ -118,14 +118,13 @@ function clientFactory(params) {
118
118
  var changeNumber = evaluation.changeNumber, impressionsDisabled = evaluation.impressionsDisabled;
119
119
  var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
120
120
  if (treatment === constants_1.CONTROL) {
121
- var fallbackTreatment = fallbackTreatmentsCalculator.resolve(featureFlagName, label);
121
+ var fallbackTreatment = fallbackTreatmentsCalculator(featureFlagName, label);
122
122
  treatment = fallbackTreatment.treatment;
123
123
  label = fallbackTreatment.label;
124
124
  config = fallbackTreatment.config;
125
125
  }
126
- log.info(constants_2.IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
127
126
  if ((0, splitExistence_1.validateSplitExistence)(log, readinessManager, featureFlagName, label, invokingMethodName)) {
128
- log.info(constants_2.IMPRESSION_QUEUEING);
127
+ log.info(constants_2.IMPRESSION_QUEUEING, [featureFlagName, matchingKey, treatment, label]);
129
128
  queue.push({
130
129
  imp: {
131
130
  feature: featureFlagName,
@@ -69,7 +69,7 @@ function clientAttributesDecoration(log, client) {
69
69
  attribute[attributeName] = attributeValue;
70
70
  if (!(0, attributes_1.validateAttributesDeep)(log, attribute, 'setAttribute'))
71
71
  return false;
72
- log.debug("stored " + attributeValue + " for attribute " + attributeName);
72
+ log.debug("stored ".concat(attributeValue, " for attribute ").concat(attributeName));
73
73
  return attributeStorage.setAttribute(attributeName, attributeValue);
74
74
  },
75
75
  /**
@@ -79,7 +79,7 @@ function clientAttributesDecoration(log, client) {
79
79
  * @returns Attribute with the given name
80
80
  */
81
81
  getAttribute: function (attributeName) {
82
- log.debug("retrieved attribute " + attributeName);
82
+ log.debug("retrieved attribute ".concat(attributeName));
83
83
  return attributeStorage.getAttribute(attributeName + '');
84
84
  },
85
85
  /**
@@ -108,7 +108,7 @@ function clientAttributesDecoration(log, client) {
108
108
  * @returns true if attribute was removed and false otherways
109
109
  */
110
110
  removeAttribute: function (attributeName) {
111
- log.debug("removed attribute " + attributeName);
111
+ log.debug("removed attribute ".concat(attributeName));
112
112
  return attributeStorage.removeAttribute(attributeName + '');
113
113
  },
114
114
  /**
@@ -37,97 +37,68 @@ function clientInputValidationDecorator(settings, client, readinessManager, fall
37
37
  };
38
38
  }
39
39
  function evaluateFallBackTreatment(featureFlagName, withConfig) {
40
- var _a = fallbackTreatmentsCalculator.resolve(featureFlagName, ''), treatment = _a.treatment, config = _a.config;
41
- if (withConfig) {
42
- return {
40
+ if (Array.isArray(featureFlagName)) {
41
+ var res_1 = {};
42
+ featureFlagName.forEach(function (split) { return res_1[split] = evaluateFallBackTreatment(split, withConfig); });
43
+ return res_1;
44
+ }
45
+ var _a = fallbackTreatmentsCalculator(featureFlagName), treatment = _a.treatment, config = _a.config;
46
+ return withConfig ?
47
+ {
43
48
  treatment: treatment,
44
49
  config: config
45
- };
46
- }
47
- return treatment;
50
+ } : treatment;
48
51
  }
49
52
  function wrapResult(value) {
50
53
  return isAsync ? Promise.resolve(value) : value;
51
54
  }
52
55
  function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
53
56
  var params = validateEvaluationParams(constants_1.GET_TREATMENT, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
54
- if (params.valid) {
55
- return client.getTreatment(params.key, params.nameOrNames, params.attributes, params.options);
56
- }
57
- else {
58
- var result = evaluateFallBackTreatment(params.nameOrNames, false);
59
- return wrapResult(result);
60
- }
57
+ return params.valid ?
58
+ client.getTreatment(params.key, params.nameOrNames, params.attributes, params.options) :
59
+ wrapResult(evaluateFallBackTreatment(params.nameOrNames, false));
61
60
  }
62
61
  function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
63
62
  var params = validateEvaluationParams(constants_1.GET_TREATMENT_WITH_CONFIG, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
64
- if (params.valid) {
65
- return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes, params.options);
66
- }
67
- else {
68
- var result = evaluateFallBackTreatment(params.nameOrNames, true);
69
- return wrapResult(result);
70
- }
63
+ return params.valid ?
64
+ client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes, params.options) :
65
+ wrapResult(evaluateFallBackTreatment(params.nameOrNames, true));
71
66
  }
72
67
  function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
73
68
  var params = validateEvaluationParams(constants_1.GET_TREATMENTS, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
74
- if (params.valid) {
75
- return client.getTreatments(params.key, params.nameOrNames, params.attributes, params.options);
76
- }
77
- else {
78
- var res_1 = {};
79
- if (params.nameOrNames)
80
- params.nameOrNames.forEach(function (split) { return res_1[split] = evaluateFallBackTreatment(split, false); });
81
- return wrapResult(res_1);
82
- }
69
+ return params.valid ?
70
+ client.getTreatments(params.key, params.nameOrNames, params.attributes, params.options) :
71
+ wrapResult(evaluateFallBackTreatment(params.nameOrNames || [], false));
83
72
  }
84
73
  function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
85
74
  var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
86
- if (params.valid) {
87
- return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes, params.options);
88
- }
89
- else {
90
- var res_2 = {};
91
- if (params.nameOrNames)
92
- params.nameOrNames.forEach(function (split) { return res_2[split] = evaluateFallBackTreatment(split, true); });
93
- return wrapResult(res_2);
94
- }
75
+ return params.valid ?
76
+ client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes, params.options) :
77
+ wrapResult(evaluateFallBackTreatment(params.nameOrNames || [], true));
95
78
  }
96
79
  function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
97
80
  var params = validateEvaluationParams(constants_1.GET_TREATMENTS_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
98
- if (params.valid) {
99
- return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes, params.options);
100
- }
101
- else {
102
- return wrapResult({});
103
- }
81
+ return params.valid ?
82
+ client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes, params.options) :
83
+ wrapResult({});
104
84
  }
105
85
  function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
106
86
  var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
107
- if (params.valid) {
108
- return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes, params.options);
109
- }
110
- else {
111
- return wrapResult({});
112
- }
87
+ return params.valid ?
88
+ client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes, params.options) :
89
+ wrapResult({});
113
90
  }
114
91
  function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
115
92
  var params = validateEvaluationParams(constants_1.GET_TREATMENTS_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
116
- if (params.valid) {
117
- return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options);
118
- }
119
- else {
120
- return wrapResult({});
121
- }
93
+ return params.valid ?
94
+ client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options) :
95
+ wrapResult({});
122
96
  }
123
97
  function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
124
98
  var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
125
- if (params.valid) {
126
- return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options);
127
- }
128
- else {
129
- return wrapResult({});
130
- }
99
+ return params.valid ?
100
+ client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options) :
101
+ wrapResult({});
131
102
  }
132
103
  function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
133
104
  var key = (0, inputValidation_1.validateKey)(log, maybeKey, constants_1.TRACK_FN_LABEL);
@@ -136,12 +107,9 @@ function clientInputValidationDecorator(settings, client, readinessManager, fall
136
107
  var eventValue = (0, inputValidation_1.validateEventValue)(log, maybeEventValue, constants_1.TRACK_FN_LABEL);
137
108
  var _a = (0, inputValidation_1.validateEventProperties)(log, maybeProperties, constants_1.TRACK_FN_LABEL), properties = _a.properties, size = _a.size;
138
109
  var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.TRACK_FN_LABEL);
139
- if (isNotDestroyed && key && tt && event && eventValue !== false && properties !== false) { // @ts-expect-error
140
- return client.track(key, tt, event, eventValue, properties, size);
141
- }
142
- else {
143
- return isAsync ? Promise.resolve(false) : false;
144
- }
110
+ return isNotDestroyed && key && tt && event && eventValue !== false && properties !== false ? // @ts-expect-error
111
+ client.track(key, tt, event, eventValue, properties, size) :
112
+ wrapResult(false);
145
113
  }
146
114
  return {
147
115
  getTreatment: getTreatment,
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildInstanceId = void 0;
4
4
  function buildInstanceId(key, trafficType) {
5
- return (key.matchingKey ? key.matchingKey : key) + "-" + (key.bucketingKey ? key.bucketingKey : key) + "-" + (trafficType ? trafficType : '');
5
+ return "".concat(key.matchingKey ? key.matchingKey : key, "-").concat(key.bucketingKey ? key.bucketingKey : key, "-").concat(trafficType ? trafficType : '');
6
6
  }
7
7
  exports.buildInstanceId = buildInstanceId;
@@ -7,10 +7,11 @@ var client_1 = require("./client");
7
7
  var clientInputValidation_1 = require("./clientInputValidation");
8
8
  var COOLDOWN_TIME_IN_MILLIS = 1000;
9
9
  /**
10
- * Creates an Sdk client, i.e., a base client with status and destroy interface
10
+ * Creates an Sdk client, i.e., a base client with status, init, flush and destroy interface
11
11
  */
12
12
  function sdkClientFactory(params, isSharedClient) {
13
- var sdkReadinessManager = params.sdkReadinessManager, syncManager = params.syncManager, storage = params.storage, signalListener = params.signalListener, settings = params.settings, telemetryTracker = params.telemetryTracker, uniqueKeysTracker = params.uniqueKeysTracker;
13
+ var sdkReadinessManager = params.sdkReadinessManager, syncManager = params.syncManager, storage = params.storage, signalListener = params.signalListener, settings = params.settings, telemetryTracker = params.telemetryTracker, impressionsTracker = params.impressionsTracker;
14
+ var hasInit = false;
14
15
  var lastActionTime = 0;
15
16
  function __cooldown(func, time) {
16
17
  var now = Date.now();
@@ -19,7 +20,7 @@ function sdkClientFactory(params, isSharedClient) {
19
20
  //check if the time elapsed is less than desired cooldown
20
21
  if (timeElapsed < time) {
21
22
  //if yes, return message with remaining time in seconds
22
- settings.log.warn("Flush cooldown, remaining time " + (time - timeElapsed) / 1000 + " seconds");
23
+ settings.log.warn("Flush cooldown, remaining time ".concat((time - timeElapsed) / 1000, " seconds"));
23
24
  return Promise.resolve();
24
25
  }
25
26
  else {
@@ -35,14 +36,25 @@ function sdkClientFactory(params, isSharedClient) {
35
36
  // Proto-linkage of the readiness Event Emitter
36
37
  Object.create(sdkReadinessManager.sdkStatus),
37
38
  // Client API (getTreatment* & track methods)
38
- (0, clientInputValidation_1.clientInputValidationDecorator)(settings, (0, client_1.clientFactory)(params), sdkReadinessManager.readinessManager, params.fallbackTreatmentsCalculator),
39
- // Sdk destroy
40
- {
39
+ (0, clientInputValidation_1.clientInputValidationDecorator)(settings, (0, client_1.clientFactory)(params), sdkReadinessManager.readinessManager, params.fallbackTreatmentsCalculator), {
40
+ init: function () {
41
+ if (hasInit)
42
+ return;
43
+ hasInit = true;
44
+ if (!isSharedClient) {
45
+ (0, apiKey_1.validateAndTrackApiKey)(settings.log, settings.core.authorizationKey);
46
+ sdkReadinessManager.readinessManager.init();
47
+ impressionsTracker.start();
48
+ syncManager && syncManager.start();
49
+ signalListener && signalListener.start();
50
+ }
51
+ },
41
52
  flush: function () {
42
53
  // @TODO define cooldown time
43
54
  return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
44
55
  },
45
56
  destroy: function () {
57
+ hasInit = false;
46
58
  // Mark the SDK as destroyed immediately
47
59
  sdkReadinessManager.readinessManager.destroy();
48
60
  // For main client, cleanup the SDK Key, listeners and scheduled jobs, and record stat before flushing data
@@ -50,7 +62,7 @@ function sdkClientFactory(params, isSharedClient) {
50
62
  (0, apiKey_1.releaseApiKey)(settings.core.authorizationKey);
51
63
  telemetryTracker.sessionLength();
52
64
  signalListener && signalListener.stop();
53
- uniqueKeysTracker.stop();
65
+ impressionsTracker.stop();
54
66
  }
55
67
  // Stop background jobs
56
68
  syncManager && syncManager.stop();