Skip to content

Commit 074d1ad

Browse files
authored
Merge pull request #100 from splitio/sdks-7437
Flag sets
2 parents aed92aa + 24f1904 commit 074d1ad

13 files changed

Lines changed: 8496 additions & 11409 deletions

CHANGES.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
0.12.0 (November 3, 2023)
2+
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
3+
- Added new variations of the get treatment methods to support evaluating flags in given flag set/s.
4+
- getTreatmentsByFlagSet and getTreatmentsByFlagSets
5+
- getTreatmentsWithConfigByFlagSets and getTreatmentsWithConfigByFlagSets
6+
- Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
7+
- Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init.
8+
- Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
9+
- Updated @splitsoftware/splitio-commons package to version 1.11.0.
10+
111
0.11.0 (October 31, 2023)
212
- Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).
313
- Updated @splitsoftware/splitio-commons package to version 1.10.0 that includes vulnerability fixes, and adds the `defaultTreatment` property to the `SplitView` object.

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-browserjs",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "Split SDK for JavaScript on Browser",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
@@ -64,7 +64,7 @@
6464
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
6565
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
6666
"dependencies": {
67-
"@splitsoftware/splitio-commons": "1.10.0",
67+
"@splitsoftware/splitio-commons": "1.11.0",
6868
"@types/google.analytics": "0.0.40",
6969
"unfetch": "^4.2.0"
7070
},

src/__tests__/browserSuites/manager.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default async function (settings, fetchMock, assert) {
4040
'changeNumber': mockSplits.splits[index].changeNumber,
4141
'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment),
4242
'configs': mockSplits.splits[index].configurations || {},
43+
'sets': mockSplits.splits[index].sets,
4344
'defaultTreatment': mockSplits.splits[index].defaultTreatment
4445
});
4546

src/__tests__/browserSuites/ready-from-cache.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ export default function (fetchMock, assert) {
473473
events: 'https://events.baseurl/readyFromCache_5'
474474
};
475475
localStorage.clear();
476-
t.plan(7);
476+
t.plan(6);
477477

478478
fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=-1&names=p1__split,p2__split', { status: 200, body: { splits: [splitDeclarations.p1__split, splitDeclarations.p2__split], since: -1, till: 1457552620999 } }, { delay: 10 }); // short delay to let emit SDK_READY_FROM_CACHE
479479
// fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=1457552620999&names=p1__split', { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
@@ -499,7 +499,8 @@ export default function (fetchMock, assert) {
499499
const manager = splitio.manager();
500500

501501
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
502-
t.deepEqual(manager.names(), ['p2__split'], 'stored p3__split must be removed because doesn\'t match the filter');
502+
t.fail('It should not emit SDK_READY_FROM_CACHE if cache is empty.');
503+
t.end();
503504
});
504505

505506
client.once(client.Event.SDK_READY, () => {
@@ -731,7 +732,7 @@ export default function (fetchMock, assert) {
731732
events: 'https://events.baseurl/readyFromCache_9'
732733
};
733734
localStorage.clear();
734-
t.plan(7);
735+
t.plan(6);
735736

736737
fetchMock.getOnce(testUrls.sdk + '/splitChanges?since=-1&names=no%20exist%20trim,no_exist,p3__split&prefixes=no%20exist%20trim,p2', { status: 200, body: { splits: [splitDeclarations.p2__split, splitDeclarations.p3__split], since: -1, till: 1457552620999 } }, { delay: 10 }); // short delay to let emit SDK_READY_FROM_CACHE
737738
fetchMock.getOnce(testUrls.sdk + '/mySegments/nicolas%40split.io', { status: 200, body: { mySegments: [] } });
@@ -757,7 +758,8 @@ export default function (fetchMock, assert) {
757758
const manager = splitio.manager();
758759

759760
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
760-
t.deepEqual(manager.names(), ['p2__split'], 'stored p1__split must be removed because doesn\'t match the filter');
761+
t.fail('It should not emit SDK_READY_FROM_CACHE because all splits were removed from cache since the filter query changed.');
762+
t.end();
761763
});
762764

763765
client.once(client.Event.SDK_READY, () => {

src/__tests__/browserSuites/telemetry.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default async function telemetryBrowserSuite(fetchMock, assert) {
5454
const data = JSON.parse(opts.body);
5555

5656
// Validate last successful sync
57-
assert.deepEqual(Object.keys(data.lS), ['sp', 'ms', 'te'], 'Successful splitChanges, mySegments and metrics/config requests');
57+
assert.deepEqual(Object.keys(data.lS), ['ms', 'sp', 'te'], 'Successful splitChanges, mySegments and metrics/config requests');
5858
lastSync = data.lS; delete data.lS;
5959

6060
// Validate http and method latencies
@@ -106,7 +106,8 @@ export default async function telemetryBrowserSuite(fetchMock, assert) {
106106
oM: 0, st: 'memory', aF: 1, rF: 0, sE: false,
107107
rR: { sp: 99999, ms: 60, im: 300, ev: 60, te: 1 } /* override featuresRefreshRate */,
108108
uO: { s: true, e: true, a: false, st: false, t: true } /* override sdk, events and telemetry URLs */,
109-
iQ: 30000, eQ: 500, iM: 0, iL: false, hP: false, nR: 1 /* 1 non ready usage */, t: [], i: [], uC: 2 /* Default GRANTED */
109+
iQ: 30000, eQ: 500, iM: 0, iL: false, hP: false, nR: 1 /* 1 non ready usage */, t: [], i: [], uC: 2 /* Default GRANTED */,
110+
fsT: 0, fsI: 0 /* Flag sets */
110111
}, 'metrics/config JSON payload should be the expected');
111112

112113
finish.next();

src/__tests__/consumer/browser_consumer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { version } from '../../../package.json';
1010
import { SplitFactory, PluggableStorage } from '../../';
1111

1212
const expectedSplitName = 'hierarchical_splits_testing_on';
13-
const expectedSplitView = { name: 'hierarchical_splits_testing_on', trafficType: 'user', killed: false, changeNumber: 1487277320548, treatments: ['on', 'off'], configs: {}, defaultTreatment: 'off' };
13+
const expectedSplitView = { name: 'hierarchical_splits_testing_on', trafficType: 'user', killed: false, changeNumber: 1487277320548, treatments: ['on', 'off'], configs: {}, sets: [], defaultTreatment: 'off' };
1414

1515
const wrapperPrefix = 'PLUGGABLE_STORAGE_UT';
1616
const wrapperInstance = inMemoryWrapperFactory();

src/__tests__/consumer/browser_consumer_partial.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { applyOperations } from './wrapper-commands';
1010
import { SplitFactory, PluggableStorage } from '../../';
1111

1212
const expectedSplitName = 'hierarchical_splits_testing_on';
13-
const expectedSplitView = { name: 'hierarchical_splits_testing_on', trafficType: 'user', killed: false, changeNumber: 1487277320548, treatments: ['on', 'off'], configs: {}, defaultTreatment: 'off' };
13+
const expectedSplitView = { name: 'hierarchical_splits_testing_on', trafficType: 'user', killed: false, changeNumber: 1487277320548, treatments: ['on', 'off'], configs: {}, sets: [], defaultTreatment: 'off' };
1414

1515
const wrapperPrefix = 'PLUGGABLE_STORAGE_UT';
1616
const wrapperInstance = inMemoryWrapperFactory();

src/__tests__/mocks/splitchanges.real.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"label": "default rule"
4848
}
4949
],
50-
"configurations": {}
50+
"configurations": {},
51+
"sets": []
5152
},
5253
{
5354
"trafficTypeName": "user",
@@ -98,7 +99,8 @@
9899
],
99100
"configurations": {
100101
"on": "{\"color\":\"brown\",\"dimensions\":{\"height\":12,\"width\":14},\"text\":{\"inner\":\"click me\"}}"
101-
}
102+
},
103+
"sets": []
102104
}
103105
],
104106
"since": -1,

src/__tests__/offline/browser.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ tape('Browser offline mode', function (assert) {
181181

182182
// Manager tests
183183
const expectedSplitView1 = {
184-
name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}, defaultTreatment: 'control'
184+
name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}, sets: [], defaultTreatment: 'control'
185185
};
186186
const expectedSplitView2 = {
187-
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }, defaultTreatment: 'control'
187+
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }, sets: [], defaultTreatment: 'control'
188188
};
189189
assert.deepEqual(manager.names(), ['testing_split', 'testing_split_with_config']);
190190
assert.deepEqual(manager.split('testing_split'), expectedSplitView1);
@@ -282,7 +282,7 @@ tape('Browser offline mode', function (assert) {
282282

283283
// Manager tests
284284
const expectedSplitView3 = {
285-
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}, defaultTreatment: 'control'
285+
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}, sets: [], defaultTreatment: 'control'
286286
};
287287
assert.deepEqual(manager.names(), ['testing_split', 'testing_split_2', 'testing_split_3', 'testing_split_with_config']);
288288
assert.deepEqual(manager.split('testing_split'), expectedSplitView1);

0 commit comments

Comments
 (0)