@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
@@ -15,6 +15,14 @@ function treatmentsNotReady(featureFlagNames) {
15
15
  });
16
16
  return evaluations;
17
17
  }
18
+ function stringify(options) {
19
+ if (options && options.properties) {
20
+ try {
21
+ return JSON.stringify(options.properties);
22
+ }
23
+ 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 */ }
24
+ }
25
+ }
18
26
  /**
19
27
  * Creator of base client with getTreatments and track methods.
20
28
  */
@@ -22,13 +30,13 @@ export function clientFactory(params) {
22
30
  var readinessManager = params.sdkReadinessManager.readinessManager, storage = params.storage, settings = params.settings, impressionsTracker = params.impressionsTracker, eventTracker = params.eventTracker, telemetryTracker = params.telemetryTracker;
23
31
  var log = settings.log, mode = settings.mode;
24
32
  var isAsync = isConsumerMode(mode);
25
- function getTreatment(key, featureFlagName, attributes, withConfig, methodName) {
33
+ function getTreatment(key, featureFlagName, attributes, options, withConfig, methodName) {
26
34
  if (withConfig === void 0) { withConfig = false; }
27
35
  if (methodName === void 0) { methodName = GET_TREATMENT; }
28
36
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENT_WITH_CONFIG : TREATMENT);
29
37
  var wrapUp = function (evaluationResult) {
30
38
  var queue = [];
31
- var treatment = processEvaluation(evaluationResult, featureFlagName, key, attributes, withConfig, methodName, queue);
39
+ var treatment = processEvaluation(evaluationResult, featureFlagName, key, stringify(options), withConfig, methodName, queue);
32
40
  impressionsTracker.track(queue, attributes);
33
41
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
34
42
  return treatment;
@@ -40,18 +48,19 @@ export function clientFactory(params) {
40
48
  treatmentNotReady;
41
49
  return thenable(evaluation) ? evaluation.then(function (res) { return wrapUp(res); }) : wrapUp(evaluation);
42
50
  }
43
- function getTreatmentWithConfig(key, featureFlagName, attributes) {
44
- return getTreatment(key, featureFlagName, attributes, true, GET_TREATMENT_WITH_CONFIG);
51
+ function getTreatmentWithConfig(key, featureFlagName, attributes, options) {
52
+ return getTreatment(key, featureFlagName, attributes, options, true, GET_TREATMENT_WITH_CONFIG);
45
53
  }
46
- function getTreatments(key, featureFlagNames, attributes, withConfig, methodName) {
54
+ function getTreatments(key, featureFlagNames, attributes, options, withConfig, methodName) {
47
55
  if (withConfig === void 0) { withConfig = false; }
48
56
  if (methodName === void 0) { methodName = GET_TREATMENTS; }
49
57
  var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENTS_WITH_CONFIG : TREATMENTS);
50
58
  var wrapUp = function (evaluationResults) {
51
59
  var queue = [];
52
60
  var treatments = {};
61
+ var properties = stringify(options);
53
62
  Object.keys(evaluationResults).forEach(function (featureFlagName) {
54
- treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
63
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
55
64
  });
56
65
  impressionsTracker.track(queue, attributes);
57
66
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
@@ -64,10 +73,10 @@ export function clientFactory(params) {
64
73
  treatmentsNotReady(featureFlagNames);
65
74
  return thenable(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
66
75
  }
67
- function getTreatmentsWithConfig(key, featureFlagNames, attributes) {
68
- return getTreatments(key, featureFlagNames, attributes, true, GET_TREATMENTS_WITH_CONFIG);
76
+ function getTreatmentsWithConfig(key, featureFlagNames, attributes, options) {
77
+ return getTreatments(key, featureFlagNames, attributes, options, true, GET_TREATMENTS_WITH_CONFIG);
69
78
  }
70
- function getTreatmentsByFlagSets(key, flagSetNames, attributes, withConfig, method, methodName) {
79
+ function getTreatmentsByFlagSets(key, flagSetNames, attributes, options, withConfig, method, methodName) {
71
80
  if (withConfig === void 0) { withConfig = false; }
72
81
  if (method === void 0) { method = TREATMENTS_BY_FLAGSETS; }
73
82
  if (methodName === void 0) { methodName = GET_TREATMENTS_BY_FLAG_SETS; }
@@ -75,9 +84,9 @@ export function clientFactory(params) {
75
84
  var wrapUp = function (evaluationResults) {
76
85
  var queue = [];
77
86
  var treatments = {};
78
- var evaluations = evaluationResults;
79
- Object.keys(evaluations).forEach(function (featureFlagName) {
80
- treatments[featureFlagName] = processEvaluation(evaluations[featureFlagName], featureFlagName, key, attributes, withConfig, methodName, queue);
87
+ var properties = stringify(options);
88
+ Object.keys(evaluationResults).forEach(function (featureFlagName) {
89
+ treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, properties, withConfig, methodName, queue);
81
90
  });
82
91
  impressionsTracker.track(queue, attributes);
83
92
  stopTelemetryTracker(queue[0] && queue[0].imp.label);
@@ -90,17 +99,17 @@ export function clientFactory(params) {
90
99
  {};
91
100
  return thenable(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
92
101
  }
93
- function getTreatmentsWithConfigByFlagSets(key, flagSetNames, attributes) {
94
- return getTreatmentsByFlagSets(key, flagSetNames, attributes, true, TREATMENTS_WITH_CONFIG_BY_FLAGSETS, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
102
+ function getTreatmentsWithConfigByFlagSets(key, flagSetNames, attributes, options) {
103
+ return getTreatmentsByFlagSets(key, flagSetNames, attributes, options, true, TREATMENTS_WITH_CONFIG_BY_FLAGSETS, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
95
104
  }
96
- function getTreatmentsByFlagSet(key, flagSetName, attributes) {
97
- return getTreatmentsByFlagSets(key, [flagSetName], attributes, false, TREATMENTS_BY_FLAGSET, GET_TREATMENTS_BY_FLAG_SET);
105
+ function getTreatmentsByFlagSet(key, flagSetName, attributes, options) {
106
+ return getTreatmentsByFlagSets(key, [flagSetName], attributes, options, false, TREATMENTS_BY_FLAGSET, GET_TREATMENTS_BY_FLAG_SET);
98
107
  }
99
- function getTreatmentsWithConfigByFlagSet(key, flagSetName, attributes) {
100
- return getTreatmentsByFlagSets(key, [flagSetName], attributes, true, TREATMENTS_WITH_CONFIG_BY_FLAGSET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
108
+ function getTreatmentsWithConfigByFlagSet(key, flagSetName, attributes, options) {
109
+ return getTreatmentsByFlagSets(key, [flagSetName], attributes, options, true, TREATMENTS_WITH_CONFIG_BY_FLAGSET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
101
110
  }
102
111
  // Internal function
103
- function processEvaluation(evaluation, featureFlagName, key, attributes, withConfig, invokingMethodName, queue) {
112
+ function processEvaluation(evaluation, featureFlagName, key, properties, withConfig, invokingMethodName, queue) {
104
113
  var matchingKey = getMatching(key);
105
114
  var bucketingKey = getBucketing(key);
106
115
  var treatment = evaluation.treatment, label = evaluation.label, changeNumber = evaluation.changeNumber, _a = evaluation.config, config = _a === void 0 ? null : _a, impressionsDisabled = evaluation.impressionsDisabled;
@@ -116,6 +125,7 @@ export function clientFactory(params) {
116
125
  bucketingKey: bucketingKey,
117
126
  label: label,
118
127
  changeNumber: changeNumber,
128
+ properties: properties
119
129
  },
120
130
  disabled: impressionsDisabled
121
131
  });
@@ -15,40 +15,35 @@ export function clientAttributesDecoration(log, client) {
15
15
  var clientGetTreatmentsWithConfigByFlagSets = client.getTreatmentsWithConfigByFlagSets;
16
16
  var clientGetTreatmentsByFlagSet = client.getTreatmentsByFlagSet;
17
17
  var clientGetTreatmentsWithConfigByFlagSet = client.getTreatmentsWithConfigByFlagSet;
18
- var clientTrack = client.track;
19
- function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
20
- return clientGetTreatment(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
18
+ function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
19
+ return clientGetTreatment(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes), maybeOptions);
21
20
  }
22
- function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
23
- return clientGetTreatmentWithConfig(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
21
+ function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
22
+ return clientGetTreatmentWithConfig(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes), maybeOptions);
24
23
  }
25
- function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
26
- return clientGetTreatments(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
24
+ function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
25
+ return clientGetTreatments(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes), maybeOptions);
27
26
  }
28
- function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
29
- return clientGetTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
27
+ function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
28
+ return clientGetTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes), maybeOptions);
30
29
  }
31
- function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
32
- return clientGetTreatmentsByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes));
30
+ function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
31
+ return clientGetTreatmentsByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes), maybeOptions);
33
32
  }
34
- function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
35
- return clientGetTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes));
33
+ function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
34
+ return clientGetTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes), maybeOptions);
36
35
  }
37
- function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
38
- return clientGetTreatmentsByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes));
36
+ function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
37
+ return clientGetTreatmentsByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes), maybeOptions);
39
38
  }
40
- function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
41
- return clientGetTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes));
42
- }
43
- function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
44
- return clientTrack(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties);
39
+ function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
40
+ return clientGetTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes), maybeOptions);
45
41
  }
46
42
  function combineAttributes(maybeAttributes) {
47
43
  var storedAttributes = attributeStorage.getAll();
48
- if (Object.keys(storedAttributes).length > 0) {
49
- return objectAssign({}, storedAttributes, maybeAttributes);
50
- }
51
- return maybeAttributes;
44
+ return Object.keys(storedAttributes).length > 0 ?
45
+ objectAssign({}, storedAttributes, maybeAttributes) :
46
+ maybeAttributes;
52
47
  }
53
48
  return objectAssign(client, {
54
49
  getTreatment: getTreatment,
@@ -59,7 +54,6 @@ export function clientAttributesDecoration(log, client) {
59
54
  getTreatmentsWithConfigByFlagSets: getTreatmentsWithConfigByFlagSets,
60
55
  getTreatmentsByFlagSet: getTreatmentsByFlagSet,
61
56
  getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
62
- track: track,
63
57
  /**
64
58
  * Add an attribute to client's in memory attributes storage
65
59
  *
@@ -1,5 +1,5 @@
1
1
  import { objectAssign } from '../utils/lang/objectAssign';
2
- import { validateAttributes, validateEvent, validateEventValue, validateEventProperties, validateKey, validateSplit, validateSplits, validateTrafficType, validateIfNotDestroyed, validateIfOperational } from '../utils/inputValidation';
2
+ import { validateAttributes, validateEvent, validateEventValue, validateEventProperties, validateKey, validateSplit, validateSplits, validateTrafficType, validateIfNotDestroyed, validateIfOperational, validateEvaluationOptions } from '../utils/inputValidation';
3
3
  import { startsWith } from '../utils/lang';
4
4
  import { CONTROL, CONTROL_WITH_CONFIG, GET_TREATMENT, GET_TREATMENTS, GET_TREATMENTS_BY_FLAG_SET, GET_TREATMENTS_BY_FLAG_SETS, GET_TREATMENTS_WITH_CONFIG, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, GET_TREATMENT_WITH_CONFIG, TRACK_FN_LABEL } from '../utils/constants';
5
5
  import { isConsumerMode } from '../utils/settingsValidation/mode';
@@ -14,7 +14,7 @@ export function clientInputValidationDecorator(settings, client, readinessManage
14
14
  /**
15
15
  * Avoid repeating this validations code
16
16
  */
17
- function validateEvaluationParams(maybeKey, maybeNameOrNames, maybeAttributes, methodName) {
17
+ function validateEvaluationParams(methodName, maybeKey, maybeNameOrNames, maybeAttributes, maybeOptions) {
18
18
  var key = validateKey(log, maybeKey, methodName);
19
19
  var nameOrNames = methodName.indexOf('ByFlagSet') > -1 ?
20
20
  validateFlagSets(log, methodName, maybeNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet) :
@@ -23,40 +23,42 @@ export function clientInputValidationDecorator(settings, client, readinessManage
23
23
  validateSplit(log, maybeNameOrNames, methodName);
24
24
  var attributes = validateAttributes(log, maybeAttributes, methodName);
25
25
  var isNotDestroyed = validateIfNotDestroyed(log, readinessManager, methodName);
26
+ var options = validateEvaluationOptions(log, maybeOptions, methodName);
26
27
  validateIfOperational(log, readinessManager, methodName, nameOrNames);
27
28
  var valid = isNotDestroyed && key && nameOrNames && attributes !== false;
28
29
  return {
29
30
  valid: valid,
30
31
  key: key,
31
32
  nameOrNames: nameOrNames,
32
- attributes: attributes
33
+ attributes: attributes,
34
+ options: options
33
35
  };
34
36
  }
35
37
  function wrapResult(value) {
36
38
  return isAsync ? Promise.resolve(value) : value;
37
39
  }
38
- function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
39
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, GET_TREATMENT);
40
+ function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
41
+ var params = validateEvaluationParams(GET_TREATMENT, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
40
42
  if (params.valid) {
41
- return client.getTreatment(params.key, params.nameOrNames, params.attributes);
43
+ return client.getTreatment(params.key, params.nameOrNames, params.attributes, params.options);
42
44
  }
43
45
  else {
44
46
  return wrapResult(CONTROL);
45
47
  }
46
48
  }
47
- function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
48
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagName, maybeAttributes, GET_TREATMENT_WITH_CONFIG);
49
+ function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
50
+ var params = validateEvaluationParams(GET_TREATMENT_WITH_CONFIG, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
49
51
  if (params.valid) {
50
- return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes);
52
+ return client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes, params.options);
51
53
  }
52
54
  else {
53
55
  return wrapResult(objectAssign({}, CONTROL_WITH_CONFIG));
54
56
  }
55
57
  }
56
- function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
57
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, GET_TREATMENTS);
58
+ function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
59
+ var params = validateEvaluationParams(GET_TREATMENTS, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
58
60
  if (params.valid) {
59
- return client.getTreatments(params.key, params.nameOrNames, params.attributes);
61
+ return client.getTreatments(params.key, params.nameOrNames, params.attributes, params.options);
60
62
  }
61
63
  else {
62
64
  var res_1 = {};
@@ -65,10 +67,10 @@ export function clientInputValidationDecorator(settings, client, readinessManage
65
67
  return wrapResult(res_1);
66
68
  }
67
69
  }
68
- function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
69
- var params = validateEvaluationParams(maybeKey, maybeFeatureFlagNames, maybeAttributes, GET_TREATMENTS_WITH_CONFIG);
70
+ function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
71
+ var params = validateEvaluationParams(GET_TREATMENTS_WITH_CONFIG, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
70
72
  if (params.valid) {
71
- return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes);
73
+ return client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes, params.options);
72
74
  }
73
75
  else {
74
76
  var res_2 = {};
@@ -77,37 +79,37 @@ export function clientInputValidationDecorator(settings, client, readinessManage
77
79
  return wrapResult(res_2);
78
80
  }
79
81
  }
80
- function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
81
- var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, GET_TREATMENTS_BY_FLAG_SETS);
82
+ function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
83
+ var params = validateEvaluationParams(GET_TREATMENTS_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
82
84
  if (params.valid) {
83
- return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes);
85
+ return client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes, params.options);
84
86
  }
85
87
  else {
86
88
  return wrapResult({});
87
89
  }
88
90
  }
89
- function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
90
- var params = validateEvaluationParams(maybeKey, maybeFlagSets, maybeAttributes, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS);
91
+ function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
92
+ var params = validateEvaluationParams(GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
91
93
  if (params.valid) {
92
- return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes);
94
+ return client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes, params.options);
93
95
  }
94
96
  else {
95
97
  return wrapResult({});
96
98
  }
97
99
  }
98
- function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
99
- var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, GET_TREATMENTS_BY_FLAG_SET);
100
+ function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
101
+ var params = validateEvaluationParams(GET_TREATMENTS_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
100
102
  if (params.valid) {
101
- return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes);
103
+ return client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options);
102
104
  }
103
105
  else {
104
106
  return wrapResult({});
105
107
  }
106
108
  }
107
- function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
108
- var params = validateEvaluationParams(maybeKey, [maybeFlagSet], maybeAttributes, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET);
109
+ function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
110
+ var params = validateEvaluationParams(GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
109
111
  if (params.valid) {
110
- return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes);
112
+ return client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options);
111
113
  }
112
114
  else {
113
115
  return wrapResult({});
@@ -38,8 +38,8 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
38
38
  }
39
39
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
40
40
  },
41
- fetchSplitChanges: function (since, noCache, till, rbSince) {
42
- var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (rbSince ? '&rbSince=' + rbSince : '') + (filterQueryString || '') + (till ? '&till=' + till : '');
41
+ fetchSplitChanges: function (since, noCache, till) {
42
+ var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
43
43
  return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
44
44
  .catch(function (err) {
45
45
  if (err.statusCode === 414)
@@ -57,8 +57,8 @@ export { AbstractSplitsCacheSync };
57
57
  * Given a parsed split, it returns a boolean flagging if its conditions use segments matchers (rules & whitelists).
58
58
  * This util is intended to simplify the implementation of `splitsCache::usesSegments` method
59
59
  */
60
- export function usesSegments(ruleEntity) {
61
- var conditions = ruleEntity.conditions || [];
60
+ export function usesSegments(split) {
61
+ var conditions = split.conditions || [];
62
62
  for (var i = 0; i < conditions.length; i++) {
63
63
  var matchers = conditions[i].matcherGroup.matchers;
64
64
  for (var j = 0; j < matchers.length; j++) {
@@ -67,8 +67,5 @@ export function usesSegments(ruleEntity) {
67
67
  return true;
68
68
  }
69
69
  }
70
- var excluded = ruleEntity.excluded;
71
- if (excluded && excluded.segments && excluded.segments.length > 0)
72
- return true;
73
70
  return false;
74
71
  }
@@ -24,15 +24,6 @@ var KeyBuilder = /** @class */ (function () {
24
24
  KeyBuilder.prototype.buildSplitKeyPrefix = function () {
25
25
  return this.prefix + ".split.";
26
26
  };
27
- KeyBuilder.prototype.buildRBSegmentKey = function (rbsegmentName) {
28
- return this.prefix + ".rbsegment." + rbsegmentName;
29
- };
30
- KeyBuilder.prototype.buildRBSegmentsTillKey = function () {
31
- return this.prefix + ".rbsegments.till";
32
- };
33
- KeyBuilder.prototype.buildRBSegmentKeyPrefix = function () {
34
- return this.prefix + ".rbsegment.";
35
- };
36
27
  KeyBuilder.prototype.buildSegmentNameKey = function (segmentName) {
37
28
  return this.prefix + ".segment." + segmentName;
38
29
  };
@@ -6,7 +6,7 @@ var KeyBuilderCS = /** @class */ (function (_super) {
6
6
  function KeyBuilderCS(prefix, matchingKey) {
7
7
  var _this = _super.call(this, prefix) || this;
8
8
  _this.matchingKey = matchingKey;
9
- _this.regexSplitsCacheKey = new RegExp("^" + prefix + "\\.(splits?|trafficType|flagSet|rbsegment)\\.");
9
+ _this.regexSplitsCacheKey = new RegExp("^" + prefix + "\\.(splits?|trafficType|flagSet)\\.");
10
10
  return _this;
11
11
  }
12
12
  /**
@@ -32,9 +32,6 @@ var KeyBuilderCS = /** @class */ (function (_super) {
32
32
  KeyBuilderCS.prototype.isSplitKey = function (key) {
33
33
  return startsWith(key, this.prefix + ".split.");
34
34
  };
35
- KeyBuilderCS.prototype.isRBSegmentKey = function (key) {
36
- return startsWith(key, this.prefix + ".rbsegment.");
37
- };
38
35
  KeyBuilderCS.prototype.buildSplitsWithSegmentCountKey = function () {
39
36
  return this.prefix + ".splits.usingSegments";
40
37
  };
@@ -39,9 +39,6 @@ var KeyBuilderSS = /** @class */ (function (_super) {
39
39
  KeyBuilderSS.prototype.searchPatternForSplitKeys = function () {
40
40
  return this.buildSplitKeyPrefix() + "*";
41
41
  };
42
- KeyBuilderSS.prototype.searchPatternForRBSegmentKeys = function () {
43
- return this.buildRBSegmentKeyPrefix() + "*";
44
- };
45
42
  /* Telemetry keys */
46
43
  KeyBuilderSS.prototype.buildLatencyKey = function (method, bucket) {
47
44
  return this.latencyPrefix + "::" + this.versionablePrefix + "/" + METHOD_NAMES[method] + "/" + bucket;
@@ -44,13 +44,15 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
44
44
  };
45
45
  SplitsCacheInLocal.prototype._incrementCounts = function (split) {
46
46
  try {
47
- var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
48
- // @ts-expect-error
49
- localStorage.setItem(ttKey, toNumber(localStorage.getItem(ttKey)) + 1);
50
- if (usesSegments(split)) {
51
- var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
47
+ if (split) {
48
+ var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
52
49
  // @ts-expect-error
53
- localStorage.setItem(segmentsCountKey, toNumber(localStorage.getItem(segmentsCountKey)) + 1);
50
+ localStorage.setItem(ttKey, toNumber(localStorage.getItem(ttKey)) + 1);
51
+ if (usesSegments(split)) {
52
+ var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
53
+ // @ts-expect-error
54
+ localStorage.setItem(segmentsCountKey, toNumber(localStorage.getItem(segmentsCountKey)) + 1);
55
+ }
54
56
  }
55
57
  }
56
58
  catch (e) {
@@ -172,9 +174,12 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
172
174
  return true;
173
175
  var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
174
176
  var splitsWithSegmentsCount = storedCount === null ? 0 : toNumber(storedCount);
175
- return isFiniteNumber(splitsWithSegmentsCount) ?
176
- splitsWithSegmentsCount > 0 :
177
- true;
177
+ if (isFiniteNumber(splitsWithSegmentsCount)) {
178
+ return splitsWithSegmentsCount > 0;
179
+ }
180
+ else {
181
+ return true;
182
+ }
178
183
  };
179
184
  /**
180
185
  * Check if the splits information is already stored in browser LocalStorage.
@@ -13,7 +13,6 @@ import { STORAGE_LOCALSTORAGE } from '../../utils/constants';
13
13
  import { shouldRecordTelemetry, TelemetryCacheInMemory } from '../inMemory/TelemetryCacheInMemory';
14
14
  import { UniqueKeysCacheInMemoryCS } from '../inMemory/UniqueKeysCacheInMemoryCS';
15
15
  import { getMatching } from '../../utils/key';
16
- import { RBSegmentsCacheInLocal } from './RBSegmentsCacheInLocal';
17
16
  /**
18
17
  * InLocal storage factory for standalone client-side SplitFactory
19
18
  */
@@ -31,12 +30,10 @@ export function InLocalStorage(options) {
31
30
  var keys = new KeyBuilderCS(prefix, matchingKey);
32
31
  var expirationTimestamp = Date.now() - DEFAULT_CACHE_EXPIRATION_IN_MILLIS;
33
32
  var splits = new SplitsCacheInLocal(settings, keys, expirationTimestamp);
34
- var rbSegments = new RBSegmentsCacheInLocal(settings, keys);
35
33
  var segments = new MySegmentsCacheInLocal(log, keys);
36
34
  var largeSegments = new MySegmentsCacheInLocal(log, myLargeSegmentsKeyBuilder(prefix, matchingKey));
37
35
  return {
38
36
  splits: splits,
39
- rbSegments: rbSegments,
40
37
  segments: segments,
41
38
  largeSegments: largeSegments,
42
39
  impressions: new ImpressionsCacheInMemory(impressionsQueueSize),
@@ -49,7 +46,6 @@ export function InLocalStorage(options) {
49
46
  shared: function (matchingKey) {
50
47
  return {
51
48
  splits: this.splits,
52
- rbSegments: this.rbSegments,
53
49
  segments: new MySegmentsCacheInLocal(log, new KeyBuilderCS(prefix, matchingKey)),
54
50
  largeSegments: new MySegmentsCacheInLocal(log, myLargeSegmentsKeyBuilder(prefix, matchingKey)),
55
51
  impressions: this.impressions,
@@ -6,7 +6,6 @@ import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
6
6
  import { LOCALHOST_MODE, STORAGE_MEMORY } from '../../utils/constants';
7
7
  import { shouldRecordTelemetry, TelemetryCacheInMemory } from './TelemetryCacheInMemory';
8
8
  import { UniqueKeysCacheInMemory } from './UniqueKeysCacheInMemory';
9
- import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
10
9
  /**
11
10
  * InMemory storage factory for standalone server-side SplitFactory
12
11
  *
@@ -15,11 +14,9 @@ import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
15
14
  export function InMemoryStorageFactory(params) {
16
15
  var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, __splitFiltersValidation = _a.sync.__splitFiltersValidation;
17
16
  var splits = new SplitsCacheInMemory(__splitFiltersValidation);
18
- var rbSegments = new RBSegmentsCacheInMemory();
19
17
  var segments = new SegmentsCacheInMemory();
20
18
  var storage = {
21
19
  splits: splits,
22
- rbSegments: rbSegments,
23
20
  segments: segments,
24
21
  impressions: new ImpressionsCacheInMemory(impressionsQueueSize),
25
22
  impressionCounts: new ImpressionCountsCacheInMemory(),
@@ -6,7 +6,6 @@ import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
6
6
  import { LOCALHOST_MODE, STORAGE_MEMORY } from '../../utils/constants';
7
7
  import { shouldRecordTelemetry, TelemetryCacheInMemory } from './TelemetryCacheInMemory';
8
8
  import { UniqueKeysCacheInMemoryCS } from './UniqueKeysCacheInMemoryCS';
9
- import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
10
9
  /**
11
10
  * InMemory storage factory for standalone client-side SplitFactory
12
11
  *
@@ -15,12 +14,10 @@ import { RBSegmentsCacheInMemory } from './RBSegmentsCacheInMemory';
15
14
  export function InMemoryStorageCSFactory(params) {
16
15
  var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, __splitFiltersValidation = _a.sync.__splitFiltersValidation;
17
16
  var splits = new SplitsCacheInMemory(__splitFiltersValidation);
18
- var rbSegments = new RBSegmentsCacheInMemory();
19
17
  var segments = new MySegmentsCacheInMemory();
20
18
  var largeSegments = new MySegmentsCacheInMemory();
21
19
  var storage = {
22
20
  splits: splits,
23
- rbSegments: rbSegments,
24
21
  segments: segments,
25
22
  largeSegments: largeSegments,
26
23
  impressions: new ImpressionsCacheInMemory(impressionsQueueSize),
@@ -33,7 +30,6 @@ export function InMemoryStorageCSFactory(params) {
33
30
  shared: function () {
34
31
  return {
35
32
  splits: this.splits,
36
- rbSegments: this.rbSegments,
37
33
  segments: new MySegmentsCacheInMemory(),
38
34
  largeSegments: new MySegmentsCacheInMemory(),
39
35
  impressions: this.impressions,
@@ -9,7 +9,6 @@ import { TelemetryCacheInRedis } from './TelemetryCacheInRedis';
9
9
  import { UniqueKeysCacheInRedis } from './UniqueKeysCacheInRedis';
10
10
  import { ImpressionCountsCacheInRedis } from './ImpressionCountsCacheInRedis';
11
11
  import { metadataBuilder } from '../utils';
12
- import { RBSegmentsCacheInRedis } from './RBSegmentsCacheInRedis';
13
12
  /**
14
13
  * InRedis storage factory for consumer server-side SplitFactory, that uses `Ioredis` Redis client for Node.js
15
14
  * @see {@link https://www.npmjs.com/package/ioredis}
@@ -38,7 +37,6 @@ export function InRedisStorage(options) {
38
37
  });
39
38
  return {
40
39
  splits: new SplitsCacheInRedis(log, keys, redisClient, settings.sync.__splitFiltersValidation),
41
- rbSegments: new RBSegmentsCacheInRedis(log, keys, redisClient),
42
40
  segments: new SegmentsCacheInRedis(log, keys, redisClient),
43
41
  impressions: new ImpressionsCacheInRedis(log, keys.buildImpressionsKey(), redisClient, metadata),
44
42
  impressionCounts: impressionCountsCache,
@@ -19,7 +19,6 @@ import { UniqueKeysCacheInMemory } from '../inMemory/UniqueKeysCacheInMemory';
19
19
  import { UniqueKeysCacheInMemoryCS } from '../inMemory/UniqueKeysCacheInMemoryCS';
20
20
  import { metadataBuilder } from '../utils';
21
21
  import { LOG_PREFIX } from '../pluggable/constants';
22
- import { RBSegmentsCachePluggable } from './RBSegmentsCachePluggable';
23
22
  var NO_VALID_WRAPPER = 'Expecting pluggable storage `wrapper` in options, but no valid wrapper instance was provided.';
24
23
  var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow the expected interface. Check our docs.';
25
24
  /**
@@ -102,7 +101,6 @@ export function PluggableStorage(options) {
102
101
  });
103
102
  return {
104
103
  splits: new SplitsCachePluggable(log, keys, wrapper, settings.sync.__splitFiltersValidation),
105
- rbSegments: new RBSegmentsCachePluggable(log, keys, wrapper),
106
104
  segments: new SegmentsCachePluggable(log, keys, wrapper),
107
105
  impressions: isPartialConsumer ? new ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
108
106
  impressionCounts: impressionCountsCache,
@@ -23,6 +23,7 @@ export function impressionsToJSON(impressions, metadata) {
23
23
  c: impression.changeNumber,
24
24
  m: impression.time,
25
25
  pt: impression.pt,
26
+ properties: impression.properties
26
27
  }
27
28
  };
28
29
  return JSON.stringify(impressionWithMetadata);
@@ -3,10 +3,10 @@
3
3
  * SplitChanges fetcher is a wrapper around `splitChanges` API service that parses the response and handle errors.
4
4
  */
5
5
  export function splitChangesFetcherFactory(fetchSplitChanges) {
6
- return function splitChangesFetcher(since, noCache, till, rbSince,
6
+ return function splitChangesFetcher(since, noCache, till,
7
7
  // Optional decorator for `fetchSplitChanges` promise, such as timeout or time tracker
8
8
  decorator) {
9
- var splitsPromise = fetchSplitChanges(since, noCache, till, rbSince);
9
+ var splitsPromise = fetchSplitChanges(since, noCache, till);
10
10
  if (decorator)
11
11
  splitsPromise = decorator(splitsPromise);
12
12
  return splitsPromise.then(function (resp) { return resp.json(); });
@@ -31,10 +31,10 @@ export function pollingManagerCSFactory(params) {
31
31
  readiness.splits.on(SDK_SPLITS_ARRIVED, function () {
32
32
  if (!splitsSyncTask.isRunning())
33
33
  return; // noop if not doing polling
34
- var usingSegments = storage.splits.usesSegments() || storage.rbSegments.usesSegments();
35
- if (usingSegments !== mySegmentsSyncTask.isRunning()) {
36
- log.info(POLLING_SMART_PAUSING, [usingSegments ? 'ON' : 'OFF']);
37
- if (usingSegments) {
34
+ var splitsHaveSegments = storage.splits.usesSegments();
35
+ if (splitsHaveSegments !== mySegmentsSyncTask.isRunning()) {
36
+ log.info(POLLING_SMART_PAUSING, [splitsHaveSegments ? 'ON' : 'OFF']);
37
+ if (splitsHaveSegments) {
38
38
  startMySegmentsSyncTasks();
39
39
  }
40
40
  else {
@@ -46,10 +46,10 @@ export function pollingManagerCSFactory(params) {
46
46
  var mySegmentsSyncTask = mySegmentsSyncTaskFactory(splitApi.fetchMemberships, storage, readiness, settings, matchingKey);
47
47
  // smart ready
48
48
  function smartReady() {
49
- if (!readiness.isReady() && !storage.splits.usesSegments() && !storage.rbSegments.usesSegments())
49
+ if (!readiness.isReady() && !storage.splits.usesSegments())
50
50
  readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
51
51
  }
52
- if (!storage.splits.usesSegments() && !storage.rbSegments.usesSegments())
52
+ if (!storage.splits.usesSegments())
53
53
  setTimeout(smartReady, 0);
54
54
  else
55
55
  readiness.splits.once(SDK_SPLITS_ARRIVED, smartReady);
@@ -63,7 +63,7 @@ export function pollingManagerCSFactory(params) {
63
63
  start: function () {
64
64
  log.info(POLLING_START);
65
65
  splitsSyncTask.start();
66
- if (storage.splits.usesSegments() || storage.rbSegments.usesSegments())
66
+ if (storage.splits.usesSegments())
67
67
  startMySegmentsSyncTasks();
68
68
  },
69
69
  // Stop periodic fetching (polling)
@@ -9,7 +9,7 @@ import { MEMBERSHIPS_LS_UPDATE } from '../../streaming/constants';
9
9
  * - uses `segmentsEventEmitter` to emit events related to segments data updates
10
10
  */
11
11
  export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, storage, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady, matchingKey) {
12
- var splits = storage.splits, rbSegments = storage.rbSegments, segments = storage.segments, largeSegments = storage.largeSegments;
12
+ var splits = storage.splits, segments = storage.segments, largeSegments = storage.largeSegments;
13
13
  var readyOnAlreadyExistentState = true;
14
14
  var startingUp = true;
15
15
  /** timeout and telemetry decorator for `splitChangesFetcher` promise */
@@ -31,7 +31,7 @@ export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, storage, segmen
31
31
  shouldNotifyUpdate = largeSegments.resetSegments(segmentsData.ls || {}) || shouldNotifyUpdate;
32
32
  }
33
33
  // Notify update if required
34
- if ((splits.usesSegments() || rbSegments.usesSegments()) && (shouldNotifyUpdate || readyOnAlreadyExistentState)) {
34
+ if (splits.usesSegments() && (shouldNotifyUpdate || readyOnAlreadyExistentState)) {
35
35
  readyOnAlreadyExistentState = false;
36
36
  segmentsEventEmitter.emit(SDK_SEGMENTS_ARRIVED);
37
37
  }