@splitsoftware/splitio-commons 2.11.1-rc.2 → 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 +6 -2
  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
@@ -16,7 +16,7 @@ function submitterFactory(log, postClient, sourceCache, postRate, fromCacheToPay
16
16
  if (sourceCache.isEmpty() && !data)
17
17
  return Promise.resolve();
18
18
  data = sourceCache.pop(data);
19
- var dataCountMessage = typeof data.length === 'number' ? data.length + " " + dataName : dataName;
19
+ var dataCountMessage = typeof data.length === 'number' ? "".concat(data.length, " ").concat(dataName) : dataName;
20
20
  log[debugLogs ? 'debug' : 'info'](constants_1.SUBMITTERS_PUSH, [dataCountMessage]);
21
21
  var jsonPayload = JSON.stringify(fromCacheToPayload ? fromCacheToPayload(data) : data);
22
22
  if (!maxRetries)
@@ -12,26 +12,24 @@ var mode_1 = require("../utils/settingsValidation/mode");
12
12
  * @param eventsCache - cache to save events
13
13
  * @param integrationsManager - optional event handler used for integrations
14
14
  */
15
- function eventTrackerFactory(settings, eventsCache, whenInit, integrationsManager, telemetryCache) {
15
+ function eventTrackerFactory(settings, eventsCache, integrationsManager, telemetryCache) {
16
16
  var log = settings.log, mode = settings.mode;
17
17
  var isAsync = (0, mode_1.isConsumerMode)(mode);
18
18
  function queueEventsCallback(eventData, tracked) {
19
19
  var eventTypeId = eventData.eventTypeId, trafficTypeName = eventData.trafficTypeName, key = eventData.key, value = eventData.value, timestamp = eventData.timestamp, properties = eventData.properties;
20
20
  // Logging every prop would be too much.
21
- var msg = "event of type \"" + eventTypeId + "\" for traffic type \"" + trafficTypeName + "\". Key: " + key + ". Value: " + value + ". Timestamp: " + timestamp + ". " + (properties ? 'With properties.' : 'With no properties.');
21
+ var msg = "event of type \"".concat(eventTypeId, "\" for traffic type \"").concat(trafficTypeName, "\". Key: ").concat(key, ". Value: ").concat(value, ". Timestamp: ").concat(timestamp, ". ").concat(properties ? 'With properties.' : 'With no properties.');
22
22
  if (tracked) {
23
23
  log.info(constants_1.EVENTS_TRACKER_SUCCESS, [msg]);
24
24
  if (integrationsManager) {
25
- whenInit(function () {
26
- // Wrap in a timeout because we don't want it to be blocking.
27
- setTimeout(function () {
28
- // copy of event, to avoid unexpected behavior if modified by integrations
29
- var eventDataCopy = (0, objectAssign_1.objectAssign)({}, eventData);
30
- if (properties)
31
- eventDataCopy.properties = (0, objectAssign_1.objectAssign)({}, properties);
32
- // integrationsManager does not throw errors (they are internally handled by each integration module)
33
- integrationsManager.handleEvent(eventDataCopy);
34
- });
25
+ // Wrap in a timeout because we don't want it to be blocking.
26
+ setTimeout(function () {
27
+ // copy of event, to avoid unexpected behavior if modified by integrations
28
+ var eventDataCopy = (0, objectAssign_1.objectAssign)({}, eventData);
29
+ if (properties)
30
+ eventDataCopy.properties = (0, objectAssign_1.objectAssign)({}, properties);
31
+ // integrationsManager does not throw errors (they are internally handled by each integration module)
32
+ integrationsManager.handleEvent(eventDataCopy);
35
33
  });
36
34
  }
37
35
  }
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildKey = void 0;
4
4
  function buildKey(impression) {
5
- return impression.keyName + ":" + impression.feature + ":" + impression.treatment + ":" + impression.label + ":" + impression.changeNumber;
5
+ return "".concat(impression.keyName, ":").concat(impression.feature, ":").concat(impression.treatment, ":").concat(impression.label, ":").concat(impression.changeNumber);
6
6
  }
7
7
  exports.buildKey = buildKey;
@@ -5,12 +5,31 @@ var objectAssign_1 = require("../utils/lang/objectAssign");
5
5
  var thenable_1 = require("../utils/promise/thenable");
6
6
  var constants_1 = require("../logger/constants");
7
7
  var constants_2 = require("../utils/constants");
8
+ var strategyDebug_1 = require("./strategy/strategyDebug");
9
+ var strategyNone_1 = require("./strategy/strategyNone");
10
+ var strategyOptimized_1 = require("./strategy/strategyOptimized");
11
+ var uniqueKeysTracker_1 = require("./uniqueKeysTracker");
8
12
  /**
9
13
  * Impressions tracker stores impressions in cache and pass them to the listener and integrations manager if provided.
10
14
  */
11
- function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, strategy, whenInit, integrationsManager, telemetryCache) {
12
- var log = settings.log, impressionListener = settings.impressionListener, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version;
15
+ function impressionsTrackerFactory(params, storage, integrationsManager) {
16
+ var settings = params.settings, impressionsObserverFactory = params.impressionsObserverFactory, filterAdapterFactory = params.filterAdapterFactory;
17
+ var log = settings.log, impressionListener = settings.impressionListener, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version, impressionsMode = settings.sync.impressionsMode;
18
+ var observer = impressionsObserverFactory();
19
+ var uniqueKeysTracker = (0, uniqueKeysTracker_1.uniqueKeysTrackerFactory)(log, storage.uniqueKeys, filterAdapterFactory && filterAdapterFactory());
20
+ var noneStrategy = (0, strategyNone_1.strategyNoneFactory)(storage.impressionCounts, uniqueKeysTracker);
21
+ var strategy = impressionsMode === constants_2.OPTIMIZED ?
22
+ (0, strategyOptimized_1.strategyOptimizedFactory)(observer, storage.impressionCounts) :
23
+ impressionsMode === constants_2.DEBUG ?
24
+ (0, strategyDebug_1.strategyDebugFactory)(observer) :
25
+ noneStrategy;
13
26
  return {
27
+ start: function () {
28
+ uniqueKeysTracker.start();
29
+ },
30
+ stop: function () {
31
+ uniqueKeysTracker.stop();
32
+ },
14
33
  track: function (impressions, attributes) {
15
34
  if (settings.userConsent === constants_2.CONSENT_DECLINED)
16
35
  return;
@@ -23,7 +42,7 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
23
42
  var impressionsLength = impressions.length;
24
43
  var impressionsToStoreLength = impressionsToStore.length;
25
44
  if (impressionsToStoreLength) {
26
- var res = impressionsCache.track(impressionsToStore.map(function (item) { return item.imp; }));
45
+ var res = storage.impressions.track(impressionsToStore.map(function (item) { return item.imp; }));
27
46
  // If we're on an async storage, handle error and log it.
28
47
  if ((0, thenable_1.thenable)(res)) {
29
48
  res.then(function () {
@@ -35,9 +54,9 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
35
54
  else {
36
55
  // Record when impressionsCache is sync only (standalone mode)
37
56
  // @TODO we are not dropping impressions on full queue yet, so DROPPED stats are not recorded
38
- if (telemetryCache) {
39
- telemetryCache.recordImpressionStats(constants_2.QUEUED, impressionsToStoreLength);
40
- telemetryCache.recordImpressionStats(constants_2.DEDUPED, impressionsLength - impressionsToStoreLength);
57
+ if (storage.telemetry) {
58
+ storage.telemetry.recordImpressionStats(constants_2.QUEUED, impressionsToStoreLength);
59
+ storage.telemetry.recordImpressionStats(constants_2.DEDUPED, impressionsLength - impressionsToStoreLength);
41
60
  }
42
61
  }
43
62
  }
@@ -52,20 +71,18 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
52
71
  hostname: hostname,
53
72
  sdkLanguageVersion: version
54
73
  };
55
- whenInit(function () {
56
- // Wrap in a timeout because we don't want it to be blocking.
57
- setTimeout(function () {
58
- // integrationsManager.handleImpression does not throw errors
59
- if (integrationsManager)
60
- integrationsManager.handleImpression(impressionData);
61
- try { // @ts-ignore. An exception on the listeners should not break the SDK.
62
- if (impressionListener)
63
- impressionListener.logImpression(impressionData);
64
- }
65
- catch (err) {
66
- log.error(constants_1.ERROR_IMPRESSIONS_LISTENER, [err]);
67
- }
68
- });
74
+ // Wrap in a timeout because we don't want it to be blocking.
75
+ setTimeout(function () {
76
+ // integrationsManager.handleImpression does not throw errors
77
+ if (integrationsManager)
78
+ integrationsManager.handleImpression(impressionData);
79
+ try { // @ts-ignore. An exception on the listeners should not break the SDK.
80
+ if (impressionListener)
81
+ impressionListener.logImpression(impressionData);
82
+ }
83
+ catch (err) {
84
+ log.error(constants_1.ERROR_IMPRESSIONS_LISTENER, [err]);
85
+ }
69
86
  });
70
87
  };
71
88
  for (var i = 0; i < impressionsLength; i++) {
@@ -22,7 +22,7 @@ function uniqueKeysTrackerFactory(log, uniqueKeysCache, filterAdapter) {
22
22
  return {
23
23
  track: function (key, featureName) {
24
24
  if (!filterAdapter.add(key, featureName)) {
25
- log.debug(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The feature " + featureName + " and key " + key + " exist in the filter");
25
+ log.debug("".concat(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER, "The feature ").concat(featureName, " and key ").concat(key, " exist in the filter"));
26
26
  return;
27
27
  }
28
28
  uniqueKeysCache.track(key, featureName);
@@ -38,7 +38,7 @@ function validateAndTrackApiKey(log, maybeSdkKey) {
38
38
  }
39
39
  }
40
40
  else {
41
- log.warn(constants_1.WARN_SDK_KEY, [exports.usedKeysMap[sdkKey] + " factory/ies with this SDK Key"]);
41
+ log.warn(constants_1.WARN_SDK_KEY, ["".concat(exports.usedKeysMap[sdkKey], " factory/ies with this SDK Key")]);
42
42
  exports.usedKeysMap[sdkKey]++;
43
43
  }
44
44
  }
@@ -4,7 +4,7 @@ exports.validateAttribute = void 0;
4
4
  var lang_1 = require("../../utils/lang");
5
5
  function validateAttribute(log, attributeKey, attributeValue, method) {
6
6
  if (!(0, lang_1.isString)(attributeKey) || attributeKey.length === 0) {
7
- log.warn(method + ": you passed an invalid attribute name, attribute name must be a non-empty string.");
7
+ log.warn("".concat(method, ": you passed an invalid attribute name, attribute name must be a non-empty string."));
8
8
  return false;
9
9
  }
10
10
  var isStringVal = (0, lang_1.isString)(attributeValue);
@@ -12,7 +12,7 @@ function validateAttribute(log, attributeKey, attributeValue, method) {
12
12
  var isBoolVal = (0, lang_1.isBoolean)(attributeValue);
13
13
  var isArrayVal = Array.isArray(attributeValue);
14
14
  if (!(isStringVal || isFiniteVal || isBoolVal || isArrayVal)) { // If it's not of valid type.
15
- log.warn(method + ": you passed an invalid attribute value for " + attributeKey + ". Acceptable types are: string, number, boolean and array of strings.");
15
+ log.warn("".concat(method, ": you passed an invalid attribute value for ").concat(attributeKey, ". Acceptable types are: string, number, boolean and array of strings."));
16
16
  return false;
17
17
  }
18
18
  return true;
@@ -70,7 +70,7 @@ function validateEvaluationOptions(log, maybeOptions, method) {
70
70
  if (!impressionsDisabled)
71
71
  return options;
72
72
  // @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
73
- return options ? (0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { impressionsDisabled: impressionsDisabled }) : { impressionsDisabled: impressionsDisabled };
73
+ return options ? tslib_1.__assign(tslib_1.__assign({}, options), { impressionsDisabled: impressionsDisabled }) : { impressionsDisabled: impressionsDisabled };
74
74
  }
75
75
  else if (maybeOptions) {
76
76
  log.error(constants_1.ERROR_NOT_PLAIN_OBJECT, [method, 'evaluation options']);
@@ -12,7 +12,7 @@ exports.validateIfNotDestroyed = validateIfNotDestroyed;
12
12
  function validateIfReadyFromCache(log, readinessManager, method, featureFlagNameOrNames) {
13
13
  if (readinessManager.isReadyFromCache())
14
14
  return true;
15
- log.warn(constants_1.CLIENT_NOT_READY_FROM_CACHE, [method, featureFlagNameOrNames ? " for feature flag " + featureFlagNameOrNames.toString() : '']);
15
+ log.warn(constants_1.CLIENT_NOT_READY_FROM_CACHE, [method, featureFlagNameOrNames ? " for feature flag ".concat(featureFlagNameOrNames.toString()) : '']);
16
16
  return false;
17
17
  }
18
18
  exports.validateIfReadyFromCache = validateIfReadyFromCache;
@@ -200,7 +200,7 @@ function merge(target, source) {
200
200
  });
201
201
  if (rest && rest.length) {
202
202
  var nextSource = rest.splice(0, 1)[0];
203
- res = merge.apply(void 0, (0, tslib_1.__spreadArray)([res, nextSource], rest, false));
203
+ res = merge.apply(void 0, tslib_1.__spreadArray([res, nextSource], rest, false));
204
204
  }
205
205
  return res;
206
206
  }
@@ -15,9 +15,9 @@ function returnSetsUnion(set, set2) {
15
15
  return new Set(setToArray(set).concat(setToArray(set2)));
16
16
  }
17
17
  exports.returnSetsUnion = returnSetsUnion;
18
- function returnDifference(list, list2) {
19
- if (list === void 0) { list = []; }
20
- if (list2 === void 0) { list2 = []; }
21
- return list.filter(function (item) { return list2.indexOf(item) === -1; });
18
+ function returnDifference(list1, list2) {
19
+ list1 = list1 || [];
20
+ list2 = list2 || [];
21
+ return list1.filter(function (item) { return list2.indexOf(item) === -1; });
22
22
  }
23
23
  exports.returnDifference = returnDifference;
@@ -6,7 +6,7 @@ function timeout(ms, promise) {
6
6
  return promise;
7
7
  return new Promise(function (resolve, reject) {
8
8
  var tid = setTimeout(function () {
9
- reject(new Error("Operation timed out because it exceeded the configured time limit of " + ms + " ms."));
9
+ reject(new Error("Operation timed out because it exceeded the configured time limit of ".concat(ms, " ms.")));
10
10
  }, ms);
11
11
  promise.then(function (res) {
12
12
  clearTimeout(tid);
@@ -45,14 +45,14 @@ function validateFilterType(maybeFilterType) {
45
45
  */
46
46
  function validateSplitFilter(log, type, values, maxLength) {
47
47
  // validate and remove invalid and duplicated values
48
- var result = (0, splits_1.validateSplits)(log, values, constants_1.LOG_PREFIX_SETTINGS, type + " filter", type + " filter value");
48
+ var result = (0, splits_1.validateSplits)(log, values, constants_1.LOG_PREFIX_SETTINGS, "".concat(type, " filter"), "".concat(type, " filter value"));
49
49
  if (result) {
50
50
  if (type === 'bySet') {
51
51
  result = sanitizeFlagSets(log, result, constants_1.LOG_PREFIX_SETTINGS);
52
52
  }
53
53
  // check max length
54
54
  if (result.length > maxLength)
55
- throw new Error(maxLength + " unique values can be specified at most for '" + type + "' filter. You passed " + result.length + ". Please consider reducing the amount or using other filter.");
55
+ throw new Error("".concat(maxLength, " unique values can be specified at most for '").concat(type, "' filter. You passed ").concat(result.length, ". Please consider reducing the amount or using other filter."));
56
56
  // sort values
57
57
  result.sort();
58
58
  }
@@ -15,17 +15,17 @@ var streamingEndpointMatcher = /^\/(sse|event-stream)/;
15
15
  */
16
16
  function url(settings, target) {
17
17
  if (telemetryEndpointMatcher.test(target)) {
18
- return "" + settings.urls.telemetry + target;
18
+ return "".concat(settings.urls.telemetry).concat(target);
19
19
  }
20
20
  if (eventsEndpointMatcher.test(target)) {
21
- return "" + settings.urls.events + target;
21
+ return "".concat(settings.urls.events).concat(target);
22
22
  }
23
23
  if (authEndpointMatcher.test(target)) {
24
- return "" + settings.urls.auth + target;
24
+ return "".concat(settings.urls.auth).concat(target);
25
25
  }
26
26
  if (streamingEndpointMatcher.test(target)) {
27
- return "" + settings.urls.streaming + target;
27
+ return "".concat(settings.urls.streaming).concat(target);
28
28
  }
29
- return "" + settings.urls.sdk + target;
29
+ return "".concat(settings.urls.sdk).concat(target);
30
30
  }
31
31
  exports.url = url;
@@ -12,10 +12,10 @@ export function getTreatment(log, key, seed, treatments) {
12
12
  /**
13
13
  * Evaluates the traffic allocation to see if we should apply rollout conditions or not.
14
14
  */
15
- export function shouldApplyRollout(trafficAllocation, key, trafficAllocationSeed) {
15
+ export function shouldApplyRollout(trafficAllocation, bucketingKey, trafficAllocationSeed) {
16
16
  // For rollout, if traffic allocation for splits is 100%, we don't need to filter it because everything should evaluate the rollout.
17
17
  if (trafficAllocation < 100) {
18
- var _bucket = bucket(key, trafficAllocationSeed);
18
+ var _bucket = bucket(bucketingKey, trafficAllocationSeed);
19
19
  if (_bucket > trafficAllocation) {
20
20
  return false;
21
21
  }
@@ -19,7 +19,7 @@ function sanitizeGlobal(logger, treatment) {
19
19
  if (treatment === undefined)
20
20
  return undefined;
21
21
  if (!isValidTreatment(treatment)) {
22
- logger.error("Fallback treatments - Discarded fallback: " + FallbackDiscardReason.Treatment);
22
+ logger.error("Fallback treatments - Discarded fallback: ".concat(FallbackDiscardReason.Treatment));
23
23
  return undefined;
24
24
  }
25
25
  return treatment;
@@ -31,11 +31,11 @@ function sanitizeByFlag(logger, byFlagFallbacks) {
31
31
  Object.keys(byFlagFallbacks).forEach(function (flag) {
32
32
  var t = byFlagFallbacks[flag];
33
33
  if (!isValidFlagName(flag)) {
34
- logger.error("Fallback treatments - Discarded flag '" + flag + "': " + FallbackDiscardReason.FlagName);
34
+ logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(FallbackDiscardReason.FlagName));
35
35
  return;
36
36
  }
37
37
  if (!isValidTreatment(t)) {
38
- logger.error("Fallback treatments - Discarded treatment for flag '" + flag + "': " + FallbackDiscardReason.Treatment);
38
+ logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(FallbackDiscardReason.Treatment));
39
39
  return;
40
40
  }
41
41
  sanitizedByFlag[flag] = t;
@@ -1,40 +1,28 @@
1
1
  import { CONTROL } from '../../utils/constants';
2
2
  import { isString } from '../../utils/lang';
3
3
  export var FALLBACK_PREFIX = 'fallback - ';
4
- var FallbackTreatmentsCalculator = /** @class */ (function () {
5
- function FallbackTreatmentsCalculator(fallbacks) {
6
- if (fallbacks === void 0) { fallbacks = {}; }
7
- this.fallbacks = fallbacks;
8
- }
9
- FallbackTreatmentsCalculator.prototype.resolve = function (flagName, label) {
4
+ export function FallbackTreatmentsCalculator(fallbacks) {
5
+ if (fallbacks === void 0) { fallbacks = {}; }
6
+ return function (flagName, label) {
10
7
  var _a;
11
- var treatment = (_a = this.fallbacks.byFlag) === null || _a === void 0 ? void 0 : _a[flagName];
12
- if (treatment) {
13
- return this.copyWithLabel(treatment, label);
14
- }
15
- if (this.fallbacks.global) {
16
- return this.copyWithLabel(this.fallbacks.global, label);
17
- }
18
- return {
19
- treatment: CONTROL,
20
- config: null,
21
- label: label,
22
- };
23
- };
24
- FallbackTreatmentsCalculator.prototype.copyWithLabel = function (fallback, label) {
25
- if (isString(fallback)) {
26
- return {
27
- treatment: fallback,
8
+ if (label === void 0) { label = ''; }
9
+ var fallback = ((_a = fallbacks.byFlag) === null || _a === void 0 ? void 0 : _a[flagName]) || fallbacks.global;
10
+ return fallback ?
11
+ isString(fallback) ?
12
+ {
13
+ treatment: fallback,
14
+ config: null,
15
+ label: "".concat(FALLBACK_PREFIX).concat(label),
16
+ } :
17
+ {
18
+ treatment: fallback.treatment,
19
+ config: fallback.config,
20
+ label: "".concat(FALLBACK_PREFIX).concat(label),
21
+ } :
22
+ {
23
+ treatment: CONTROL,
28
24
  config: null,
29
- label: "" + FALLBACK_PREFIX + label,
25
+ label: label,
30
26
  };
31
- }
32
- return {
33
- treatment: fallback.treatment,
34
- config: fallback.config,
35
- label: "" + FALLBACK_PREFIX + label,
36
- };
37
27
  };
38
- return FallbackTreatmentsCalculator;
39
- }());
40
- export { FallbackTreatmentsCalculator };
28
+ }
@@ -1,5 +1,5 @@
1
1
  export function whitelistMatcherContext(ruleAttr) {
2
- var whitelistSet = new Set(ruleAttr);
2
+ var whitelistSet = new Set(ruleAttr || []);
3
3
  return function whitelistMatcher(runtimeAttr) {
4
4
  var isInWhitelist = whitelistSet.has(runtimeAttr);
5
5
  return isInWhitelist;
@@ -13,7 +13,7 @@ export function pluggableIntegrationsManagerFactory(integrations, params) {
13
13
  // No need to check if `settings.integrations` is an array of functions. It was already validated
14
14
  integrations.forEach(function (integrationFactory) {
15
15
  var integration = integrationFactory(params);
16
- if (integration && integration.queue)
16
+ if (integration)
17
17
  listeners.push(integration);
18
18
  });
19
19
  // If `listeners` is empty, not return a integration manager
@@ -44,13 +44,13 @@ var NodeSignalListener = /** @class */ (function () {
44
44
  // eslint-disable-next-line no-undef
45
45
  process.kill(process.pid, SIGTERM);
46
46
  };
47
- this.settings.log.debug(LOG_PREFIX_CLEANUP + "Split SDK graceful shutdown after SIGTERM.");
47
+ this.settings.log.debug("".concat(LOG_PREFIX_CLEANUP, "Split SDK graceful shutdown after SIGTERM."));
48
48
  var handlerResult = null;
49
49
  try {
50
50
  handlerResult = this.handler();
51
51
  }
52
52
  catch (err) {
53
- this.settings.log.error(LOG_PREFIX_CLEANUP + "Error with Split SDK graceful shutdown: " + err);
53
+ this.settings.log.error("".concat(LOG_PREFIX_CLEANUP, "Error with Split SDK graceful shutdown: ").concat(err));
54
54
  }
55
55
  if (thenable(handlerResult)) {
56
56
  // Always exit, even with errors. The promise is returned for UT purposes.
@@ -31,7 +31,6 @@ export var ENGINE_MATCHER_RESULT = 40;
31
31
  export var ENGINE_DEFAULT = 41;
32
32
  export var CLIENT_READY_FROM_CACHE = 100;
33
33
  export var CLIENT_READY = 101;
34
- export var IMPRESSION = 102;
35
34
  export var IMPRESSION_QUEUEING = 103;
36
35
  export var NEW_SHARED_CLIENT = 104;
37
36
  export var NEW_FACTORY = 105;
@@ -86,7 +86,7 @@ var Logger = /** @class */ (function () {
86
86
  Logger.prototype._log = function (method, msg, args) {
87
87
  if (typeof msg === 'number') {
88
88
  var format = this.codes.get(msg);
89
- msg = format ? _sprintf(format, args) : "Message code " + msg + (args ? ', with args: ' + args.toString() : '');
89
+ msg = format ? _sprintf(format, args) : "Message code ".concat(msg).concat(args ? ', with args: ' + args.toString() : '');
90
90
  }
91
91
  else {
92
92
  if (args)
@@ -6,8 +6,7 @@ export var codesInfo = codesWarn.concat([
6
6
  [c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
7
7
  [c.CLIENT_READY, READY_MSG],
8
8
  // SDK
9
- [c.IMPRESSION, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
10
- [c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing corresponding impression.'],
9
+ [c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression. Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
11
10
  [c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
12
11
  [c.NEW_FACTORY, 'New Split SDK instance created. %s'],
13
12
  [c.EVENTS_TRACKER_SUCCESS, c.LOG_PREFIX_EVENTS_TRACKER + 'Successfully queued %s'],
@@ -20,9 +20,9 @@ export var codesWarn = codesError.concat([
20
20
  [c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
21
21
  [c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
22
22
  [c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
23
- [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.'],
23
+ [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.'],
24
24
  [c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
25
- [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.'],
25
+ [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.'],
26
26
  [c.WARN_FLAGSET_NOT_CONFIGURED, '%s: you passed %s which is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
27
27
  // initialization / settings validation
28
28
  [c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS + ': %s integration item(s) at settings is invalid. %s'],
@@ -34,5 +34,5 @@ export var codesWarn = codesError.concat([
34
34
  [c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing %s notification: %s'],
35
35
  [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.'],
36
36
  [c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
37
- [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.'],
37
+ [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.'],
38
38
  ]);
@@ -5,7 +5,7 @@ import { validateSplitExistence } from '../utils/inputValidation/splitExistence'
5
5
  import { validateTrafficTypeExistence } from '../utils/inputValidation/trafficTypeExistence';
6
6
  import { SDK_NOT_READY } from '../utils/labels';
7
7
  import { CONTROL, TREATMENT, TREATMENTS, TREATMENT_WITH_CONFIG, TREATMENTS_WITH_CONFIG, TRACK, TREATMENTS_WITH_CONFIG_BY_FLAGSETS, TREATMENTS_BY_FLAGSETS, TREATMENTS_BY_FLAGSET, TREATMENTS_WITH_CONFIG_BY_FLAGSET, GET_TREATMENTS_WITH_CONFIG, GET_TREATMENTS_BY_FLAG_SETS, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, GET_TREATMENTS_BY_FLAG_SET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, GET_TREATMENT_WITH_CONFIG, GET_TREATMENT, GET_TREATMENTS, TRACK_FN_LABEL } from '../utils/constants';
8
- import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
8
+ import { IMPRESSION_QUEUEING } from '../logger/constants';
9
9
  import { isConsumerMode } from '../utils/settingsValidation/mode';
10
10
  var treatmentNotReady = { treatment: CONTROL, label: SDK_NOT_READY };
11
11
  function treatmentsNotReady(featureFlagNames) {
@@ -115,14 +115,13 @@ export function clientFactory(params) {
115
115
  var changeNumber = evaluation.changeNumber, impressionsDisabled = evaluation.impressionsDisabled;
116
116
  var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
117
117
  if (treatment === CONTROL) {
118
- var fallbackTreatment = fallbackTreatmentsCalculator.resolve(featureFlagName, label);
118
+ var fallbackTreatment = fallbackTreatmentsCalculator(featureFlagName, label);
119
119
  treatment = fallbackTreatment.treatment;
120
120
  label = fallbackTreatment.label;
121
121
  config = fallbackTreatment.config;
122
122
  }
123
- log.info(IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
124
123
  if (validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName)) {
125
- log.info(IMPRESSION_QUEUEING);
124
+ log.info(IMPRESSION_QUEUEING, [featureFlagName, matchingKey, treatment, label]);
126
125
  queue.push({
127
126
  imp: {
128
127
  feature: featureFlagName,
@@ -66,7 +66,7 @@ export function clientAttributesDecoration(log, client) {
66
66
  attribute[attributeName] = attributeValue;
67
67
  if (!validateAttributesDeep(log, attribute, 'setAttribute'))
68
68
  return false;
69
- log.debug("stored " + attributeValue + " for attribute " + attributeName);
69
+ log.debug("stored ".concat(attributeValue, " for attribute ").concat(attributeName));
70
70
  return attributeStorage.setAttribute(attributeName, attributeValue);
71
71
  },
72
72
  /**
@@ -76,7 +76,7 @@ export function clientAttributesDecoration(log, client) {
76
76
  * @returns Attribute with the given name
77
77
  */
78
78
  getAttribute: function (attributeName) {
79
- log.debug("retrieved attribute " + attributeName);
79
+ log.debug("retrieved attribute ".concat(attributeName));
80
80
  return attributeStorage.getAttribute(attributeName + '');
81
81
  },
82
82
  /**
@@ -105,7 +105,7 @@ export function clientAttributesDecoration(log, client) {
105
105
  * @returns true if attribute was removed and false otherways
106
106
  */
107
107
  removeAttribute: function (attributeName) {
108
- log.debug("removed attribute " + attributeName);
108
+ log.debug("removed attribute ".concat(attributeName));
109
109
  return attributeStorage.removeAttribute(attributeName + '');
110
110
  },
111
111
  /**