Skip to content

Commit d6a0e69

Browse files
Merge pull request #401 from splitio/release_v2.2.0
Prepare release v2.2.0
2 parents ac8d76b + 752f736 commit d6a0e69

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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 backend.
2+
- Added a 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 impressions sent to Split backend. Read more in our docs.
33
- Added two new configuration options for the SDK storage in browsers when using storage type `LOCALSTORAGE`:
44
- `storage.expirationDays` to specify the validity period of the rollout cache.
55
- `storage.clearOnInit` to clear the rollout cache on SDK initialization.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "2.1.1-rc.1",
3+
"version": "2.2.0",
44
"description": "Split JavaScript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

src/evaluator/parser/__tests__/index.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { parser } from '..';
33
import { keyParser } from '../../../utils/key';
44
import { ISplitCondition } from '../../../dtos/types';
5-
import { bucket } from '../../../utils/murmur3/murmur3';
65
import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';
76

87
test('PARSER / if user is in segment all 100%:on', async function () {
@@ -662,8 +661,6 @@ test('PARSER / if user is in segment all then split 20%:A,20%:B,60%:A', async fu
662661
let evaluation = await evaluator(keyParser('aa'), 31, 100, 31);
663662
expect(evaluation.treatment).toBe('A'); // 20%:A // bucket 6 with murmur3
664663

665-
console.log(bucket('b297', 31));
666-
667664
evaluation = await evaluator(keyParser('b297'), 31, 100, 31);
668665
expect(evaluation.treatment).toBe('B'); // 20%:B // bucket 34 with murmur3
669666

src/storages/inLocalStorage/SplitsCacheInLocal.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
3131
else localStorage.removeItem(key);
3232
}
3333

34-
private _decrementCounts(split: ISplit | null) {
34+
private _decrementCounts(split: ISplit) {
3535
try {
36-
if (split) {
37-
const ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
38-
this._decrementCount(ttKey);
36+
const ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
37+
this._decrementCount(ttKey);
3938

40-
if (usesSegments(split)) {
41-
const segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
42-
this._decrementCount(segmentsCountKey);
43-
}
39+
if (usesSegments(split)) {
40+
const segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
41+
this._decrementCount(segmentsCountKey);
4442
}
4543
} catch (e) {
4644
this.log.error(LOG_PREFIX + e);
@@ -93,12 +91,14 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
9391
const splitFromLocalStorage = localStorage.getItem(splitKey);
9492
const previousSplit = splitFromLocalStorage ? JSON.parse(splitFromLocalStorage) : null;
9593

94+
if (previousSplit) {
95+
this._decrementCounts(previousSplit);
96+
this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
97+
}
98+
9699
localStorage.setItem(splitKey, JSON.stringify(split));
97100

98101
this._incrementCounts(split);
99-
this._decrementCounts(previousSplit);
100-
101-
if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
102102
this.addToFlagSets(split);
103103

104104
return true;
@@ -116,7 +116,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
116116
localStorage.removeItem(this.keys.buildSplitKey(name));
117117

118118
this._decrementCounts(split);
119-
if (split) this.removeFromFlagSets(split.name, split.sets);
119+
this.removeFromFlagSets(split.name, split.sets);
120120

121121
return true;
122122
} catch (e) {

0 commit comments

Comments
 (0)