@splitsoftware/splitio-commons 2.1.1-rc.0 → 2.1.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGES.txt +3 -0
  2. package/README.md +0 -1
  3. package/cjs/evaluator/combiners/and.js +6 -2
  4. package/cjs/evaluator/combiners/ifelseif.js +6 -6
  5. package/cjs/evaluator/condition/index.js +5 -6
  6. package/cjs/evaluator/index.js +7 -7
  7. package/cjs/evaluator/matchers/index.js +1 -3
  8. package/cjs/evaluator/matchers/matcherTypes.js +0 -1
  9. package/cjs/evaluator/matchersTransform/index.js +0 -4
  10. package/cjs/evaluator/parser/index.js +2 -2
  11. package/cjs/evaluator/value/sanitize.js +0 -1
  12. package/cjs/logger/constants.js +3 -4
  13. package/cjs/logger/messages/debug.js +2 -3
  14. package/cjs/logger/messages/error.js +1 -1
  15. package/cjs/logger/messages/warn.js +2 -2
  16. package/cjs/sdkClient/client.js +29 -19
  17. package/cjs/sdkClient/clientAttributesDecoration.js +19 -25
  18. package/cjs/sdkClient/clientInputValidation.js +28 -26
  19. package/cjs/services/splitApi.js +2 -2
  20. package/cjs/storages/AbstractSplitsCacheSync.js +2 -5
  21. package/cjs/storages/KeyBuilder.js +0 -9
  22. package/cjs/storages/KeyBuilderCS.js +1 -4
  23. package/cjs/storages/KeyBuilderSS.js +0 -3
  24. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
  25. package/cjs/storages/inLocalStorage/index.js +0 -4
  26. package/cjs/storages/inMemory/InMemoryStorage.js +0 -3
  27. package/cjs/storages/inMemory/InMemoryStorageCS.js +0 -4
  28. package/cjs/storages/inRedis/index.js +0 -2
  29. package/cjs/storages/pluggable/index.js +0 -2
  30. package/cjs/storages/utils.js +1 -0
  31. package/cjs/sync/polling/fetchers/splitChangesFetcher.js +2 -2
  32. package/cjs/sync/polling/pollingManagerCS.js +7 -7
  33. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
  34. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
  35. package/cjs/sync/polling/updaters/splitChangesUpdater.js +35 -51
  36. package/cjs/sync/streaming/SSEHandler/index.js +0 -1
  37. package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +77 -106
  38. package/cjs/sync/streaming/constants.js +1 -2
  39. package/cjs/sync/streaming/pushManager.js +16 -3
  40. package/cjs/sync/submitters/impressionsSubmitter.js +3 -2
  41. package/cjs/sync/syncManagerOnline.js +2 -2
  42. package/cjs/trackers/strategy/strategyOptimized.js +3 -0
  43. package/cjs/utils/constants/index.js +2 -3
  44. package/cjs/utils/inputValidation/eventProperties.js +12 -1
  45. package/cjs/utils/inputValidation/index.js +3 -1
  46. package/esm/evaluator/combiners/and.js +6 -2
  47. package/esm/evaluator/combiners/ifelseif.js +7 -7
  48. package/esm/evaluator/condition/index.js +5 -6
  49. package/esm/evaluator/index.js +7 -7
  50. package/esm/evaluator/matchers/index.js +1 -3
  51. package/esm/evaluator/matchers/matcherTypes.js +0 -1
  52. package/esm/evaluator/matchersTransform/index.js +0 -4
  53. package/esm/evaluator/parser/index.js +2 -2
  54. package/esm/evaluator/value/sanitize.js +0 -1
  55. package/esm/logger/constants.js +0 -1
  56. package/esm/logger/messages/debug.js +2 -3
  57. package/esm/logger/messages/error.js +1 -1
  58. package/esm/logger/messages/warn.js +2 -2
  59. package/esm/sdkClient/client.js +29 -19
  60. package/esm/sdkClient/clientAttributesDecoration.js +19 -25
  61. package/esm/sdkClient/clientInputValidation.js +29 -27
  62. package/esm/services/splitApi.js +2 -2
  63. package/esm/storages/AbstractSplitsCacheSync.js +2 -5
  64. package/esm/storages/KeyBuilder.js +0 -9
  65. package/esm/storages/KeyBuilderCS.js +1 -4
  66. package/esm/storages/KeyBuilderSS.js +0 -3
  67. package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
  68. package/esm/storages/inLocalStorage/index.js +0 -4
  69. package/esm/storages/inMemory/InMemoryStorage.js +0 -3
  70. package/esm/storages/inMemory/InMemoryStorageCS.js +0 -4
  71. package/esm/storages/inRedis/index.js +0 -2
  72. package/esm/storages/pluggable/index.js +0 -2
  73. package/esm/storages/utils.js +1 -0
  74. package/esm/sync/polling/fetchers/splitChangesFetcher.js +2 -2
  75. package/esm/sync/polling/pollingManagerCS.js +7 -7
  76. package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
  77. package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
  78. package/esm/sync/polling/updaters/splitChangesUpdater.js +35 -51
  79. package/esm/sync/streaming/SSEHandler/index.js +1 -2
  80. package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +73 -102
  81. package/esm/sync/streaming/constants.js +0 -1
  82. package/esm/sync/streaming/pushManager.js +19 -6
  83. package/esm/sync/submitters/impressionsSubmitter.js +3 -2
  84. package/esm/sync/syncManagerOnline.js +2 -2
  85. package/esm/trackers/strategy/strategyOptimized.js +3 -0
  86. package/esm/utils/constants/index.js +1 -2
  87. package/esm/utils/inputValidation/eventProperties.js +10 -0
  88. package/esm/utils/inputValidation/index.js +1 -0
  89. package/package.json +1 -1
  90. package/src/dtos/types.ts +8 -32
  91. package/src/evaluator/Engine.ts +1 -1
  92. package/src/evaluator/combiners/and.ts +4 -5
  93. package/src/evaluator/combiners/ifelseif.ts +9 -7
  94. package/src/evaluator/condition/engineUtils.ts +1 -1
  95. package/src/evaluator/condition/index.ts +12 -12
  96. package/src/evaluator/index.ts +7 -7
  97. package/src/evaluator/matchers/index.ts +1 -3
  98. package/src/evaluator/matchers/matcherTypes.ts +0 -1
  99. package/src/evaluator/matchersTransform/index.ts +0 -3
  100. package/src/evaluator/parser/index.ts +3 -3
  101. package/src/evaluator/types.ts +2 -2
  102. package/src/evaluator/value/index.ts +2 -2
  103. package/src/evaluator/value/sanitize.ts +4 -5
  104. package/src/logger/constants.ts +0 -1
  105. package/src/logger/messages/debug.ts +2 -3
  106. package/src/logger/messages/error.ts +1 -1
  107. package/src/logger/messages/warn.ts +2 -2
  108. package/src/sdkClient/client.ts +31 -21
  109. package/src/sdkClient/clientAttributesDecoration.ts +20 -27
  110. package/src/sdkClient/clientInputValidation.ts +30 -27
  111. package/src/sdkManager/index.ts +1 -1
  112. package/src/services/splitApi.ts +2 -2
  113. package/src/services/types.ts +1 -1
  114. package/src/storages/AbstractSplitsCacheSync.ts +3 -6
  115. package/src/storages/KeyBuilder.ts +0 -12
  116. package/src/storages/KeyBuilderCS.ts +1 -5
  117. package/src/storages/KeyBuilderSS.ts +0 -4
  118. package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +14 -10
  119. package/src/storages/inLocalStorage/index.ts +0 -4
  120. package/src/storages/inMemory/InMemoryStorage.ts +0 -3
  121. package/src/storages/inMemory/InMemoryStorageCS.ts +0 -4
  122. package/src/storages/inRedis/index.ts +0 -2
  123. package/src/storages/pluggable/index.ts +0 -2
  124. package/src/storages/types.ts +1 -33
  125. package/src/storages/utils.ts +1 -0
  126. package/src/sync/polling/fetchers/splitChangesFetcher.ts +1 -2
  127. package/src/sync/polling/fetchers/types.ts +0 -1
  128. package/src/sync/polling/pollingManagerCS.ts +7 -7
  129. package/src/sync/polling/types.ts +2 -2
  130. package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
  131. package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
  132. package/src/sync/polling/updaters/splitChangesUpdater.ts +44 -61
  133. package/src/sync/streaming/SSEHandler/index.ts +1 -2
  134. package/src/sync/streaming/SSEHandler/types.ts +2 -2
  135. package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +68 -98
  136. package/src/sync/streaming/constants.ts +0 -1
  137. package/src/sync/streaming/parseUtils.ts +2 -2
  138. package/src/sync/streaming/pushManager.ts +18 -6
  139. package/src/sync/streaming/types.ts +2 -3
  140. package/src/sync/submitters/impressionsSubmitter.ts +3 -2
  141. package/src/sync/submitters/types.ts +23 -33
  142. package/src/sync/syncManagerOnline.ts +2 -2
  143. package/src/trackers/strategy/strategyOptimized.ts +3 -0
  144. package/src/utils/constants/index.ts +1 -2
  145. package/src/utils/inputValidation/eventProperties.ts +10 -0
  146. package/src/utils/inputValidation/index.ts +1 -0
  147. package/src/utils/lang/index.ts +1 -1
  148. package/types/splitio.d.ts +100 -35
  149. package/cjs/evaluator/matchers/rbsegment.js +0 -43
  150. package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -117
  151. package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +0 -61
  152. package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +0 -64
  153. package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +0 -64
  154. package/esm/evaluator/matchers/rbsegment.js +0 -39
  155. package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -114
  156. package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +0 -58
  157. package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +0 -61
  158. package/esm/storages/pluggable/RBSegmentsCachePluggable.js +0 -61
  159. package/src/evaluator/matchers/rbsegment.ts +0 -61
  160. package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +0 -136
  161. package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +0 -68
  162. package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +0 -79
  163. package/src/storages/pluggable/RBSegmentsCachePluggable.ts +0 -76
package/CHANGES.txt CHANGED
@@ -1,3 +1,6 @@
1
+ 2.2.0 (March 28, 2025)
2
+ - Added new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impression object sent to Split's backend. Read more in our docs.
3
+
1
4
  2.1.0 (January 17, 2025)
2
5
  - Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on `SplitView` type objects. Read more in our docs.
3
6
 
package/README.md CHANGED
@@ -27,7 +27,6 @@ Split has built and maintains SDKs for:
27
27
  * .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
28
28
  * Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
29
29
  * Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
30
- * Elixir thin-client [Github](https://github.com/splitio/elixir-thin-client) [Docs](https://help.split.io/hc/en-us/articles/26988707417869-Elixir-Thin-Client-SDK)
31
30
  * Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
32
31
  * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
33
32
  * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
@@ -11,8 +11,12 @@ function andCombinerContext(log, matchers) {
11
11
  log.debug(constants_1.ENGINE_COMBINER_AND, [hasMatchedAll]);
12
12
  return hasMatchedAll;
13
13
  }
14
- return function andCombiner(key, attributes, splitEvaluator) {
15
- var matcherResults = matchers.map(function (matcher) { return matcher(key, attributes, splitEvaluator); });
14
+ return function andCombiner() {
15
+ var params = [];
16
+ for (var _i = 0; _i < arguments.length; _i++) {
17
+ params[_i] = arguments[_i];
18
+ }
19
+ var matcherResults = matchers.map(function (matcher) { return matcher.apply(void 0, params); });
16
20
  // If any matching result is a thenable we should use Promise.all
17
21
  if ((0, lang_1.findIndex)(matcherResults, thenable_1.thenable) !== -1) {
18
22
  return Promise.all(matcherResults).then(andResults);
@@ -14,12 +14,12 @@ function ifElseIfCombinerContext(log, predicates) {
14
14
  label: labels_1.UNSUPPORTED_MATCHER_TYPE
15
15
  };
16
16
  }
17
- function computeEvaluation(predicateResults) {
18
- for (var i = 0, len = predicateResults.length; i < len; i++) {
17
+ function computeTreatment(predicateResults) {
18
+ var len = predicateResults.length;
19
+ for (var i = 0; i < len; i++) {
19
20
  var evaluation = predicateResults[i];
20
21
  if (evaluation !== undefined) {
21
- if (!(0, lang_1.isBoolean)(evaluation))
22
- log.debug(constants_2.ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
22
+ log.debug(constants_2.ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
23
23
  return evaluation;
24
24
  }
25
25
  }
@@ -33,9 +33,9 @@ function ifElseIfCombinerContext(log, predicates) {
33
33
  var predicateResults = predicates.map(function (evaluator) { return evaluator(key, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator); });
34
34
  // if we find a thenable
35
35
  if ((0, lang_1.findIndex)(predicateResults, thenable_1.thenable) !== -1) {
36
- return Promise.all(predicateResults).then(function (results) { return computeEvaluation(results); });
36
+ return Promise.all(predicateResults).then(function (results) { return computeTreatment(results); });
37
37
  }
38
- return computeEvaluation(predicateResults);
38
+ return computeTreatment(predicateResults);
39
39
  }
40
40
  // if there is none predicates, then there was an error in parsing phase
41
41
  if (!Array.isArray(predicates) || predicates.length === 0) {
@@ -7,12 +7,11 @@ var labels_1 = require("../../utils/labels");
7
7
  // Build Evaluation object if and only if matchingResult is true
8
8
  function match(log, matchingResult, bucketingKey, seed, treatments, label) {
9
9
  if (matchingResult) {
10
- return treatments ? // Feature flag
11
- {
12
- treatment: (0, engineUtils_1.getTreatment)(log, bucketingKey, seed, treatments),
13
- label: label
14
- } : // Rule-based segment
15
- true;
10
+ var treatment = (0, engineUtils_1.getTreatment)(log, bucketingKey, seed, treatments);
11
+ return {
12
+ treatment: treatment,
13
+ label: label
14
+ };
16
15
  }
17
16
  // else we should notify the engine to continue evaluating
18
17
  return undefined;
@@ -29,12 +29,12 @@ function evaluateFeature(log, key, splitName, attributes, storage) {
29
29
  return treatmentException;
30
30
  }
31
31
  if ((0, thenable_1.thenable)(parsedSplit)) {
32
- return parsedSplit.then(function (split) { return getEvaluation(log, key, split, attributes, storage); }).catch(
32
+ return parsedSplit.then(function (split) { return getEvaluation(log, split, key, attributes, storage); }).catch(
33
33
  // Exception on async `getSplit` storage. For example, when the storage is redis or
34
34
  // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
35
35
  function () { return treatmentException; });
36
36
  }
37
- return getEvaluation(log, key, parsedSplit, attributes, storage);
37
+ return getEvaluation(log, parsedSplit, key, attributes, storage);
38
38
  }
39
39
  exports.evaluateFeature = evaluateFeature;
40
40
  function evaluateFeatures(log, key, splitNames, attributes, storage) {
@@ -47,13 +47,13 @@ function evaluateFeatures(log, key, splitNames, attributes, storage) {
47
47
  return treatmentsException(splitNames);
48
48
  }
49
49
  return (0, thenable_1.thenable)(parsedSplits) ?
50
- parsedSplits.then(function (splits) { return getEvaluations(log, key, splitNames, splits, attributes, storage); })
50
+ parsedSplits.then(function (splits) { return getEvaluations(log, splitNames, splits, key, attributes, storage); })
51
51
  .catch(function () {
52
52
  // Exception on async `getSplits` storage. For example, when the storage is redis or
53
53
  // pluggable and there is a connection issue and we can't retrieve the split to be evaluated
54
54
  return treatmentsException(splitNames);
55
55
  }) :
56
- getEvaluations(log, key, splitNames, parsedSplits, attributes, storage);
56
+ getEvaluations(log, splitNames, parsedSplits, key, attributes, storage);
57
57
  }
58
58
  exports.evaluateFeatures = evaluateFeatures;
59
59
  function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
@@ -90,7 +90,7 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
90
90
  evaluate(storedFlagNames);
91
91
  }
92
92
  exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
93
- function getEvaluation(log, key, splitJSON, attributes, storage) {
93
+ function getEvaluation(log, splitJSON, key, attributes, storage) {
94
94
  var evaluation = {
95
95
  treatment: constants_1.CONTROL,
96
96
  label: labels_1.SPLIT_NOT_FOUND,
@@ -116,11 +116,11 @@ function getEvaluation(log, key, splitJSON, attributes, storage) {
116
116
  }
117
117
  return evaluation;
118
118
  }
119
- function getEvaluations(log, key, splitNames, splits, attributes, storage) {
119
+ function getEvaluations(log, splitNames, splits, key, attributes, storage) {
120
120
  var result = {};
121
121
  var thenables = [];
122
122
  splitNames.forEach(function (splitName) {
123
- var evaluation = getEvaluation(log, key, splits[splitName], attributes, storage);
123
+ var evaluation = getEvaluation(log, splits[splitName], key, attributes, storage);
124
124
  if ((0, thenable_1.thenable)(evaluation)) {
125
125
  thenables.push(evaluation.then(function (res) {
126
126
  result[splitName] = res;
@@ -24,7 +24,6 @@ var semver_gte_1 = require("./semver_gte");
24
24
  var semver_lte_1 = require("./semver_lte");
25
25
  var semver_between_1 = require("./semver_between");
26
26
  var semver_inlist_1 = require("./semver_inlist");
27
- var rbsegment_1 = require("./rbsegment");
28
27
  var matchers = [
29
28
  undefined,
30
29
  all_1.allMatcherContext,
@@ -49,8 +48,7 @@ var matchers = [
49
48
  semver_lte_1.lessThanEqualToSemverMatcherContext,
50
49
  semver_between_1.betweenSemverMatcherContext,
51
50
  semver_inlist_1.inListSemverMatcherContext,
52
- large_segment_1.largeSegmentMatcherContext,
53
- rbsegment_1.ruleBasedSegmentMatcherContext // IN_RULE_BASED_SEGMENT: 24
51
+ large_segment_1.largeSegmentMatcherContext, // IN_LARGE_SEGMENT: 23
54
52
  ];
55
53
  /**
56
54
  * Matcher factory.
@@ -26,7 +26,6 @@ exports.matcherTypes = {
26
26
  BETWEEN_SEMVER: 21,
27
27
  IN_LIST_SEMVER: 22,
28
28
  IN_LARGE_SEGMENT: 23,
29
- IN_RULE_BASED_SEGMENT: 24,
30
29
  };
31
30
  exports.matcherDataTypes = {
32
31
  BOOLEAN: 'BOOLEAN',
@@ -81,10 +81,6 @@ function matchersTransform(matchers) {
81
81
  type === matcherTypes_1.matcherTypes.LESS_THAN_OR_EQUAL_TO_SEMVER) {
82
82
  value = stringMatcherData;
83
83
  }
84
- else if (type === matcherTypes_1.matcherTypes.IN_RULE_BASED_SEGMENT) {
85
- value = (0, segment_1.segmentTransform)(userDefinedSegmentMatcherData);
86
- dataType = matcherTypes_1.matcherDataTypes.NOT_SPECIFIED;
87
- }
88
84
  return {
89
85
  attribute: attribute,
90
86
  negate: negate,
@@ -53,9 +53,9 @@ function parser(log, conditions, storage) {
53
53
  // and break the loop
54
54
  break;
55
55
  }
56
- predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), partitions && treatments_1.Treatments.parse(partitions), label, conditionType));
56
+ predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), treatments_1.Treatments.parse(partitions), label, conditionType));
57
57
  }
58
- // Instantiate evaluator given the set of conditions using if else if logic
58
+ // Instanciate evaluator given the set of conditions using if else if logic
59
59
  return (0, ifelseif_1.ifElseIfCombinerContext)(log, predicates);
60
60
  }
61
61
  exports.parser = parser;
@@ -52,7 +52,6 @@ function getProcessingFunction(matcherTypeID, dataType) {
52
52
  case matcherTypes_1.matcherTypes.BETWEEN:
53
53
  return dataType === 'DATETIME' ? convertions_1.zeroSinceSS : undefined;
54
54
  case matcherTypes_1.matcherTypes.IN_SPLIT_TREATMENT:
55
- case matcherTypes_1.matcherTypes.IN_RULE_BASED_SEGMENT:
56
55
  return dependencyProcessor;
57
56
  default:
58
57
  return undefined;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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 = 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_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_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 = 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 = void 0;
5
- exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = void 0;
3
+ 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 = 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_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = 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_STORAGE_INVALID = 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 = 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 = void 0;
5
+ exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = 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.
@@ -26,7 +26,6 @@ exports.RETRIEVE_MANAGER = 29;
26
26
  exports.SYNC_OFFLINE_DATA = 30;
27
27
  exports.SYNC_SPLITS_FETCH = 31;
28
28
  exports.SYNC_SPLITS_UPDATE = 32;
29
- exports.SYNC_RBS_UPDATE = 33;
30
29
  exports.STREAMING_NEW_MESSAGE = 35;
31
30
  exports.SYNC_TASK_START = 36;
32
31
  exports.SYNC_TASK_EXECUTE = 37;
@@ -23,9 +23,8 @@ exports.codesDebug = info_1.codesInfo.concat([
23
23
  [c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
24
24
  // synchronizer
25
25
  [c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
26
- [c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s and rbSince = %s.'],
27
- [c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s.'],
28
- [c.SYNC_RBS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New rule-based segments %s. Removed rule-based segments %s.'],
26
+ [c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s'],
27
+ [c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s. Segment names collected %s'],
29
28
  [c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
30
29
  [c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
31
30
  [c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + ': Running %s'],
@@ -24,7 +24,7 @@ exports.codesError = [
24
24
  // input validation
25
25
  [c.ERROR_EVENT_TYPE_FORMAT, '%s: you passed "%s", event_type must adhere to the regular expression /^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/g. This means an event_type must be alphanumeric, cannot be more than 80 characters long, and can only include a dash, underscore, period, or colon as separators of alphanumeric characters.'],
26
26
  [c.ERROR_NOT_PLAIN_OBJECT, '%s: %s must be a plain object.'],
27
- [c.ERROR_SIZE_EXCEEDED, '%s: the maximum size allowed for the properties is 32768 bytes, which was exceeded. Event not queued.'],
27
+ [c.ERROR_SIZE_EXCEEDED, '%s: the maximum size allowed for the properties is 32768 bytes, which was exceeded.'],
28
28
  [c.ERROR_NOT_FINITE, '%s: value must be a finite number.'],
29
29
  [c.ERROR_NULL, '%s: you passed a null or undefined %s. It must be a non-empty string.'],
30
30
  [c.ERROR_TOO_LONG, '%s: %s too long. It must have 250 characters or less.'],
@@ -21,7 +21,7 @@ exports.codesWarn = error_1.codesError.concat([
21
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.'],
22
22
  // input validation
23
23
  [c.WARN_SETTING_NULL, '%s: Property "%s" is of invalid type. Setting value to null.'],
24
- [c.WARN_TRIMMING_PROPERTIES, '%s: Event has more than 300 properties. Some of them will be trimmed when processed.'],
24
+ [c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
25
25
  [c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
26
26
  [c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
27
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.'],
@@ -35,7 +35,7 @@ exports.codesWarn = error_1.codesError.concat([
35
35
  [c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
36
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'],
37
37
  [c.STREAMING_PARSING_MEMBERSHIPS_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching Memberships due to an error processing %s notification: %s'],
38
- [c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing %s notification: %s'],
38
+ [c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
39
39
  [c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
40
40
  [c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
41
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.'],
@@ -18,6 +18,14 @@ function treatmentsNotReady(featureFlagNames) {
18
18
  });
19
19
  return evaluations;
20
20
  }
21
+ function stringify(options) {
22
+ if (options && options.properties) {
23
+ try {
24
+ return JSON.stringify(options.properties);
25
+ }
26
+ catch ( /* JSON.stringify should never throw with validated options, but handling just in case */_a) { /* JSON.stringify should never throw with validated options, but handling just in case */ }
27
+ }
28
+ }
21
29
  /**
22
30
  * Creator of base client with getTreatments and track methods.
23
31
  */
@@ -25,13 +33,13 @@ function clientFactory(params) {
25
33
  var readinessManager = params.sdkReadinessManager.readinessManager, storage = params.storage, settings = params.settings, impressionsTracker = params.impressionsTracker, eventTracker = params.eventTracker, telemetryTracker = params.telemetryTracker;
26
34
  var log = settings.log, mode = settings.mode;
27
35
  var isAsync = (0, mode_1.isConsumerMode)(mode);
28
- function getTreatment(key, featureFlagName, attributes, withConfig, methodName) {
36
+ function getTreatment(key, featureFlagName, attributes, options, withConfig, methodName) {
29
37
  if (withConfig === void 0) { withConfig = false; }
30
38
  if (methodName === void 0) { methodName = constants_1.GET_TREATMENT; }
31
39
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? constants_1.TREATMENT_WITH_CONFIG : constants_1.TREATMENT);
32
40
  var wrapUp = function (evaluationResult) {
33
41
  var queue = [];
34
- var treatment = processEvaluation(evaluationResult, featureFlagName, key, attributes, withConfig, methodName, queue);
42
+ var treatment = processEvaluation(evaluationResult, featureFlagName, key, stringify(options), withConfig, methodName, queue);
35
43
  impressionsTracker.track(queue, attributes);
36
44
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
37
45
  return treatment;
@@ -43,18 +51,19 @@ function clientFactory(params) {
43
51
  treatmentNotReady;
44
52
  return (0, thenable_1.thenable)(evaluation) ? evaluation.then(function (res) { return wrapUp(res); }) : wrapUp(evaluation);
45
53
  }
46
- function getTreatmentWithConfig(key, featureFlagName, attributes) {
47
- return getTreatment(key, featureFlagName, attributes, true, constants_1.GET_TREATMENT_WITH_CONFIG);
54
+ function getTreatmentWithConfig(key, featureFlagName, attributes, options) {
55
+ return getTreatment(key, featureFlagName, attributes, options, true, constants_1.GET_TREATMENT_WITH_CONFIG);
48
56
  }
49
- function getTreatments(key, featureFlagNames, attributes, withConfig, methodName) {
57
+ function getTreatments(key, featureFlagNames, attributes, options, withConfig, methodName) {
50
58
  if (withConfig === void 0) { withConfig = false; }
51
59
  if (methodName === void 0) { methodName = constants_1.GET_TREATMENTS; }
52
60
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? constants_1.TREATMENTS_WITH_CONFIG : constants_1.TREATMENTS);
53
61
  var wrapUp = function (evaluationResults) {
54
62
  var queue = [];
55
63
  var treatments = {};
64
+ var properties = stringify(options);
56
65
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
57
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
66
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
58
67
  });
59
68
  impressionsTracker.track(queue, attributes);
60
69
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
@@ -67,10 +76,10 @@ function clientFactory(params) {
67
76
  treatmentsNotReady(featureFlagNames);
68
77
  return (0, thenable_1.thenable)(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
69
78
  }
70
- function getTreatmentsWithConfig(key, featureFlagNames, attributes) {
71
- return getTreatments(key, featureFlagNames, attributes, true, constants_1.GET_TREATMENTS_WITH_CONFIG);
79
+ function getTreatmentsWithConfig(key, featureFlagNames, attributes, options) {
80
+ return getTreatments(key, featureFlagNames, attributes, options, true, constants_1.GET_TREATMENTS_WITH_CONFIG);
72
81
  }
73
- function getTreatmentsByFlagSets(key, flagSetNames, attributes, withConfig, method, methodName) {
82
+ function getTreatmentsByFlagSets(key, flagSetNames, attributes, options, withConfig, method, methodName) {
74
83
  if (withConfig === void 0) { withConfig = false; }
75
84
  if (method === void 0) { method = constants_1.TREATMENTS_BY_FLAGSETS; }
76
85
  if (methodName === void 0) { methodName = constants_1.GET_TREATMENTS_BY_FLAG_SETS; }
@@ -78,9 +87,9 @@ function clientFactory(params) {
78
87
  var wrapUp = function (evaluationResults) {
79
88
  var queue = [];
80
89
  var treatments = {};
81
- var evaluations = evaluationResults;
82
- Object.keys(evaluations).forEach(function (featureFlagName) {
83
- treatments[featureFlagName] = processEvaluation(evaluations[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
90
+ var properties = stringify(options);
91
+ Object.keys(evaluationResults).forEach(function (featureFlagName) {
92
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
84
93
  });
85
94
  impressionsTracker.track(queue, attributes);
86
95
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
@@ -93,17 +102,17 @@ function clientFactory(params) {
93
102
  {};
94
103
  return (0, thenable_1.thenable)(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
95
104
  }
96
- function getTreatmentsWithConfigByFlagSets(key, flagSetNames, attributes) {
97
- return getTreatmentsByFlagSets(key, flagSetNames, attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSETS, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
105
+ function getTreatmentsWithConfigByFlagSets(key, flagSetNames, attributes, options) {
106
+ return getTreatmentsByFlagSets(key, flagSetNames, attributes, options, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSETS, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
98
107
  }
99
- function getTreatmentsByFlagSet(key, flagSetName, attributes) {
100
- return getTreatmentsByFlagSets(key, [flagSetName], attributes, false, constants_1.TREATMENTS_BY_FLAGSET, constants_1.GET_TREATMENTS_BY_FLAG_SET);
108
+ function getTreatmentsByFlagSet(key, flagSetName, attributes, options) {
109
+ return getTreatmentsByFlagSets(key, [flagSetName], attributes, options, false, constants_1.TREATMENTS_BY_FLAGSET, constants_1.GET_TREATMENTS_BY_FLAG_SET);
101
110
  }
102
- function getTreatmentsWithConfigByFlagSet(key, flagSetName, attributes) {
103
- return getTreatmentsByFlagSets(key, [flagSetName], attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSET, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
111
+ function getTreatmentsWithConfigByFlagSet(key, flagSetName, attributes, options) {
112
+ return getTreatmentsByFlagSets(key, [flagSetName], attributes, options, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSET, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
104
113
  }
105
114
  // Internal function
106
- function processEvaluation(evaluation, featureFlagName, key, attributes, withConfig, invokingMethodName, queue) {
115
+ function processEvaluation(evaluation, featureFlagName, key, properties, withConfig, invokingMethodName, queue) {
107
116
  var matchingKey = (0, key_1.getMatching)(key);
108
117
  var bucketingKey = (0, key_1.getBucketing)(key);
109
118
  var treatment = evaluation.treatment, label = evaluation.label, changeNumber = evaluation.changeNumber, _a = evaluation.config, config = _a === void 0 ? null : _a, impressionsDisabled = evaluation.impressionsDisabled;
@@ -119,6 +128,7 @@ function clientFactory(params) {
119
128
  bucketingKey: bucketingKey,
120
129
  label: label,
121
130
  changeNumber: changeNumber,
131
+ properties: properties
122
132
  },
123
133
  disabled: impressionsDisabled
124
134
  });
@@ -18,40 +18,35 @@ function clientAttributesDecoration(log, client) {
18
18
  var clientGetTreatmentsWithConfigByFlagSets = client.getTreatmentsWithConfigByFlagSets;
19
19
  var clientGetTreatmentsByFlagSet = client.getTreatmentsByFlagSet;
20
20
  var clientGetTreatmentsWithConfigByFlagSet = client.getTreatmentsWithConfigByFlagSet;
21
- var clientTrack = client.track;
22
- function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
23
- return clientGetTreatment(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
21
+ function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
22
+ return clientGetTreatment(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes), maybeOptions);
24
23
  }
25
- function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
26
- return clientGetTreatmentWithConfig(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
24
+ function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
25
+ return clientGetTreatmentWithConfig(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes), maybeOptions);
27
26
  }
28
- function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
29
- return clientGetTreatments(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
27
+ function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
28
+ return clientGetTreatments(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes), maybeOptions);
30
29
  }
31
- function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
32
- return clientGetTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
30
+ function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
31
+ return clientGetTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes), maybeOptions);
33
32
  }
34
- function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
35
- return clientGetTreatmentsByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes));
33
+ function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
34
+ return clientGetTreatmentsByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes), maybeOptions);
36
35
  }
37
- function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
38
- return clientGetTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes));
36
+ function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
37
+ return clientGetTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes), maybeOptions);
39
38
  }
40
- function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
41
- return clientGetTreatmentsByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes));
39
+ function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
40
+ return clientGetTreatmentsByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes), maybeOptions);
42
41
  }
43
- function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
44
- return clientGetTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes));
45
- }
46
- function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
47
- return clientTrack(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties);
42
+ function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
43
+ return clientGetTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes), maybeOptions);
48
44
  }
49
45
  function combineAttributes(maybeAttributes) {
50
46
  var storedAttributes = attributeStorage.getAll();
51
- if (Object.keys(storedAttributes).length > 0) {
52
- return (0, objectAssign_1.objectAssign)({}, storedAttributes, maybeAttributes);
53
- }
54
- return maybeAttributes;
47
+ return Object.keys(storedAttributes).length > 0 ?
48
+ (0, objectAssign_1.objectAssign)({}, storedAttributes, maybeAttributes) :
49
+ maybeAttributes;
55
50
  }
56
51
  return (0, objectAssign_1.objectAssign)(client, {
57
52
  getTreatment: getTreatment,
@@ -62,7 +57,6 @@ function clientAttributesDecoration(log, client) {
62
57
  getTreatmentsWithConfigByFlagSets: getTreatmentsWithConfigByFlagSets,
63
58
  getTreatmentsByFlagSet: getTreatmentsByFlagSet,
64
59
  getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
65
- track: track,
66
60
  /**
67
61
  * Add an attribute to client's in memory attributes storage
68
62
  *
@@ -17,7 +17,7 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
17
17
  /**
18
18
  * Avoid repeating this validations code
19
19
  */
20
- function validateEvaluationParams(maybeKey, maybeNameOrNames, maybeAttributes, methodName) {
20
+ function validateEvaluationParams(methodName, maybeKey, maybeNameOrNames, maybeAttributes, maybeOptions) {
21
21
  var key = (0, inputValidation_1.validateKey)(log, maybeKey, methodName);
22
22
  var nameOrNames = methodName.indexOf('ByFlagSet') > -1 ?
23
23
  (0, splitFilters_1.validateFlagSets)(log, methodName, maybeNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet) :
@@ -26,40 +26,42 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
26
26
  (0, inputValidation_1.validateSplit)(log, maybeNameOrNames, methodName);
27
27
  var attributes = (0, inputValidation_1.validateAttributes)(log, maybeAttributes, methodName);
28
28
  var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, methodName);
29
+ var options = (0, inputValidation_1.validateEvaluationOptions)(log, maybeOptions, methodName);
29
30
  (0, inputValidation_1.validateIfOperational)(log, readinessManager, methodName, nameOrNames);
30
31
  var valid = isNotDestroyed && key && nameOrNames && attributes !== false;
31
32
  return {
32
33
  valid: valid,
33
34
  key: key,
34
35
  nameOrNames: nameOrNames,
35
- attributes: attributes
36
+ attributes: attributes,
37
+ options: options
36
38
  };
37
39
  }
38
40
  function wrapResult(value) {
39
41
  return isAsync ? Promise.resolve(value) : value;
40
42
  }
41
- function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
42
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, constants_1.GET_TREATMENT);
43
+ function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
44
+ var params = validateEvaluationParams(constants_1.GET_TREATMENT, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
43
45
  if (params.valid) {
44
- return client.getTreatment(params.key, params.nameOrNames, params.attributes);
46
+ return client.getTreatment(params.key, params.nameOrNames, params.attributes, params.options);
45
47
  }
46
48
  else {
47
49
  return wrapResult(constants_1.CONTROL);
48
50
  }
49
51
  }
50
- function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
51
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, constants_1.GET_TREATMENT_WITH_CONFIG);
52
+ function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
53
+ var params = validateEvaluationParams(constants_1.GET_TREATMENT_WITH_CONFIG, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
52
54
  if (params.valid) {
53
- return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes);
55
+ return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes, params.options);
54
56
  }
55
57
  else {
56
58
  return wrapResult((0, objectAssign_1.objectAssign)({}, constants_1.CONTROL_WITH_CONFIG));
57
59
  }
58
60
  }
59
- function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
60
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, constants_1.GET_TREATMENTS);
61
+ function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
62
+ var params = validateEvaluationParams(constants_1.GET_TREATMENTS, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
61
63
  if (params.valid) {
62
- return client.getTreatments(params.key, params.nameOrNames, params.attributes);
64
+ return client.getTreatments(params.key, params.nameOrNames, params.attributes, params.options);
63
65
  }
64
66
  else {
65
67
  var res_1 = {};
@@ -68,10 +70,10 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
68
70
  return wrapResult(res_1);
69
71
  }
70
72
  }
71
- function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
72
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG);
73
+ function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
74
+ var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
73
75
  if (params.valid) {
74
- return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes);
76
+ return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes, params.options);
75
77
  }
76
78
  else {
77
79
  var res_2 = {};
@@ -80,37 +82,37 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
80
82
  return wrapResult(res_2);
81
83
  }
82
84
  }
83
- function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
84
- var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, constants_1.GET_TREATMENTS_BY_FLAG_SETS);
85
+ function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
86
+ var params = validateEvaluationParams(constants_1.GET_TREATMENTS_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
85
87
  if (params.valid) {
86
- return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes);
88
+ return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes, params.options);
87
89
  }
88
90
  else {
89
91
  return wrapResult({});
90
92
  }
91
93
  }
92
- function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
93
- var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
94
+ function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
95
+ var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
94
96
  if (params.valid) {
95
- return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes);
97
+ return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes, params.options);
96
98
  }
97
99
  else {
98
100
  return wrapResult({});
99
101
  }
100
102
  }
101
- function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
102
- var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, constants_1.GET_TREATMENTS_BY_FLAG_SET);
103
+ function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
104
+ var params = validateEvaluationParams(constants_1.GET_TREATMENTS_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
103
105
  if (params.valid) {
104
- return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes);
106
+ return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options);
105
107
  }
106
108
  else {
107
109
  return wrapResult({});
108
110
  }
109
111
  }
110
- function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
111
- var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
112
+ function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
113
+ var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
112
114
  if (params.valid) {
113
- return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes);
115
+ return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options);
114
116
  }
115
117
  else {
116
118
  return wrapResult({});
@@ -41,8 +41,8 @@ function splitApiFactory(settings, platform, telemetryTracker) {
41
41
  }
42
42
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_1.TOKEN));
43
43
  },
44
- fetchSplitChanges: function (since, noCache, till, rbSince) {
45
- var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (rbSince ? '&rbSince=' + rbSince : '') + (filterQueryString || '') + (till ? '&till=' + till : '');
44
+ fetchSplitChanges: function (since, noCache, till) {
45
+ var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
46
46
  return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
47
47
  .catch(function (err) {
48
48
  if (err.statusCode === 414)