@splitsoftware/splitio-commons 1.10.1-rc.4 → 1.12.0-rc.0

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 (109) hide show
  1. package/CHANGES.txt +16 -10
  2. package/cjs/evaluator/index.js +22 -3
  3. package/cjs/logger/constants.js +6 -4
  4. package/cjs/logger/messages/warn.js +5 -3
  5. package/cjs/sdkClient/client.js +19 -16
  6. package/cjs/sdkClient/clientInputValidation.js +16 -16
  7. package/cjs/sdkFactory/index.js +1 -1
  8. package/cjs/sdkManager/index.js +14 -13
  9. package/cjs/storages/KeyBuilder.js +1 -1
  10. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +3 -10
  11. package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -10
  12. package/cjs/storages/inRedis/RedisAdapter.js +32 -13
  13. package/cjs/storages/inRedis/SegmentsCacheInRedis.js +2 -2
  14. package/cjs/storages/inRedis/SplitsCacheInRedis.js +38 -22
  15. package/cjs/storages/inRedis/index.js +1 -1
  16. package/cjs/storages/pluggable/SplitsCachePluggable.js +27 -11
  17. package/cjs/storages/pluggable/index.js +1 -1
  18. package/cjs/utils/constants/index.js +16 -2
  19. package/cjs/utils/inputValidation/index.js +5 -5
  20. package/cjs/utils/inputValidation/{splitExistance.js → splitExistence.js} +3 -3
  21. package/cjs/utils/inputValidation/{trafficTypeExistance.js → trafficTypeExistence.js} +6 -6
  22. package/cjs/utils/lang/sets.js +11 -1
  23. package/cjs/utils/settingsValidation/index.js +1 -1
  24. package/cjs/utils/settingsValidation/splitFilters.js +25 -17
  25. package/esm/evaluator/index.js +23 -4
  26. package/esm/logger/constants.js +4 -2
  27. package/esm/logger/messages/warn.js +5 -3
  28. package/esm/sdkClient/client.js +20 -17
  29. package/esm/sdkClient/clientInputValidation.js +18 -18
  30. package/esm/sdkFactory/index.js +1 -1
  31. package/esm/sdkManager/index.js +11 -10
  32. package/esm/storages/KeyBuilder.js +1 -1
  33. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +4 -11
  34. package/esm/storages/inMemory/SplitsCacheInMemory.js +3 -11
  35. package/esm/storages/inRedis/RedisAdapter.js +32 -13
  36. package/esm/storages/inRedis/SegmentsCacheInRedis.js +2 -2
  37. package/esm/storages/inRedis/SplitsCacheInRedis.js +40 -24
  38. package/esm/storages/inRedis/index.js +1 -1
  39. package/esm/storages/pluggable/SplitsCachePluggable.js +29 -13
  40. package/esm/storages/pluggable/index.js +1 -1
  41. package/esm/utils/constants/index.js +14 -0
  42. package/esm/utils/inputValidation/index.js +2 -2
  43. package/esm/utils/inputValidation/{splitExistance.js → splitExistence.js} +1 -1
  44. package/esm/utils/inputValidation/{trafficTypeExistance.js → trafficTypeExistence.js} +4 -4
  45. package/esm/utils/lang/sets.js +9 -0
  46. package/esm/utils/settingsValidation/index.js +1 -1
  47. package/esm/utils/settingsValidation/splitFilters.js +17 -9
  48. package/package.json +1 -1
  49. package/src/evaluator/index.ts +28 -5
  50. package/src/logger/constants.ts +4 -2
  51. package/src/logger/messages/warn.ts +9 -7
  52. package/src/sdkClient/client.ts +18 -18
  53. package/src/sdkClient/clientInputValidation.ts +18 -18
  54. package/src/sdkFactory/index.ts +1 -1
  55. package/src/sdkFactory/types.ts +3 -7
  56. package/src/sdkManager/index.ts +14 -14
  57. package/src/storages/AbstractSplitsCacheAsync.ts +1 -1
  58. package/src/storages/AbstractSplitsCacheSync.ts +1 -1
  59. package/src/storages/KeyBuilder.ts +1 -1
  60. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +8 -15
  61. package/src/storages/inMemory/SplitsCacheInMemory.ts +6 -14
  62. package/src/storages/inRedis/EventsCacheInRedis.ts +3 -3
  63. package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +3 -3
  64. package/src/storages/inRedis/ImpressionsCacheInRedis.ts +3 -3
  65. package/src/storages/inRedis/RedisAdapter.ts +38 -16
  66. package/src/storages/inRedis/SegmentsCacheInRedis.ts +5 -5
  67. package/src/storages/inRedis/SplitsCacheInRedis.ts +49 -28
  68. package/src/storages/inRedis/TelemetryCacheInRedis.ts +2 -2
  69. package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +3 -3
  70. package/src/storages/inRedis/index.ts +1 -1
  71. package/src/storages/pluggable/SplitsCachePluggable.ts +35 -13
  72. package/src/storages/pluggable/index.ts +1 -1
  73. package/src/storages/types.ts +5 -5
  74. package/src/trackers/impressionObserver/utils.ts +1 -1
  75. package/src/types.ts +0 -2
  76. package/src/utils/constants/index.ts +16 -0
  77. package/src/utils/inputValidation/index.ts +2 -2
  78. package/src/utils/inputValidation/{splitExistance.ts → splitExistence.ts} +1 -1
  79. package/src/utils/inputValidation/{trafficTypeExistance.ts → trafficTypeExistence.ts} +4 -4
  80. package/src/utils/lang/sets.ts +9 -1
  81. package/src/utils/redis/RedisMock.ts +1 -3
  82. package/src/utils/settingsValidation/index.ts +1 -1
  83. package/src/utils/settingsValidation/splitFilters.ts +19 -11
  84. package/types/evaluator/index.d.ts +1 -1
  85. package/types/logger/constants.d.ts +4 -2
  86. package/types/sdkFactory/types.d.ts +3 -3
  87. package/types/sdkManager/index.d.ts +2 -3
  88. package/types/storages/AbstractSplitsCacheAsync.d.ts +1 -1
  89. package/types/storages/AbstractSplitsCacheSync.d.ts +1 -1
  90. package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -1
  91. package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -1
  92. package/types/storages/inRedis/EventsCacheInRedis.d.ts +2 -2
  93. package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +3 -2
  94. package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +2 -2
  95. package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
  96. package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +3 -3
  97. package/types/storages/inRedis/SplitsCacheInRedis.d.ts +10 -14
  98. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +2 -2
  99. package/types/storages/inRedis/UniqueKeysCacheInRedis.d.ts +3 -2
  100. package/types/storages/pluggable/SplitsCachePluggable.d.ts +10 -9
  101. package/types/storages/types.d.ts +5 -5
  102. package/types/trackers/impressionObserver/utils.d.ts +1 -1
  103. package/types/types.d.ts +0 -2
  104. package/types/utils/constants/index.d.ts +12 -0
  105. package/types/utils/inputValidation/index.d.ts +2 -2
  106. package/types/utils/inputValidation/splitExistence.d.ts +7 -0
  107. package/types/utils/inputValidation/trafficTypeExistence.d.ts +9 -0
  108. package/types/utils/lang/sets.d.ts +1 -0
  109. package/types/utils/settingsValidation/splitFilters.d.ts +3 -2
package/CHANGES.txt CHANGED
@@ -1,12 +1,18 @@
1
- 1.11.0 (November XX, 2023)
2
- - Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
3
- - Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
4
- - getTreatmentsByFlagSet and getTreatmentsByFlagSets
5
- - getTreatmentsWithConfigByFlagSets and getTreatmentsWithConfigByFlagSets
6
- - Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
7
- - Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init.
8
- - Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
9
- - Bugfixing - Fixed SDK key validation in NodeJS to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768).
1
+ 1.12.0 (December 4, 2023)
2
+ - Added support for Flag Sets in "consumer" and "partial consumer" modes for Pluggable and Redis storages.
3
+ - Updated evaluation flow to log a warning when using flag sets that don't contain cached feature flags.
4
+ - Updated Redis adapter to handle timeouts and queueing of some missing commands: 'hincrby', 'popNRaw', and 'pipeline.exec'.
5
+ - Bugfixing - Fixed manager methods in consumer modes to return results in a promise when the SDK is not operational (not ready or destroyed).
6
+
7
+ 1.11.0 (November 3, 2023)
8
+ - Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
9
+ - Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
10
+ - getTreatmentsByFlagSet and getTreatmentsByFlagSets
11
+ - getTreatmentsWithConfigByFlagSets and getTreatmentsWithConfigByFlagSets
12
+ - Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
13
+ - Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init.
14
+ - Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
15
+ - Bugfixing - Fixed SDK key validation in NodeJS to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768).
10
16
 
11
17
  1.10.0 (October 20, 2023)
12
18
  - Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).
@@ -53,7 +59,7 @@
53
59
  - Added a new impressions mode for the SDK called NONE, to be used in factory when there is no desire to capture impressions on an SDK factory to feed Split's analytics engine. Running NONE mode, the SDK will only capture unique keys evaluated for a particular feature flag instead of full blown impressions.
54
60
  - Updated SDK telemetry to support pluggable storage, partial consumer mode, and synchronizer.
55
61
  - Updated storage implementations to improve the performance of feature flag evaluations (i.e., `getTreatment(s)` method calls) when using the default storage in memory.
56
- - Updated evaluation flow to avoid unnecessarily storage calls when the SDK is not ready.
62
+ - Updated evaluation flow (i.e., `getTreatment(s)` method calls) to avoid calling the storage for cached feature flags when the SDK is not ready or ready from cache. It applies to all SDK modes.
57
63
 
58
64
  1.6.1 (July 22, 2022)
59
65
  - Updated GoogleAnalyticsToSplit integration to validate `autoRequire` config parameter and avoid some wrong warning logs when mapping GA hit fields to Split event properties.
@@ -7,6 +7,7 @@ var thenable_1 = require("../utils/promise/thenable");
7
7
  var LabelsConstants = (0, tslib_1.__importStar)(require("../utils/labels"));
8
8
  var constants_1 = require("../utils/constants");
9
9
  var sets_1 = require("../utils/lang/sets");
10
+ var constants_2 = require("../logger/constants");
10
11
  var treatmentException = {
11
12
  treatment: constants_1.CONTROL,
12
13
  label: LabelsConstants.EXCEPTION,
@@ -56,8 +57,23 @@ function evaluateFeatures(log, key, splitNames, attributes, storage) {
56
57
  getEvaluations(log, splitNames, parsedSplits, key, attributes, storage);
57
58
  }
58
59
  exports.evaluateFeatures = evaluateFeatures;
59
- function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage) {
60
+ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
60
61
  var storedFlagNames;
62
+ function evaluate(featureFlagsByFlagSets) {
63
+ var featureFlags = new sets_1._Set();
64
+ for (var i = 0; i < flagSets.length; i++) {
65
+ var featureFlagByFlagSet = featureFlagsByFlagSets[i];
66
+ if (featureFlagByFlagSet.size) {
67
+ featureFlags = (0, sets_1.returnSetsUnion)(featureFlags, featureFlagByFlagSet);
68
+ }
69
+ else {
70
+ log.warn(constants_2.WARN_FLAGSET_WITHOUT_FLAGS, [method, flagSets[i]]);
71
+ }
72
+ }
73
+ return featureFlags.size ?
74
+ evaluateFeatures(log, key, (0, sets_1.setToArray)(featureFlags), attributes, storage) :
75
+ {};
76
+ }
61
77
  // get features by flag sets
62
78
  try {
63
79
  storedFlagNames = storage.splits.getNamesByFlagSets(flagSets);
@@ -68,8 +84,11 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage) {
68
84
  }
69
85
  // evaluate related features
70
86
  return (0, thenable_1.thenable)(storedFlagNames) ?
71
- storedFlagNames.then(function (splitNames) { return evaluateFeatures(log, key, (0, sets_1.setToArray)(splitNames), attributes, storage); }) :
72
- evaluateFeatures(log, key, (0, sets_1.setToArray)(storedFlagNames), attributes, storage);
87
+ storedFlagNames.then(function (storedFlagNames) { return evaluate(storedFlagNames); })
88
+ .catch(function () {
89
+ return {};
90
+ }) :
91
+ evaluate(storedFlagNames);
73
92
  }
74
93
  exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
75
94
  function getEvaluation(log, splitJSON, key, attributes, storage) {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = 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_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.ENGINE_MATCHER_STRING_INVALID = exports.ENGINE_MATCHER_STRING = exports.ENGINE_MATCHER_SEGMENT = exports.ENGINE_MATCHER_PART_OF = exports.ENGINE_MATCHER_LESS = exports.ENGINE_MATCHER_GREATER = exports.ENGINE_MATCHER_ENDS_WITH = exports.ENGINE_MATCHER_EQUAL_TO_SET = exports.ENGINE_MATCHER_EQUAL = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_MATCHER_CONTAINS_STRING = exports.ENGINE_MATCHER_CONTAINS_ANY = exports.ENGINE_MATCHER_CONTAINS_ALL = exports.ENGINE_MATCHER_BOOLEAN = exports.ENGINE_MATCHER_BETWEEN = exports.ENGINE_MATCHER_ALL = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
4
- 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_NOT_CONFIGURED = exports.WARN_SPLITS_FILTER_LOWERCASE_SET = exports.WARN_SPLITS_FILTER_INVALID_SET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = 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 = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = 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 = 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_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = 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_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = 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 = void 0;
4
+ 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_MY_SEGMENTS_UPDATE_V2 = 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 = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = 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 = 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_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = 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_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = 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 = 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.
@@ -94,14 +94,16 @@ exports.WARN_NOT_EXISTENT_SPLIT = 215;
94
94
  exports.WARN_LOWERCASE_TRAFFIC_TYPE = 216;
95
95
  exports.WARN_NOT_EXISTENT_TT = 217;
96
96
  exports.WARN_INTEGRATION_INVALID = 218;
97
+ exports.WARN_SPLITS_FILTER_IGNORED = 219;
97
98
  exports.WARN_SPLITS_FILTER_INVALID = 220;
98
99
  exports.WARN_SPLITS_FILTER_EMPTY = 221;
99
100
  exports.WARN_SDK_KEY = 222;
100
101
  exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 223;
101
102
  exports.STREAMING_PARSING_SPLIT_UPDATE = 224;
102
- exports.WARN_SPLITS_FILTER_INVALID_SET = 225;
103
- exports.WARN_SPLITS_FILTER_LOWERCASE_SET = 226;
103
+ exports.WARN_INVALID_FLAGSET = 225;
104
+ exports.WARN_LOWERCASE_FLAGSET = 226;
104
105
  exports.WARN_FLAGSET_NOT_CONFIGURED = 227;
106
+ exports.WARN_FLAGSET_WITHOUT_FLAGS = 228;
105
107
  exports.ERROR_ENGINE_COMBINER_IFELSEIF = 300;
106
108
  exports.ERROR_LOGLEVEL_INVALID = 301;
107
109
  exports.ERROR_CLIENT_LISTENER = 302;
@@ -27,14 +27,16 @@ exports.codesWarn = error_1.codesError.concat([
27
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.'],
28
28
  [c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
29
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.'],
30
- [c.WARN_FLAGSET_NOT_CONFIGURED, '%s: : you passed %s wich is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
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'],
33
+ [c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS + ': feature flag filters are not applicable for Consumer modes where the SDK does not keep rollout data in sync. Filters were discarded'],
33
34
  [c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ': feature flag filter at position %s is invalid. It must be an object with a valid filter type ("bySet", "byName" or "byPrefix") and a list of "values".'],
34
35
  [c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
35
36
  [c.WARN_SDK_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
36
37
  [c.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching MySegments due to an error processing %s notification: %s'],
37
38
  [c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
38
- [c.WARN_SPLITS_FILTER_INVALID_SET, c.LOG_PREFIX_SETTINGS + ': 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.'],
39
- [c.WARN_SPLITS_FILTER_LOWERCASE_SET, c.LOG_PREFIX_SETTINGS + ': flag set %s should be all lowercase - converting string to lowercase.'],
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
+ [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.'],
40
42
  ]);
@@ -4,8 +4,8 @@ exports.clientFactory = void 0;
4
4
  var evaluator_1 = require("../evaluator");
5
5
  var thenable_1 = require("../utils/promise/thenable");
6
6
  var key_1 = require("../utils/key");
7
- var splitExistance_1 = require("../utils/inputValidation/splitExistance");
8
- var trafficTypeExistance_1 = require("../utils/inputValidation/trafficTypeExistance");
7
+ var splitExistence_1 = require("../utils/inputValidation/splitExistence");
8
+ var trafficTypeExistence_1 = require("../utils/inputValidation/trafficTypeExistence");
9
9
  var labels_1 = require("../utils/labels");
10
10
  var constants_1 = require("../utils/constants");
11
11
  var constants_2 = require("../logger/constants");
@@ -24,12 +24,13 @@ function treatmentsNotReady(featureFlagNames) {
24
24
  function clientFactory(params) {
25
25
  var readinessManager = params.sdkReadinessManager.readinessManager, storage = params.storage, settings = params.settings, impressionsTracker = params.impressionsTracker, eventTracker = params.eventTracker, telemetryTracker = params.telemetryTracker;
26
26
  var log = settings.log, mode = settings.mode;
27
- function getTreatment(key, featureFlagName, attributes, withConfig) {
27
+ function getTreatment(key, featureFlagName, attributes, withConfig, methodName) {
28
28
  if (withConfig === void 0) { withConfig = false; }
29
+ if (methodName === void 0) { methodName = constants_1.GET_TREATMENT; }
29
30
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? constants_1.TREATMENT_WITH_CONFIG : constants_1.TREATMENT);
30
31
  var wrapUp = function (evaluationResult) {
31
32
  var queue = [];
32
- var treatment = processEvaluation(evaluationResult, featureFlagName, key, attributes, withConfig, "getTreatment" + (withConfig ? 'withConfig' : ''), queue);
33
+ var treatment = processEvaluation(evaluationResult, featureFlagName, key, attributes, withConfig, methodName, queue);
33
34
  impressionsTracker.track(queue, attributes);
34
35
  stopTelemetryTracker(queue[0] && queue[0].label);
35
36
  return treatment;
@@ -42,16 +43,17 @@ function clientFactory(params) {
42
43
  return (0, thenable_1.thenable)(evaluation) ? evaluation.then(function (res) { return wrapUp(res); }) : wrapUp(evaluation);
43
44
  }
44
45
  function getTreatmentWithConfig(key, featureFlagName, attributes) {
45
- return getTreatment(key, featureFlagName, attributes, true);
46
+ return getTreatment(key, featureFlagName, attributes, true, constants_1.GET_TREATMENT_WITH_CONFIG);
46
47
  }
47
- function getTreatments(key, featureFlagNames, attributes, withConfig) {
48
+ function getTreatments(key, featureFlagNames, attributes, withConfig, methodName) {
48
49
  if (withConfig === void 0) { withConfig = false; }
50
+ if (methodName === void 0) { methodName = constants_1.GET_TREATMENTS; }
49
51
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? constants_1.TREATMENTS_WITH_CONFIG : constants_1.TREATMENTS);
50
52
  var wrapUp = function (evaluationResults) {
51
53
  var queue = [];
52
54
  var treatments = {};
53
55
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
54
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, attributes, withConfig, "getTreatments" + (withConfig ? 'withConfig' : ''), queue);
56
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
55
57
  });
56
58
  impressionsTracker.track(queue, attributes);
57
59
  stopTelemetryTracker(queue[0] && queue[0].label);
@@ -65,36 +67,37 @@ function clientFactory(params) {
65
67
  return (0, thenable_1.thenable)(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
66
68
  }
67
69
  function getTreatmentsWithConfig(key, featureFlagNames, attributes) {
68
- return getTreatments(key, featureFlagNames, attributes, true);
70
+ return getTreatments(key, featureFlagNames, attributes, true, constants_1.GET_TREATMENTS_WITH_CONFIG);
69
71
  }
70
- function getTreatmentsByFlagSets(key, flagSetNames, attributes, withConfig, method) {
72
+ function getTreatmentsByFlagSets(key, flagSetNames, attributes, withConfig, method, methodName) {
71
73
  if (withConfig === void 0) { withConfig = false; }
72
74
  if (method === void 0) { method = constants_1.TREATMENTS_BY_FLAGSETS; }
75
+ if (methodName === void 0) { methodName = constants_1.GET_TREATMENTS_BY_FLAG_SETS; }
73
76
  var stopTelemetryTracker = telemetryTracker.trackEval(method);
74
77
  var wrapUp = function (evaluationResults) {
75
78
  var queue = [];
76
79
  var treatments = {};
77
80
  var evaluations = evaluationResults;
78
81
  Object.keys(evaluations).forEach(function (featureFlagName) {
79
- treatments[featureFlagName] = processEvaluation(evaluations[featureFlagName], featureFlagName, key, attributes, withConfig, "getTreatmentsByFlagSets" + (withConfig ? 'WithConfig' : ''), queue);
82
+ treatments[featureFlagName] = processEvaluation(evaluations[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
80
83
  });
81
84
  impressionsTracker.track(queue, attributes);
82
85
  stopTelemetryTracker(queue[0] && queue[0].label);
83
86
  return treatments;
84
87
  };
85
88
  var evaluations = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
86
- (0, evaluator_1.evaluateFeaturesByFlagSets)(log, key, flagSetNames, attributes, storage) :
89
+ (0, evaluator_1.evaluateFeaturesByFlagSets)(log, key, flagSetNames, attributes, storage, methodName) :
87
90
  (0, utils_1.isStorageSync)(settings) ? {} : Promise.resolve({}); // Promisify if async
88
91
  return (0, thenable_1.thenable)(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
89
92
  }
90
93
  function getTreatmentsWithConfigByFlagSets(key, flagSetNames, attributes) {
91
- return getTreatmentsByFlagSets(key, flagSetNames, attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSETS);
94
+ return getTreatmentsByFlagSets(key, flagSetNames, attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSETS, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
92
95
  }
93
96
  function getTreatmentsByFlagSet(key, flagSetName, attributes) {
94
- return getTreatmentsByFlagSets(key, [flagSetName], attributes, false, constants_1.TREATMENTS_BY_FLAGSET);
97
+ return getTreatmentsByFlagSets(key, [flagSetName], attributes, false, constants_1.TREATMENTS_BY_FLAGSET, constants_1.GET_TREATMENTS_BY_FLAG_SET);
95
98
  }
96
99
  function getTreatmentsWithConfigByFlagSet(key, flagSetName, attributes) {
97
- return getTreatmentsByFlagSets(key, [flagSetName], attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSET);
100
+ return getTreatmentsByFlagSets(key, [flagSetName], attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSET, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
98
101
  }
99
102
  // Internal function
100
103
  function processEvaluation(evaluation, featureFlagName, key, attributes, withConfig, invokingMethodName, queue) {
@@ -102,7 +105,7 @@ function clientFactory(params) {
102
105
  var bucketingKey = (0, key_1.getBucketing)(key);
103
106
  var treatment = evaluation.treatment, label = evaluation.label, changeNumber = evaluation.changeNumber, _a = evaluation.config, config = _a === void 0 ? null : _a;
104
107
  log.info(constants_2.IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
105
- if ((0, splitExistance_1.validateSplitExistance)(log, readinessManager, featureFlagName, label, invokingMethodName)) {
108
+ if ((0, splitExistence_1.validateSplitExistence)(log, readinessManager, featureFlagName, label, invokingMethodName)) {
106
109
  log.info(constants_2.IMPRESSION_QUEUEING);
107
110
  queue.push({
108
111
  feature: featureFlagName,
@@ -136,7 +139,7 @@ function clientFactory(params) {
136
139
  properties: properties
137
140
  };
138
141
  // This may be async but we only warn, we don't actually care if it is valid or not in terms of queueing the event.
139
- (0, trafficTypeExistance_1.validateTrafficTypeExistance)(log, readinessManager, storage.splits, mode, trafficTypeName, 'track');
142
+ (0, trafficTypeExistence_1.validateTrafficTypeExistence)(log, readinessManager, storage.splits, mode, trafficTypeName, constants_1.TRACK_FN_LABEL);
140
143
  var result = eventTracker.track(eventData, size);
141
144
  if ((0, thenable_1.thenable)(result)) {
142
145
  return result.then(function (result) {
@@ -18,7 +18,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
18
18
  * Avoid repeating this validations code
19
19
  */
20
20
  function validateEvaluationParams(maybeKey, maybeFeatureFlagNameOrNames, maybeAttributes, methodName, maybeFlagSetNameOrNames) {
21
- var multi = (0, lang_1.startsWith)(methodName, 'getTreatments');
21
+ var multi = (0, lang_1.startsWith)(methodName, constants_1.GET_TREATMENTS);
22
22
  var key = (0, inputValidation_1.validateKey)(log, maybeKey, methodName);
23
23
  var splitOrSplits = false;
24
24
  var flagSetOrFlagSets = [];
@@ -28,7 +28,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
28
28
  var attributes = (0, inputValidation_1.validateAttributes)(log, maybeAttributes, methodName);
29
29
  var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, methodName);
30
30
  if (maybeFlagSetNameOrNames) {
31
- flagSetOrFlagSets = (0, splitFilters_1.flagSetsAreValid)(log, methodName, maybeFlagSetNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet);
31
+ flagSetOrFlagSets = (0, splitFilters_1.validateFlagSets)(log, methodName, maybeFlagSetNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet);
32
32
  }
33
33
  (0, inputValidation_1.validateIfOperational)(log, readinessManager, methodName, splitOrSplits);
34
34
  var valid = isNotDestroyed && key && (splitOrSplits || flagSetOrFlagSets.length > 0) && attributes !== false;
@@ -44,7 +44,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
44
44
  return isSync ? value : Promise.resolve(value);
45
45
  }
46
46
  function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
47
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, 'getTreatment');
47
+ var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, constants_1.GET_TREATMENT);
48
48
  if (params.valid) {
49
49
  return client.getTreatment(params.key, params.splitOrSplits, params.attributes);
50
50
  }
@@ -53,7 +53,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
53
53
  }
54
54
  }
55
55
  function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
56
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, 'getTreatmentWithConfig');
56
+ var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, constants_1.GET_TREATMENT_WITH_CONFIG);
57
57
  if (params.valid) {
58
58
  return client.getTreatmentWithConfig(params.key, params.splitOrSplits, params.attributes);
59
59
  }
@@ -62,7 +62,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
62
62
  }
63
63
  }
64
64
  function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
65
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, 'getTreatments');
65
+ var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, constants_1.GET_TREATMENTS);
66
66
  if (params.valid) {
67
67
  return client.getTreatments(params.key, params.splitOrSplits, params.attributes);
68
68
  }
@@ -74,7 +74,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
74
74
  }
75
75
  }
76
76
  function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
77
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, 'getTreatmentsWithConfig');
77
+ var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG);
78
78
  if (params.valid) {
79
79
  return client.getTreatmentsWithConfig(params.key, params.splitOrSplits, params.attributes);
80
80
  }
@@ -86,7 +86,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
86
86
  }
87
87
  }
88
88
  function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
89
- var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsByFlagSets', maybeFlagSets);
89
+ var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, constants_1.GET_TREATMENTS_BY_FLAG_SETS, maybeFlagSets);
90
90
  if (params.valid) {
91
91
  return client.getTreatmentsByFlagSets(params.key, params.flagSetOrFlagSets, params.attributes);
92
92
  }
@@ -95,7 +95,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
95
95
  }
96
96
  }
97
97
  function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
98
- var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsWithConfigByFlagSets', maybeFlagSets);
98
+ var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, maybeFlagSets);
99
99
  if (params.valid) {
100
100
  return client.getTreatmentsWithConfigByFlagSets(params.key, params.flagSetOrFlagSets, params.attributes);
101
101
  }
@@ -104,7 +104,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
104
104
  }
105
105
  }
106
106
  function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
107
- var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsByFlagSet', [maybeFlagSet]);
107
+ var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, constants_1.GET_TREATMENTS_BY_FLAG_SET, [maybeFlagSet]);
108
108
  if (params.valid) {
109
109
  return client.getTreatmentsByFlagSet(params.key, params.flagSetOrFlagSets[0], params.attributes);
110
110
  }
@@ -113,7 +113,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
113
113
  }
114
114
  }
115
115
  function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
116
- var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsWithConfigByFlagSet', [maybeFlagSet]);
116
+ var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, [maybeFlagSet]);
117
117
  if (params.valid) {
118
118
  return client.getTreatmentsWithConfigByFlagSet(params.key, params.flagSetOrFlagSets[0], params.attributes);
119
119
  }
@@ -122,12 +122,12 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
122
122
  }
123
123
  }
124
124
  function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
125
- var key = (0, inputValidation_1.validateKey)(log, maybeKey, 'track');
126
- var tt = (0, inputValidation_1.validateTrafficType)(log, maybeTT, 'track');
127
- var event = (0, inputValidation_1.validateEvent)(log, maybeEvent, 'track');
128
- var eventValue = (0, inputValidation_1.validateEventValue)(log, maybeEventValue, 'track');
129
- var _a = (0, inputValidation_1.validateEventProperties)(log, maybeProperties, 'track'), properties = _a.properties, size = _a.size;
130
- var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, 'track');
125
+ var key = (0, inputValidation_1.validateKey)(log, maybeKey, constants_1.TRACK_FN_LABEL);
126
+ var tt = (0, inputValidation_1.validateTrafficType)(log, maybeTT, constants_1.TRACK_FN_LABEL);
127
+ var event = (0, inputValidation_1.validateEvent)(log, maybeEvent, constants_1.TRACK_FN_LABEL);
128
+ var eventValue = (0, inputValidation_1.validateEventValue)(log, maybeEventValue, constants_1.TRACK_FN_LABEL);
129
+ var _a = (0, inputValidation_1.validateEventProperties)(log, maybeProperties, constants_1.TRACK_FN_LABEL), properties = _a.properties, size = _a.size;
130
+ var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.TRACK_FN_LABEL);
131
131
  if (isNotDestroyed && key && tt && event && eventValue !== false && properties !== false) { // @ts-expect-error
132
132
  return client.track(key, tt, event, eventValue, properties, size);
133
133
  }
@@ -66,7 +66,7 @@ function sdkFactory(params) {
66
66
  ctx.signalListener = signalListener;
67
67
  // SDK client and manager
68
68
  var clientMethod = sdkClientMethodFactory(ctx);
69
- var managerInstance = sdkManagerFactory(log, storage.splits, sdkReadinessManager);
69
+ var managerInstance = sdkManagerFactory(settings, storage.splits, sdkReadinessManager);
70
70
  syncManager && syncManager.start();
71
71
  signalListener && signalListener.start();
72
72
  log.info(constants_1.NEW_FACTORY);
@@ -5,9 +5,8 @@ var objectAssign_1 = require("../utils/lang/objectAssign");
5
5
  var thenable_1 = require("../utils/promise/thenable");
6
6
  var lang_1 = require("../utils/lang");
7
7
  var inputValidation_1 = require("../utils/inputValidation");
8
- var SPLIT_FN_LABEL = 'split';
9
- var SPLITS_FN_LABEL = 'splits';
10
- var NAMES_FN_LABEL = 'names';
8
+ var utils_1 = require("../trackers/impressionObserver/utils");
9
+ var constants_1 = require("../utils/constants");
11
10
  function collectTreatments(splitObject) {
12
11
  var conditions = splitObject.conditions;
13
12
  // Rollout conditions are supposed to have the entire partitions list, so we find the first one.
@@ -41,8 +40,10 @@ function objectsToViews(splitObjects) {
41
40
  });
42
41
  return views;
43
42
  }
44
- function sdkManagerFactory(log, splits, _a) {
43
+ function sdkManagerFactory(settings, splits, _a) {
45
44
  var readinessManager = _a.readinessManager, sdkStatus = _a.sdkStatus;
45
+ var log = settings.log;
46
+ var isSync = (0, utils_1.isStorageSync)(settings);
46
47
  return (0, objectAssign_1.objectAssign)(
47
48
  // Proto-linkage of the readiness Event Emitter
48
49
  Object.create(sdkStatus), {
@@ -50,26 +51,26 @@ function sdkManagerFactory(log, splits, _a) {
50
51
  * Get the feature flag object corresponding to the given feature flag name if valid
51
52
  */
52
53
  split: function (featureFlagName) {
53
- var splitName = (0, inputValidation_1.validateSplit)(log, featureFlagName, SPLIT_FN_LABEL);
54
- if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, SPLIT_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, SPLIT_FN_LABEL) || !splitName) {
55
- return null;
54
+ var splitName = (0, inputValidation_1.validateSplit)(log, featureFlagName, constants_1.SPLIT_FN_LABEL);
55
+ if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.SPLIT_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.SPLIT_FN_LABEL) || !splitName) {
56
+ return isSync ? null : Promise.resolve(null);
56
57
  }
57
58
  var split = splits.getSplit(splitName);
58
59
  if ((0, thenable_1.thenable)(split)) {
59
60
  return split.catch(function () { return null; }).then(function (result) {
60
- (0, inputValidation_1.validateSplitExistance)(log, readinessManager, splitName, result, SPLIT_FN_LABEL);
61
+ (0, inputValidation_1.validateSplitExistence)(log, readinessManager, splitName, result, constants_1.SPLIT_FN_LABEL);
61
62
  return objectToView(result);
62
63
  });
63
64
  }
64
- (0, inputValidation_1.validateSplitExistance)(log, readinessManager, splitName, split, SPLIT_FN_LABEL);
65
+ (0, inputValidation_1.validateSplitExistence)(log, readinessManager, splitName, split, constants_1.SPLIT_FN_LABEL);
65
66
  return objectToView(split);
66
67
  },
67
68
  /**
68
69
  * Get the feature flag objects present on the factory storage
69
70
  */
70
71
  splits: function () {
71
- if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, SPLITS_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, SPLITS_FN_LABEL)) {
72
- return [];
72
+ if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.SPLITS_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.SPLITS_FN_LABEL)) {
73
+ return isSync ? [] : Promise.resolve([]);
73
74
  }
74
75
  var currentSplits = splits.getAll();
75
76
  return (0, thenable_1.thenable)(currentSplits) ?
@@ -80,8 +81,8 @@ function sdkManagerFactory(log, splits, _a) {
80
81
  * Get the feature flag names present on the factory storage
81
82
  */
82
83
  names: function () {
83
- if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, NAMES_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, NAMES_FN_LABEL)) {
84
- return [];
84
+ if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.NAMES_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.NAMES_FN_LABEL)) {
85
+ return isSync ? [] : Promise.resolve([]);
85
86
  }
86
87
  var splitNames = splits.getSplitNames();
87
88
  return (0, thenable_1.thenable)(splitNames) ?
@@ -17,7 +17,7 @@ var KeyBuilder = /** @class */ (function () {
17
17
  return this.prefix + ".trafficType." + trafficType;
18
18
  };
19
19
  KeyBuilder.prototype.buildFlagSetKey = function (flagSet) {
20
- return this.prefix + ".flagset." + flagSet;
20
+ return this.prefix + ".flagSet." + flagSet;
21
21
  };
22
22
  KeyBuilder.prototype.buildSplitKey = function (splitName) {
23
23
  return this.prefix + ".split." + splitName;
@@ -231,16 +231,11 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
231
231
  };
232
232
  SplitsCacheInLocal.prototype.getNamesByFlagSets = function (flagSets) {
233
233
  var _this = this;
234
- var toReturn = new sets_1._Set([]);
235
- flagSets.forEach(function (flagSet) {
234
+ return flagSets.map(function (flagSet) {
236
235
  var flagSetKey = _this.keys.buildFlagSetKey(flagSet);
237
236
  var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
238
- if (flagSetFromLocalStorage) {
239
- var flagSetCache = new sets_1._Set(JSON.parse(flagSetFromLocalStorage));
240
- toReturn = (0, sets_1.returnSetsUnion)(toReturn, flagSetCache);
241
- }
237
+ return new sets_1._Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
242
238
  });
243
- return toReturn;
244
239
  };
245
240
  SplitsCacheInLocal.prototype.addToFlagSets = function (featureFlag) {
246
241
  var _this = this;
@@ -251,9 +246,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
251
246
  return;
252
247
  var flagSetKey = _this.keys.buildFlagSetKey(featureFlagSet);
253
248
  var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
254
- if (!flagSetFromLocalStorage)
255
- flagSetFromLocalStorage = '[]';
256
- var flagSetCache = new sets_1._Set(JSON.parse(flagSetFromLocalStorage));
249
+ var flagSetCache = new sets_1._Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
257
250
  flagSetCache.add(featureFlag.name);
258
251
  localStorage.setItem(flagSetKey, JSON.stringify((0, sets_1.setToArray)(flagSetCache)));
259
252
  });
@@ -12,14 +12,13 @@ var sets_1 = require("../../utils/lang/sets");
12
12
  var SplitsCacheInMemory = /** @class */ (function (_super) {
13
13
  (0, tslib_1.__extends)(SplitsCacheInMemory, _super);
14
14
  function SplitsCacheInMemory(splitFiltersValidation) {
15
- if (splitFiltersValidation === void 0) { splitFiltersValidation = { queryString: null, groupedFilters: { bySet: [], byName: [], byPrefix: [] }, validFilters: [] }; }
16
15
  var _this = _super.call(this) || this;
17
16
  _this.splitsCache = {};
18
17
  _this.ttCache = {};
19
18
  _this.changeNumber = -1;
20
19
  _this.splitsWithSegmentsCount = 0;
21
20
  _this.flagSetsCache = {};
22
- _this.flagSetsFilter = splitFiltersValidation.groupedFilters.bySet;
21
+ _this.flagSetsFilter = splitFiltersValidation ? splitFiltersValidation.groupedFilters.bySet : [];
23
22
  return _this;
24
23
  }
25
24
  SplitsCacheInMemory.prototype.clear = function () {
@@ -96,14 +95,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
96
95
  };
97
96
  SplitsCacheInMemory.prototype.getNamesByFlagSets = function (flagSets) {
98
97
  var _this = this;
99
- var toReturn = new sets_1._Set([]);
100
- flagSets.forEach(function (flagSet) {
101
- var featureFlagNames = _this.flagSetsCache[flagSet];
102
- if (featureFlagNames) {
103
- toReturn = (0, sets_1.returnSetsUnion)(toReturn, featureFlagNames);
104
- }
105
- });
106
- return toReturn;
98
+ return flagSets.map(function (flagSet) { return _this.flagSetsCache[flagSet] || new sets_1._Set(); });
107
99
  };
108
100
  SplitsCacheInMemory.prototype.addToFlagSets = function (featureFlag) {
109
101
  var _this = this;