@splitsoftware/splitio-commons 2.7.9-rc.0 → 2.7.9-rc.2

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 (74) hide show
  1. package/CHANGES.txt +9 -3
  2. package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +8 -4
  3. package/cjs/logger/constants.js +2 -2
  4. package/cjs/logger/index.js +0 -3
  5. package/cjs/logger/messages/info.js +1 -1
  6. package/cjs/logger/messages/warn.js +3 -3
  7. package/cjs/readiness/readinessManager.js +3 -5
  8. package/cjs/readiness/sdkReadinessManager.js +46 -10
  9. package/cjs/sdkClient/client.js +4 -4
  10. package/cjs/sdkClient/clientInputValidation.js +1 -1
  11. package/cjs/sdkManager/index.js +3 -3
  12. package/cjs/storages/inMemory/TelemetryCacheInMemory.js +2 -1
  13. package/cjs/storages/pluggable/index.js +2 -1
  14. package/cjs/sync/polling/fetchers/splitChangesFetcher.js +2 -1
  15. package/cjs/sync/streaming/SSEClient/index.js +2 -1
  16. package/cjs/sync/streaming/SSEHandler/index.js +1 -1
  17. package/cjs/sync/streaming/pushManager.js +1 -1
  18. package/cjs/sync/submitters/telemetrySubmitter.js +7 -6
  19. package/cjs/trackers/telemetryTracker.js +6 -6
  20. package/cjs/utils/inputValidation/index.js +2 -1
  21. package/cjs/utils/inputValidation/isOperational.js +9 -4
  22. package/cjs/utils/inputValidation/splitExistence.js +3 -3
  23. package/cjs/utils/key/index.js +5 -1
  24. package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -1
  25. package/esm/logger/constants.js +1 -1
  26. package/esm/logger/index.js +0 -3
  27. package/esm/logger/messages/info.js +1 -1
  28. package/esm/logger/messages/warn.js +3 -3
  29. package/esm/readiness/readinessManager.js +3 -5
  30. package/esm/readiness/sdkReadinessManager.js +46 -10
  31. package/esm/sdkClient/client.js +4 -4
  32. package/esm/sdkClient/clientInputValidation.js +2 -2
  33. package/esm/sdkManager/index.js +4 -4
  34. package/esm/storages/inMemory/TelemetryCacheInMemory.js +2 -1
  35. package/esm/storages/pluggable/index.js +2 -1
  36. package/esm/sync/polling/fetchers/splitChangesFetcher.js +2 -1
  37. package/esm/sync/streaming/SSEClient/index.js +2 -1
  38. package/esm/sync/streaming/SSEHandler/index.js +1 -1
  39. package/esm/sync/streaming/pushManager.js +2 -2
  40. package/esm/sync/submitters/telemetrySubmitter.js +7 -6
  41. package/esm/trackers/telemetryTracker.js +6 -6
  42. package/esm/utils/inputValidation/index.js +1 -1
  43. package/esm/utils/inputValidation/isOperational.js +8 -4
  44. package/esm/utils/inputValidation/splitExistence.js +3 -3
  45. package/esm/utils/key/index.js +3 -0
  46. package/package.json +1 -1
  47. package/src/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.ts +4 -1
  48. package/src/logger/constants.ts +1 -1
  49. package/src/logger/index.ts +0 -2
  50. package/src/logger/messages/info.ts +1 -1
  51. package/src/logger/messages/warn.ts +3 -3
  52. package/src/readiness/readinessManager.ts +3 -4
  53. package/src/readiness/sdkReadinessManager.ts +43 -10
  54. package/src/readiness/types.ts +1 -2
  55. package/src/sdkClient/client.ts +4 -4
  56. package/src/sdkClient/clientInputValidation.ts +3 -3
  57. package/src/sdkManager/index.ts +4 -4
  58. package/src/storages/inMemory/TelemetryCacheInMemory.ts +2 -1
  59. package/src/storages/pluggable/index.ts +2 -1
  60. package/src/sync/polling/fetchers/splitChangesFetcher.ts +2 -1
  61. package/src/sync/streaming/SSEClient/index.ts +2 -1
  62. package/src/sync/streaming/SSEHandler/index.ts +1 -1
  63. package/src/sync/streaming/pushManager.ts +2 -2
  64. package/src/sync/submitters/telemetrySubmitter.ts +7 -6
  65. package/src/trackers/telemetryTracker.ts +6 -6
  66. package/src/types.ts +0 -15
  67. package/src/utils/inputValidation/index.ts +1 -1
  68. package/src/utils/inputValidation/isOperational.ts +9 -4
  69. package/src/utils/inputValidation/splitExistence.ts +3 -3
  70. package/src/utils/key/index.ts +5 -0
  71. package/types/splitio.d.ts +77 -10
  72. package/cjs/evaluator/fallbackTreatmentsCalculator/constants.js +0 -8
  73. package/esm/evaluator/fallbackTreatmentsCalculator/constants.js +0 -5
  74. package/src/evaluator/fallbackTreatmentsCalculator/constants.ts +0 -4
package/CHANGES.txt CHANGED
@@ -1,8 +1,14 @@
1
- 2.8.0 (October XX, 2025)
2
- - Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs.
1
+ 2.8.0 (October 28, 2025)
2
+ - Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs.
3
+ - Added `client.getStatus()` method to retrieve the client readiness status properties (`isReady`, `isReadyFromCache`, etc).
4
+ - Added `client.whenReady()` and `client.whenReadyFromCache()` methods to replace the deprecated `client.ready()` method, which has an issue causing the returned promise to hang when using async/await syntax if it was rejected.
5
+ - Updated the SDK_READY_FROM_CACHE event to be emitted alongside the SDK_READY event if it hasn’t already been emitted.
6
+
7
+ 2.7.1 (October 8, 2025)
8
+ - Bugfix - Update `debug` option to support log levels when `logger` option is used.
3
9
 
4
10
  2.7.0 (October 7, 2025)
5
- - Added support for custom loggers: added `logger` configuration option and `LoggerAPI.setLogger` method to allow the SDK to use a custom logger.
11
+ - Added support for custom loggers: added `logger` configuration option and `factory.Logger.setLogger` method to allow the SDK to use a custom logger.
6
12
 
7
13
  2.6.0 (September 18, 2025)
8
14
  - Added `storage.wrapper` configuration option to allow the SDK to use a custom storage wrapper for the storage type `LOCALSTORAGE`. Default value is `window.localStorage`.
@@ -2,7 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FallbacksSanitizer = void 0;
4
4
  var lang_1 = require("../../../utils/lang");
5
- var constants_1 = require("../constants");
5
+ var FallbackDiscardReason;
6
+ (function (FallbackDiscardReason) {
7
+ FallbackDiscardReason["FlagName"] = "Invalid flag name (max 100 chars, no spaces)";
8
+ FallbackDiscardReason["Treatment"] = "Invalid treatment (max 100 chars and must match pattern)";
9
+ })(FallbackDiscardReason || (FallbackDiscardReason = {}));
6
10
  var FallbacksSanitizer = /** @class */ (function () {
7
11
  function FallbacksSanitizer() {
8
12
  }
@@ -18,7 +22,7 @@ var FallbacksSanitizer = /** @class */ (function () {
18
22
  };
19
23
  FallbacksSanitizer.sanitizeGlobal = function (logger, treatment) {
20
24
  if (!this.isValidTreatment(treatment)) {
21
- logger.error("Fallback treatments - Discarded fallback: " + constants_1.FallbackDiscardReason.Treatment);
25
+ logger.error("Fallback treatments - Discarded fallback: " + FallbackDiscardReason.Treatment);
22
26
  return undefined;
23
27
  }
24
28
  return treatment;
@@ -30,11 +34,11 @@ var FallbacksSanitizer = /** @class */ (function () {
30
34
  entries.forEach(function (flag) {
31
35
  var t = byFlagFallbacks[flag];
32
36
  if (!_this.isValidFlagName(flag)) {
33
- logger.error("Fallback treatments - Discarded flag '" + flag + "': " + constants_1.FallbackDiscardReason.FlagName);
37
+ logger.error("Fallback treatments - Discarded flag '" + flag + "': " + FallbackDiscardReason.FlagName);
34
38
  return;
35
39
  }
36
40
  if (!_this.isValidTreatment(t)) {
37
- logger.error("Fallback treatments - Discarded treatment for flag '" + flag + "': " + constants_1.FallbackDiscardReason.Treatment);
41
+ logger.error("Fallback treatments - Discarded treatment for flag '" + flag + "': " + FallbackDiscardReason.Treatment);
38
42
  return;
39
43
  }
40
44
  sanitizedByFlag[flag] = t;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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 = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = 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
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;
6
6
  /**
7
7
  * Message codes used to trim string log messages from commons and client-side API modules,
@@ -63,7 +63,7 @@ exports.SUBMITTERS_PUSH_PAGE_HIDDEN = 125;
63
63
  exports.ENGINE_VALUE_INVALID = 200;
64
64
  exports.ENGINE_VALUE_NO_ATTRIBUTES = 201;
65
65
  exports.CLIENT_NO_LISTENER = 202;
66
- exports.CLIENT_NOT_READY = 203;
66
+ exports.CLIENT_NOT_READY_FROM_CACHE = 203;
67
67
  exports.SYNC_MYSEGMENTS_FETCH_RETRY = 204;
68
68
  exports.SYNC_SPLITS_FETCH_FAILS = 205;
69
69
  exports.STREAMING_PARSING_ERROR_FAILS = 206;
@@ -63,9 +63,6 @@ var Logger = /** @class */ (function () {
63
63
  if (logger) {
64
64
  if ((0, commons_1.isLogger)(logger)) {
65
65
  this.logger = logger;
66
- // If custom logger is set, all logs are either enabled or disabled
67
- if (this.logLevel !== LogLevelIndexes.NONE)
68
- this.setLogLevel(exports.LogLevels.DEBUG);
69
66
  return;
70
67
  }
71
68
  else {
@@ -23,7 +23,7 @@ exports.codesInfo = warn_1.codesWarn.concat([
23
23
  [c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
24
24
  [c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
25
25
  [c.POLLING_STOP, c.LOG_PREFIX_SYNC_POLLING + 'Stopping polling'],
26
- [c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying download of feature flags #%s. Reason: %s'],
26
+ [c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying fetch of feature flags (attempt #%s). Reason: %s'],
27
27
  [c.SUBMITTERS_PUSH_FULL_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full %s queue and resetting timer.'],
28
28
  [c.SUBMITTERS_PUSH, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Pushing %s.'],
29
29
  [c.SUBMITTERS_PUSH_PAGE_HIDDEN, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing %s because page became hidden.'],
@@ -9,7 +9,7 @@ exports.codesWarn = error_1.codesError.concat([
9
9
  [c.ENGINE_VALUE_INVALID, c.LOG_PREFIX_ENGINE_VALUE + 'Value %s doesn\'t match with expected type.'],
10
10
  [c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute `%s`. No attributes received.'],
11
11
  // synchronizer
12
- [c.SYNC_MYSEGMENTS_FETCH_RETRY, c.LOG_PREFIX_SYNC_MYSEGMENTS + 'Retrying download of segments #%s. Reason: %s'],
12
+ [c.SYNC_MYSEGMENTS_FETCH_RETRY, c.LOG_PREFIX_SYNC_MYSEGMENTS + 'Retrying fetch of memberships (attempt #%s). Reason: %s'],
13
13
  [c.SYNC_SPLITS_FETCH_FAILS, c.LOG_PREFIX_SYNC_SPLITS + 'Error while doing fetch of feature flags. %s'],
14
14
  [c.STREAMING_PARSING_ERROR_FAILS, c.LOG_PREFIX_SYNC_STREAMING + 'Error parsing SSE error notification: %s'],
15
15
  [c.STREAMING_PARSING_MESSAGE_FAILS, c.LOG_PREFIX_SYNC_STREAMING + 'Error parsing SSE message notification: %s'],
@@ -17,8 +17,8 @@ exports.codesWarn = error_1.codesError.concat([
17
17
  [c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s.'],
18
18
  [c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s.'],
19
19
  // client status
20
- [c.CLIENT_NOT_READY, '%s: the SDK is not ready, results may be incorrect%s. Make sure to wait for SDK readiness before using this method.'],
21
- [c.CLIENT_NO_LISTENER, 'No listeners for SDK Readiness detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet ready.'],
20
+ [c.CLIENT_NOT_READY_FROM_CACHE, '%s: the SDK is not ready to evaluate. Results may be incorrect%s. Make sure to wait for SDK readiness before using this method.'],
21
+ [c.CLIENT_NO_LISTENER, 'No listeners for SDK_READY event detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet synchronized with the backend.'],
22
22
  // input validation
23
23
  [c.WARN_SETTING_NULL, '%s: Property "%s" is of invalid type. Setting value to null.'],
24
24
  [c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readinessManagerFactory = void 0;
4
4
  var objectAssign_1 = require("../utils/lang/objectAssign");
5
5
  var constants_1 = require("./constants");
6
- var constants_2 = require("../utils/constants");
7
6
  function splitsEventEmitterFactory(EventEmitter) {
8
7
  var splitsEventEmitter = (0, objectAssign_1.objectAssign)(new EventEmitter(), {
9
8
  splitsArrived: false,
@@ -75,7 +74,7 @@ function readinessManagerFactory(EventEmitter, settings, splits, isShared) {
75
74
  if (!isReady && !isDestroyed) {
76
75
  try {
77
76
  syncLastUpdate();
78
- gate.emit(constants_1.SDK_READY_FROM_CACHE);
77
+ gate.emit(constants_1.SDK_READY_FROM_CACHE, isReady);
79
78
  }
80
79
  catch (e) {
81
80
  // throws user callback exceptions in next tick
@@ -84,7 +83,6 @@ function readinessManagerFactory(EventEmitter, settings, splits, isShared) {
84
83
  }
85
84
  }
86
85
  function checkIsReadyOrUpdate(diff) {
87
- var _a;
88
86
  if (isDestroyed)
89
87
  return;
90
88
  if (isReady) {
@@ -103,9 +101,9 @@ function readinessManagerFactory(EventEmitter, settings, splits, isShared) {
103
101
  isReady = true;
104
102
  try {
105
103
  syncLastUpdate();
106
- if (!isReadyFromCache && ((_a = settings.storage) === null || _a === void 0 ? void 0 : _a.type) === constants_2.STORAGE_LOCALSTORAGE) {
104
+ if (!isReadyFromCache) {
107
105
  isReadyFromCache = true;
108
- gate.emit(constants_1.SDK_READY_FROM_CACHE);
106
+ gate.emit(constants_1.SDK_READY_FROM_CACHE, isReady);
109
107
  }
110
108
  gate.emit(constants_1.SDK_READY);
111
109
  }
@@ -8,6 +8,7 @@ var constants_1 = require("./constants");
8
8
  var constants_2 = require("../logger/constants");
9
9
  var NEW_LISTENER_EVENT = 'newListener';
10
10
  var REMOVE_LISTENER_EVENT = 'removeListener';
11
+ var TIMEOUT_ERROR = new Error(constants_1.SDK_READY_TIMED_OUT);
11
12
  /**
12
13
  * SdkReadinessManager factory, which provides the public status API of SDK clients and manager: ready promise, readiness event emitter and constants (SDK_READY, etc).
13
14
  * It also updates logs related warnings and errors.
@@ -34,6 +35,9 @@ function sdkReadinessManagerFactory(EventEmitter, settings, readinessManager) {
34
35
  readyCbCount++;
35
36
  }
36
37
  }
38
+ else if (event === constants_1.SDK_READY_FROM_CACHE && readinessManager.isReadyFromCache()) {
39
+ log.error(constants_2.ERROR_CLIENT_LISTENER, ['SDK_READY_FROM_CACHE']);
40
+ }
37
41
  });
38
42
  /** Ready promise */
39
43
  var readyPromise = generateReadyPromise();
@@ -58,6 +62,17 @@ function sdkReadinessManagerFactory(EventEmitter, settings, readinessManager) {
58
62
  }), defaultOnRejected);
59
63
  return promise;
60
64
  }
65
+ function getStatus() {
66
+ return {
67
+ isReady: readinessManager.isReady(),
68
+ isReadyFromCache: readinessManager.isReadyFromCache(),
69
+ isTimedout: readinessManager.isTimedout(),
70
+ hasTimedout: readinessManager.hasTimedout(),
71
+ isDestroyed: readinessManager.isDestroyed(),
72
+ isOperational: readinessManager.isOperational(),
73
+ lastUpdate: readinessManager.lastUpdate(),
74
+ };
75
+ }
61
76
  return {
62
77
  readinessManager: readinessManager,
63
78
  shared: function () {
@@ -76,6 +91,7 @@ function sdkReadinessManagerFactory(EventEmitter, settings, readinessManager) {
76
91
  SDK_UPDATE: constants_1.SDK_UPDATE,
77
92
  SDK_READY_TIMED_OUT: constants_1.SDK_READY_TIMED_OUT,
78
93
  },
94
+ // @TODO: remove in next major
79
95
  ready: function () {
80
96
  if (readinessManager.hasTimedout()) {
81
97
  if (!readinessManager.isReady()) {
@@ -87,17 +103,37 @@ function sdkReadinessManagerFactory(EventEmitter, settings, readinessManager) {
87
103
  }
88
104
  return readyPromise;
89
105
  },
90
- __getStatus: function () {
91
- return {
92
- isReady: readinessManager.isReady(),
93
- isReadyFromCache: readinessManager.isReadyFromCache(),
94
- isTimedout: readinessManager.isTimedout(),
95
- hasTimedout: readinessManager.hasTimedout(),
96
- isDestroyed: readinessManager.isDestroyed(),
97
- isOperational: readinessManager.isOperational(),
98
- lastUpdate: readinessManager.lastUpdate(),
99
- };
106
+ whenReady: function () {
107
+ return new Promise(function (resolve, reject) {
108
+ if (readinessManager.isReady()) {
109
+ resolve();
110
+ }
111
+ else if (readinessManager.hasTimedout()) {
112
+ reject(TIMEOUT_ERROR);
113
+ }
114
+ else {
115
+ readinessManager.gate.once(constants_1.SDK_READY, resolve);
116
+ readinessManager.gate.once(constants_1.SDK_READY_TIMED_OUT, function () { return reject(TIMEOUT_ERROR); });
117
+ }
118
+ });
119
+ },
120
+ whenReadyFromCache: function () {
121
+ return new Promise(function (resolve, reject) {
122
+ if (readinessManager.isReadyFromCache()) {
123
+ resolve(readinessManager.isReady());
124
+ }
125
+ else if (readinessManager.hasTimedout()) {
126
+ reject(TIMEOUT_ERROR);
127
+ }
128
+ else {
129
+ readinessManager.gate.once(constants_1.SDK_READY_FROM_CACHE, function () { return resolve(readinessManager.isReady()); });
130
+ readinessManager.gate.once(constants_1.SDK_READY_TIMED_OUT, function () { return reject(TIMEOUT_ERROR); });
131
+ }
132
+ });
100
133
  },
134
+ getStatus: getStatus,
135
+ // @TODO: remove in next major
136
+ __getStatus: getStatus
101
137
  })
102
138
  };
103
139
  }
@@ -44,7 +44,7 @@ function clientFactory(params) {
44
44
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
45
45
  return treatment;
46
46
  };
47
- var evaluation = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
47
+ var evaluation = readinessManager.isReadyFromCache() ?
48
48
  (0, evaluator_1.evaluateFeature)(log, key, featureFlagName, attributes, storage) :
49
49
  isAsync ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
50
50
  Promise.resolve(treatmentNotReady) :
@@ -69,7 +69,7 @@ function clientFactory(params) {
69
69
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
70
70
  return treatments;
71
71
  };
72
- var evaluations = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
72
+ var evaluations = readinessManager.isReadyFromCache() ?
73
73
  (0, evaluator_1.evaluateFeatures)(log, key, featureFlagNames, attributes, storage) :
74
74
  isAsync ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
75
75
  Promise.resolve(treatmentsNotReady(featureFlagNames)) :
@@ -95,7 +95,7 @@ function clientFactory(params) {
95
95
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
96
96
  return treatments;
97
97
  };
98
- var evaluations = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
98
+ var evaluations = readinessManager.isReadyFromCache() ?
99
99
  (0, evaluator_1.evaluateFeaturesByFlagSets)(log, key, flagSetNames, attributes, storage, methodName) :
100
100
  isAsync ?
101
101
  Promise.resolve({}) :
@@ -120,7 +120,7 @@ function clientFactory(params) {
120
120
  if (treatment === constants_1.CONTROL) {
121
121
  var fallbackTreatment = fallbackTreatmentsCalculator.resolve(featureFlagName, label);
122
122
  treatment = fallbackTreatment.treatment;
123
- label = fallbackTreatment.label ? fallbackTreatment.label : label;
123
+ label = fallbackTreatment.label;
124
124
  config = fallbackTreatment.config;
125
125
  }
126
126
  log.info(constants_2.IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
@@ -26,7 +26,7 @@ function clientInputValidationDecorator(settings, client, readinessManager, fall
26
26
  var attributes = (0, inputValidation_1.validateAttributes)(log, maybeAttributes, methodName);
27
27
  var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, methodName);
28
28
  var options = (0, inputValidation_1.validateEvaluationOptions)(log, maybeOptions, methodName);
29
- (0, inputValidation_1.validateIfOperational)(log, readinessManager, methodName, nameOrNames);
29
+ (0, inputValidation_1.validateIfReadyFromCache)(log, readinessManager, methodName, nameOrNames);
30
30
  var valid = isNotDestroyed && key && nameOrNames && attributes !== false;
31
31
  return {
32
32
  valid: valid,
@@ -54,7 +54,7 @@ function sdkManagerFactory(settings, splits, _a) {
54
54
  */
55
55
  split: function (featureFlagName) {
56
56
  var splitName = (0, inputValidation_1.validateSplit)(log, featureFlagName, constants_1.SPLIT_FN_LABEL);
57
- if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.SPLIT_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.SPLIT_FN_LABEL) || !splitName) {
57
+ if (!(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.SPLIT_FN_LABEL) || !splitName) {
58
58
  return isAsync ? Promise.resolve(null) : null;
59
59
  }
60
60
  var split = splits.getSplit(splitName);
@@ -71,7 +71,7 @@ function sdkManagerFactory(settings, splits, _a) {
71
71
  * Get the feature flag objects present on the factory storage
72
72
  */
73
73
  splits: function () {
74
- if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.SPLITS_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.SPLITS_FN_LABEL)) {
74
+ if (!(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.SPLITS_FN_LABEL)) {
75
75
  return isAsync ? Promise.resolve([]) : [];
76
76
  }
77
77
  var currentSplits = splits.getAll();
@@ -83,7 +83,7 @@ function sdkManagerFactory(settings, splits, _a) {
83
83
  * Get the feature flag names present on the factory storage
84
84
  */
85
85
  names: function () {
86
- if (!(0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.NAMES_FN_LABEL) || !(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.NAMES_FN_LABEL)) {
86
+ if (!(0, inputValidation_1.validateIfOperational)(log, readinessManager, constants_1.NAMES_FN_LABEL)) {
87
87
  return isAsync ? Promise.resolve([]) : [];
88
88
  }
89
89
  var splitNames = splits.getSplitNames();
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TelemetryCacheInMemory = exports.shouldRecordTelemetry = exports.newBuckets = exports.MAX_LATENCY_BUCKET_COUNT = void 0;
4
4
  var constants_1 = require("../../utils/constants");
5
+ var key_1 = require("../../utils/key");
5
6
  var findLatencyIndex_1 = require("../findLatencyIndex");
6
7
  var MAX_STREAMING_EVENTS = 20;
7
8
  var MAX_TAGS = 10;
@@ -19,7 +20,7 @@ var ACCEPTANCE_RANGE = 0.001;
19
20
  */
20
21
  function shouldRecordTelemetry(_a) {
21
22
  var settings = _a.settings;
22
- return settings.mode !== constants_1.LOCALHOST_MODE && (settings.core.key === undefined || Math.random() <= ACCEPTANCE_RANGE);
23
+ return settings.mode !== constants_1.LOCALHOST_MODE && ((0, key_1.checkIfServerSide)(settings) || Math.random() <= ACCEPTANCE_RANGE);
23
24
  }
24
25
  exports.shouldRecordTelemetry = shouldRecordTelemetry;
25
26
  var TelemetryCacheInMemory = /** @class */ (function () {
@@ -23,6 +23,7 @@ var UniqueKeysCacheInMemoryCS_1 = require("../inMemory/UniqueKeysCacheInMemoryCS
23
23
  var utils_1 = require("../utils");
24
24
  var constants_2 = require("../pluggable/constants");
25
25
  var RBSegmentsCachePluggable_1 = require("./RBSegmentsCachePluggable");
26
+ var key_1 = require("../../utils/key");
26
27
  var NO_VALID_WRAPPER = 'Expecting pluggable storage `wrapper` in options, but no valid wrapper instance was provided.';
27
28
  var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow the expected interface. Check our docs.';
28
29
  /**
@@ -70,7 +71,7 @@ function PluggableStorage(options) {
70
71
  new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() :
71
72
  new ImpressionCountsCachePluggable_1.ImpressionCountsCachePluggable(log, keys.buildImpressionsCountKey(), wrapper);
72
73
  var uniqueKeysCache = isPartialConsumer ?
73
- settings.core.key === undefined ? new UniqueKeysCacheInMemory_1.UniqueKeysCacheInMemory() : new UniqueKeysCacheInMemoryCS_1.UniqueKeysCacheInMemoryCS() :
74
+ (0, key_1.checkIfServerSide)(settings) ? new UniqueKeysCacheInMemory_1.UniqueKeysCacheInMemory() : new UniqueKeysCacheInMemoryCS_1.UniqueKeysCacheInMemoryCS() :
74
75
  new UniqueKeysCachePluggable_1.UniqueKeysCachePluggable(log, keys.buildUniqueKeysKey(), wrapper);
75
76
  // Connects to wrapper and emits SDK_READY event on main client
76
77
  var connectPromise = wrapper.connect().then(function () {
@@ -4,6 +4,7 @@ exports.splitChangesFetcherFactory = void 0;
4
4
  var constants_1 = require("../../../utils/constants");
5
5
  var settingsValidation_1 = require("../../../utils/settingsValidation");
6
6
  var constants_2 = require("../../../logger/constants");
7
+ var key_1 = require("../../../utils/key");
7
8
  var PROXY_CHECK_INTERVAL_MILLIS_CS = 60 * 60 * 1000; // 1 hour in Client Side
8
9
  var PROXY_CHECK_INTERVAL_MILLIS_SS = 24 * PROXY_CHECK_INTERVAL_MILLIS_CS; // 24 hours in Server Side
9
10
  function sdkEndpointOverridden(settings) {
@@ -16,7 +17,7 @@ function sdkEndpointOverridden(settings) {
16
17
  // @TODO breaking: drop support for Split Proxy below v5.10.0 and simplify the implementation
17
18
  function splitChangesFetcherFactory(fetchSplitChanges, settings, storage) {
18
19
  var log = settings.log;
19
- var PROXY_CHECK_INTERVAL_MILLIS = settings.core.key !== undefined ? PROXY_CHECK_INTERVAL_MILLIS_CS : PROXY_CHECK_INTERVAL_MILLIS_SS;
20
+ var PROXY_CHECK_INTERVAL_MILLIS = (0, key_1.checkIfServerSide)(settings) ? PROXY_CHECK_INTERVAL_MILLIS_SS : PROXY_CHECK_INTERVAL_MILLIS_CS;
20
21
  var lastProxyCheckTimestamp;
21
22
  return function splitChangesFetcher(since, noCache, till, rbSince,
22
23
  // Optional decorator for `fetchSplitChanges` promise, such as timeout or time tracker
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SSEClient = void 0;
4
4
  var decorateHeaders_1 = require("../../../services/decorateHeaders");
5
+ var key_1 = require("../../../utils/key");
5
6
  var lang_1 = require("../../../utils/lang");
6
7
  var objectAssign_1 = require("../../../utils/lang/objectAssign");
7
8
  var ABLY_API_VERSION = '1.1';
@@ -60,7 +61,7 @@ var SSEClient = /** @class */ (function () {
60
61
  return encodeURIComponent(params + channel);
61
62
  }).join(',');
62
63
  var url = this.settings.urls.streaming + "/sse?channels=" + channelsQueryParam + "&accessToken=" + authToken.token + "&v=" + ABLY_API_VERSION + "&heartbeats=true"; // same results using `&heartbeats=false`
63
- var isServerSide = !this.settings.core.key;
64
+ var isServerSide = (0, key_1.checkIfServerSide)(this.settings);
64
65
  this.connection = new this.eventSource(
65
66
  // For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
66
67
  isServerSide ? url : url + ("&SplitSDKVersion=" + this.headers.SplitSDKVersion + "&SplitSDKClientKey=" + this.headers.SplitSDKClientKey),
@@ -19,7 +19,7 @@ function SSEHandlerFactory(log, pushEmitter, telemetryTracker) {
19
19
  // Ably error
20
20
  var code = error.parsedData.code;
21
21
  telemetryTracker.streamingEvent(constants_3.ABLY_ERROR, code);
22
- // 401 errors due to invalid or expired token (e.g., if refresh token coudn't be executed)
22
+ // 401 errors due to invalid or expired token (e.g., if refresh token couldn't be executed)
23
23
  if (40140 <= code && code <= 40149)
24
24
  return true;
25
25
  // Others 4XX errors (e.g., bad request from the SDK)
@@ -26,7 +26,7 @@ function pushManagerFactory(params, pollingManager) {
26
26
  var settings = params.settings, storage = params.storage, splitApi = params.splitApi, readiness = params.readiness, platform = params.platform, telemetryTracker = params.telemetryTracker;
27
27
  // `userKey` is the matching key of main client in client-side SDK.
28
28
  // It can be used to check if running on client-side or server-side SDK.
29
- var userKey = settings.core.key ? (0, key_1.getMatching)(settings.core.key) : undefined;
29
+ var userKey = (0, key_1.checkIfServerSide)(settings) ? undefined : (0, key_1.getMatching)(settings.core.key);
30
30
  var log = settings.log;
31
31
  var sseClient;
32
32
  try {
@@ -9,6 +9,7 @@ var settingsValidation_1 = require("../../utils/settingsValidation");
9
9
  var apiKey_1 = require("../../utils/inputValidation/apiKey");
10
10
  var timer_1 = require("../../utils/timeTracker/timer");
11
11
  var objectAssign_1 = require("../../utils/lang/objectAssign");
12
+ var key_1 = require("../../utils/key");
12
13
  var OPERATION_MODE_MAP = (_a = {},
13
14
  _a[constants_1.STANDALONE_MODE] = constants_1.STANDALONE_ENUM,
14
15
  _a[constants_1.CONSUMER_MODE] = constants_1.CONSUMER_ENUM,
@@ -62,14 +63,14 @@ function telemetryCacheConfigAdapter(telemetry, settings) {
62
63
  clear: function () { },
63
64
  pop: function () {
64
65
  var urls = settings.urls, scheduler = settings.scheduler;
65
- var isClientSide = settings.core.key !== undefined;
66
+ var isServerSide = (0, key_1.checkIfServerSide)(settings);
66
67
  var _a = getTelemetryFlagSetsStats(settings.sync.__splitFiltersValidation), flagSetsTotal = _a.flagSetsTotal, flagSetsIgnored = _a.flagSetsIgnored;
67
68
  return (0, objectAssign_1.objectAssign)(getTelemetryConfigStats(settings.mode, settings.storage.type), {
68
69
  sE: settings.streamingEnabled,
69
70
  rR: {
70
71
  sp: scheduler.featuresRefreshRate / 1000,
71
- se: isClientSide ? undefined : scheduler.segmentsRefreshRate / 1000,
72
- ms: isClientSide ? scheduler.segmentsRefreshRate / 1000 : undefined,
72
+ se: isServerSide ? scheduler.segmentsRefreshRate / 1000 : undefined,
73
+ ms: isServerSide ? undefined : scheduler.segmentsRefreshRate / 1000,
73
74
  im: scheduler.impressionsRefreshRate / 1000,
74
75
  ev: scheduler.eventsPushRate / 1000,
75
76
  te: scheduler.telemetryRefreshRate / 1000,
@@ -107,14 +108,14 @@ function telemetrySubmitterFactory(params) {
107
108
  if (!telemetry || !now)
108
109
  return; // No submitter created if telemetry cache is not defined
109
110
  var settings = params.settings, _a = params.settings, log = _a.log, telemetryRefreshRate = _a.scheduler.telemetryRefreshRate, splitApi = params.splitApi, readiness = params.readiness, sdkReadinessManager = params.sdkReadinessManager;
110
- var startTime = (0, timer_1.timer)(now);
111
+ var stopTimer = (0, timer_1.timer)(now);
111
112
  var submitter = (0, submitter_1.firstPushWindowDecorator)((0, submitter_1.submitterFactory)(log, splitApi.postMetricsUsage, telemetry, telemetryRefreshRate, undefined, 0, true), telemetryRefreshRate);
112
113
  readiness.gate.once(constants_2.SDK_READY_FROM_CACHE, function () {
113
- telemetry.recordTimeUntilReadyFromCache(startTime());
114
+ telemetry.recordTimeUntilReadyFromCache(stopTimer());
114
115
  });
115
116
  sdkReadinessManager.incInternalReadyCbCount();
116
117
  readiness.gate.once(constants_2.SDK_READY, function () {
117
- telemetry.recordTimeUntilReady(startTime());
118
+ telemetry.recordTimeUntilReady(stopTimer());
118
119
  // Post config data when the SDK is ready and if the telemetry submitter was started
119
120
  if (submitter.isRunning()) {
120
121
  var postMetricsConfigTask = (0, submitter_1.submitterFactory)(log, splitApi.postMetricsConfig, telemetryCacheConfigAdapter(telemetry, settings), 0, undefined, 0, true);
@@ -6,10 +6,10 @@ var timer_1 = require("../utils/timeTracker/timer");
6
6
  var constants_1 = require("../utils/constants");
7
7
  function telemetryTrackerFactory(telemetryCache, now) {
8
8
  if (telemetryCache && now) {
9
- var startTime_1 = (0, timer_1.timer)(now);
9
+ var sessionTimer_1 = (0, timer_1.timer)(now);
10
10
  return {
11
11
  trackEval: function (method) {
12
- var evalTime = (0, timer_1.timer)(now);
12
+ var evalTimer = (0, timer_1.timer)(now);
13
13
  return function (label) {
14
14
  switch (label) {
15
15
  case labels_1.EXCEPTION:
@@ -19,13 +19,13 @@ function telemetryTrackerFactory(telemetryCache, now) {
19
19
  if (telemetryCache.recordNonReadyUsage)
20
20
  telemetryCache.recordNonReadyUsage();
21
21
  }
22
- telemetryCache.recordLatency(method, evalTime());
22
+ telemetryCache.recordLatency(method, evalTimer());
23
23
  };
24
24
  },
25
25
  trackHttp: function (operation) {
26
- var httpTime = (0, timer_1.timer)(now);
26
+ var httpTimer = (0, timer_1.timer)(now);
27
27
  return function (error) {
28
- telemetryCache.recordHttpLatency(operation, httpTime());
28
+ telemetryCache.recordHttpLatency(operation, httpTimer());
29
29
  if (error && error.statusCode)
30
30
  telemetryCache.recordHttpError(operation, error.statusCode);
31
31
  else
@@ -34,7 +34,7 @@ function telemetryTrackerFactory(telemetryCache, now) {
34
34
  },
35
35
  sessionLength: function () {
36
36
  if (telemetryCache.recordSessionLength)
37
- telemetryCache.recordSessionLength(startTime_1());
37
+ telemetryCache.recordSessionLength(sessionTimer_1());
38
38
  },
39
39
  streamingEvent: function (e, d) {
40
40
  if (e === constants_1.AUTH_REJECTION) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateEvaluationOptions = exports.validateTrafficTypeExistence = exports.validateSplitExistence = exports.validateIfOperational = exports.validateIfNotDestroyed = exports.validateTrafficType = exports.validateSplits = exports.validateSplit = exports.validateKey = exports.validateEventProperties = exports.validateEventValue = exports.validateEvent = exports.validateAttributes = exports.releaseApiKey = exports.validateAndTrackApiKey = exports.validateApiKey = void 0;
3
+ exports.validateEvaluationOptions = exports.validateTrafficTypeExistence = exports.validateSplitExistence = exports.validateIfOperational = exports.validateIfReadyFromCache = exports.validateIfNotDestroyed = exports.validateTrafficType = exports.validateSplits = exports.validateSplit = exports.validateKey = exports.validateEventProperties = exports.validateEventValue = exports.validateEvent = exports.validateAttributes = exports.releaseApiKey = exports.validateAndTrackApiKey = exports.validateApiKey = void 0;
4
4
  var apiKey_1 = require("./apiKey");
5
5
  Object.defineProperty(exports, "validateApiKey", { enumerable: true, get: function () { return apiKey_1.validateApiKey; } });
6
6
  Object.defineProperty(exports, "validateAndTrackApiKey", { enumerable: true, get: function () { return apiKey_1.validateAndTrackApiKey; } });
@@ -23,6 +23,7 @@ var trafficType_1 = require("./trafficType");
23
23
  Object.defineProperty(exports, "validateTrafficType", { enumerable: true, get: function () { return trafficType_1.validateTrafficType; } });
24
24
  var isOperational_1 = require("./isOperational");
25
25
  Object.defineProperty(exports, "validateIfNotDestroyed", { enumerable: true, get: function () { return isOperational_1.validateIfNotDestroyed; } });
26
+ Object.defineProperty(exports, "validateIfReadyFromCache", { enumerable: true, get: function () { return isOperational_1.validateIfReadyFromCache; } });
26
27
  Object.defineProperty(exports, "validateIfOperational", { enumerable: true, get: function () { return isOperational_1.validateIfOperational; } });
27
28
  var splitExistence_1 = require("./splitExistence");
28
29
  Object.defineProperty(exports, "validateSplitExistence", { enumerable: true, get: function () { return splitExistence_1.validateSplitExistence; } });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateIfOperational = exports.validateIfNotDestroyed = void 0;
3
+ exports.validateIfOperational = exports.validateIfReadyFromCache = exports.validateIfNotDestroyed = void 0;
4
4
  var constants_1 = require("../../logger/constants");
5
5
  function validateIfNotDestroyed(log, readinessManager, method) {
6
6
  if (!readinessManager.isDestroyed())
@@ -9,10 +9,15 @@ function validateIfNotDestroyed(log, readinessManager, method) {
9
9
  return false;
10
10
  }
11
11
  exports.validateIfNotDestroyed = validateIfNotDestroyed;
12
- function validateIfOperational(log, readinessManager, method, featureFlagNameOrNames) {
13
- if (readinessManager.isReady() || readinessManager.isReadyFromCache())
12
+ function validateIfReadyFromCache(log, readinessManager, method, featureFlagNameOrNames) {
13
+ if (readinessManager.isReadyFromCache())
14
14
  return true;
15
- log.warn(constants_1.CLIENT_NOT_READY, [method, featureFlagNameOrNames ? " for feature flag " + featureFlagNameOrNames.toString() : '']);
15
+ log.warn(constants_1.CLIENT_NOT_READY_FROM_CACHE, [method, featureFlagNameOrNames ? " for feature flag " + featureFlagNameOrNames.toString() : '']);
16
16
  return false;
17
17
  }
18
+ exports.validateIfReadyFromCache = validateIfReadyFromCache;
19
+ // Operational means that the SDK is ready to evaluate (not destroyed and ready from cache)
20
+ function validateIfOperational(log, readinessManager, method, featureFlagNameOrNames) {
21
+ return validateIfNotDestroyed(log, readinessManager, method) && validateIfReadyFromCache(log, readinessManager, method, featureFlagNameOrNames);
22
+ }
18
23
  exports.validateIfOperational = validateIfOperational;
@@ -5,11 +5,11 @@ var labels_1 = require("../labels");
5
5
  var constants_1 = require("../../logger/constants");
6
6
  /**
7
7
  * This is defined here and in this format mostly because of the logger and the fact that it's considered a validation at product level.
8
- * But it's not going to run on the input validation layer. In any case, the most compeling reason to use it as we do is to avoid going to Redis and get a split twice.
8
+ * But it's not going to run on the input validation layer. In any case, the most compelling reason to use it as we do is to avoid going to Redis and get a split twice.
9
9
  */
10
10
  function validateSplitExistence(log, readinessManager, splitName, labelOrSplitObj, method) {
11
- if (readinessManager.isReady()) { // Only if it's ready we validate this, otherwise it may just be that the SDK is not ready yet.
12
- if (labelOrSplitObj === labels_1.SPLIT_NOT_FOUND || labelOrSplitObj == null || labelOrSplitObj === labels_1.FALLBACK_SPLIT_NOT_FOUND) {
11
+ if (readinessManager.isReady()) { // Only if it's ready (synced with BE) we validate this, otherwise it may just be that the SDK is still syncing
12
+ if (labelOrSplitObj === labels_1.SPLIT_NOT_FOUND || labelOrSplitObj === labels_1.FALLBACK_SPLIT_NOT_FOUND || labelOrSplitObj == null) {
13
13
  log.warn(constants_1.WARN_NOT_EXISTENT_SPLIT, [method, splitName]);
14
14
  return false;
15
15
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keyParser = exports.getBucketing = exports.getMatching = void 0;
3
+ exports.checkIfServerSide = exports.keyParser = exports.getBucketing = exports.getMatching = void 0;
4
4
  var lang_1 = require("../lang");
5
5
  // function isSplitKeyObject(key: any): key is SplitIO.SplitKeyObject {
6
6
  // return key !== undefined && key !== null && typeof key.matchingKey === 'string';
@@ -34,3 +34,7 @@ function keyParser(key) {
34
34
  }
35
35
  }
36
36
  exports.keyParser = keyParser;
37
+ function checkIfServerSide(settings) {
38
+ return !settings.core.key;
39
+ }
40
+ exports.checkIfServerSide = checkIfServerSide;
@@ -1,5 +1,9 @@
1
1
  import { isObject, isString } from '../../../utils/lang';
2
- import { FallbackDiscardReason } from '../constants';
2
+ var FallbackDiscardReason;
3
+ (function (FallbackDiscardReason) {
4
+ FallbackDiscardReason["FlagName"] = "Invalid flag name (max 100 chars, no spaces)";
5
+ FallbackDiscardReason["Treatment"] = "Invalid treatment (max 100 chars and must match pattern)";
6
+ })(FallbackDiscardReason || (FallbackDiscardReason = {}));
3
7
  var FallbacksSanitizer = /** @class */ (function () {
4
8
  function FallbacksSanitizer() {
5
9
  }
@@ -58,7 +58,7 @@ export var SUBMITTERS_PUSH_PAGE_HIDDEN = 125;
58
58
  export var ENGINE_VALUE_INVALID = 200;
59
59
  export var ENGINE_VALUE_NO_ATTRIBUTES = 201;
60
60
  export var CLIENT_NO_LISTENER = 202;
61
- export var CLIENT_NOT_READY = 203;
61
+ export var CLIENT_NOT_READY_FROM_CACHE = 203;
62
62
  export var SYNC_MYSEGMENTS_FETCH_RETRY = 204;
63
63
  export var SYNC_SPLITS_FETCH_FAILS = 205;
64
64
  export var STREAMING_PARSING_ERROR_FAILS = 206;
@@ -58,9 +58,6 @@ var Logger = /** @class */ (function () {
58
58
  if (logger) {
59
59
  if (isLogger(logger)) {
60
60
  this.logger = logger;
61
- // If custom logger is set, all logs are either enabled or disabled
62
- if (this.logLevel !== LogLevelIndexes.NONE)
63
- this.setLogLevel(LogLevels.DEBUG);
64
61
  return;
65
62
  }
66
63
  else {