Skip to content

Commit 71abec7

Browse files
Update JS-commons with rule-based segments and prerequisites support
1 parent 3023470 commit 71abec7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2544
-2275
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/checkout@v4
2626

2727
- name: Setup Node.js
28-
uses: actions/setup-node@v3
28+
uses: actions/setup-node@v4
2929
with:
3030
node-version: 'lts/*'
3131
cache: 'npm'

.github/workflows/sonar-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fetch-depth: 0
2121

2222
- name: Set up Node.js
23-
uses: actions/setup-node@v3
23+
uses: actions/setup-node@v4
2424
with:
2525
node-version: 'lts/*'
2626
cache: 'npm'

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.3.0 (May 21, 2025)
2+
- Added support for targeting rules based on rule-based segments.
3+
- Added support for feature flag prerequisites.
4+
- Updated @splitsoftware/splitio-commons package to version 2.4.0.
5+
16
1.2.0 (March 31, 2025)
27
- 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.
38
- Added two new configuration options for the SDK's `InLocalStorage` module to control the behavior of the persisted rollout plan cache in the browser:

package-lock.json

Lines changed: 9 additions & 9 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": "1.2.0",
3+
"version": "1.2.1-rc.0",
44
"description": "Split SDK for JavaScript on Browser",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
@@ -59,7 +59,7 @@
5959
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
6060
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
6161
"dependencies": {
62-
"@splitsoftware/splitio-commons": "2.2.0",
62+
"@splitsoftware/splitio-commons": "2.3.1-rc.0",
6363
"tslib": "^2.3.1",
6464
"unfetch": "^4.2.0"
6565
},

src/__tests__/browserSuites/fetch-specific-splits.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ export default function fetchSpecificSplits(fetchMock, assert) {
2424
const queryString = queryStrings[i] || '';
2525
let factory;
2626

27-
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.2&since=-1' + queryString, { status: 200, body: { splits: [], since: -1, till: 1457552620999 } });
28-
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.2&since=1457552620999' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
29-
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.2&since=1457552620999' + queryString, function () {
27+
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.3&since=-1&rbSince=-1' + queryString, { status: 200, body: { splits: [], since: -1, till: 1457552620999 } });
28+
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.3&since=1457552620999&rbSince=-1' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
29+
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.3&since=1457552620999&rbSince=-1' + queryString, function () {
3030
factory.client().destroy().then(() => {
3131
assert.pass(`splitFilters #${i}`);
3232
});
33-
return { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } };
33+
return { status: 200, body: { ff: { d: [], s: 1457552620999, t: 1457552620999 } } };
3434
});
3535
fetchMock.get(urls.sdk + '/memberships/nicolas%40split.io', { status: 200, body: { 'ms': {} } });
3636

src/__tests__/browserSuites/ignore-ip-addresses-setting.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ export default function (fetchMock, assert) {
101101

102102
// Mock GET endpoints before creating the client
103103
const settings = settingsFactory(config);
104-
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=-1'), { status: 200, body: splitChangesMock1 });
105-
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=1457552620999'), { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
104+
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
106105
fetchMock.getOnce(url(settings, `/memberships/${encodeURIComponent(config.core.key)}`), { status: 200, body: { ms: {} } });
107106

108107
// Init Split client

src/__tests__/browserSuites/impressions.debug.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { SplitFactory } from '../../';
22
import { settingsFactory } from '../../settings';
33
import splitChangesMock1 from '../mocks/splitchanges.since.-1.json';
4-
import splitChangesMock2 from '../mocks/splitchanges.since.1457552620999.json';
54
import membershipsFacundo from '../mocks/memberships.facundo@split.io.json';
65
import { DEBUG } from '@splitsoftware/splitio-commons/src/utils/constants';
76
import { truncateTimeFrame } from '@splitsoftware/splitio-commons/src/utils/time';
@@ -24,8 +23,7 @@ let truncatedTimeFrame;
2423

2524
export default function (fetchMock, assert) {
2625
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
27-
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=-1'), { status: 200, body: splitChangesMock1 });
28-
fetchMock.get(url(settings, '/splitChanges?s=1.2&since=1457552620999'), { status: 200, body: splitChangesMock2 });
26+
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
2927
fetchMock.get(url(settings, '/memberships/facundo%40split.io'), { status: 200, body: membershipsFacundo });
3028

3129
const splitio = SplitFactory({

src/__tests__/browserSuites/impressions.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ let truncatedTimeFrame;
2424

2525
export default function (fetchMock, assert) {
2626
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
27-
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=-1'), { status: 200, body: splitChangesMock1 });
28-
fetchMock.get(url(settings, '/splitChanges?s=1.2&since=1457552620999'), { status: 200, body: splitChangesMock2 });
27+
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
28+
fetchMock.get(url(settings, '/splitChanges?s=1.3&since=1457552620999&rbSince=100'), { status: 200, body: splitChangesMock2 });
2929
fetchMock.get(url(settings, '/memberships/facundo%40split.io'), { status: 200, body: membershipsFacundo });
3030

3131
const splitio = SplitFactory({

src/__tests__/browserSuites/manager.spec.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import map from 'lodash/map';
44
import { url } from '../testUtils';
55

66
export default async function (settings, fetchMock, assert) {
7-
fetchMock.getOnce({ url: url(settings, '/splitChanges?s=1.2&since=-1'), overwriteRoutes: true }, { status: 200, body: splitChangesMockReal });
7+
fetchMock.getOnce({ url: url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), overwriteRoutes: true }, { status: 200, body: splitChangesMockReal });
88

99
const mockSplits = splitChangesMockReal;
1010

@@ -29,27 +29,28 @@ export default async function (settings, fetchMock, assert) {
2929

3030
const splitNames = manager.names();
3131

32-
assert.equal(splitNames.length, mockSplits.splits.length, 'The manager.splits() method should return all split names on the factory storage.');
33-
assert.deepEqual(splitNames, map(mockSplits.splits, split => split.name), 'The manager.splits() method should return all split names on the factory storage.');
32+
assert.equal(splitNames.length, mockSplits.ff.d.length, 'The manager.splits() method should return all split names on the factory storage.');
33+
assert.deepEqual(splitNames, map(mockSplits.ff.d, split => split.name), 'The manager.splits() method should return all split names on the factory storage.');
3434

3535
const splitObj = manager.split(splitNames[0]);
3636
const expectedSplitObj = index => ({
37-
'trafficType': mockSplits.splits[index].trafficTypeName,
38-
'name': mockSplits.splits[index].name,
39-
'killed': mockSplits.splits[index].killed,
40-
'changeNumber': mockSplits.splits[index].changeNumber,
41-
'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment),
42-
'configs': mockSplits.splits[index].configurations || {},
43-
'sets': mockSplits.splits[index].sets,
44-
'defaultTreatment': mockSplits.splits[index].defaultTreatment,
45-
'impressionsDisabled': false
37+
'trafficType': mockSplits.ff.d[index].trafficTypeName,
38+
'name': mockSplits.ff.d[index].name,
39+
'killed': mockSplits.ff.d[index].killed,
40+
'changeNumber': mockSplits.ff.d[index].changeNumber,
41+
'treatments': map(mockSplits.ff.d[index].conditions[0].partitions, partition => partition.treatment),
42+
'configs': mockSplits.ff.d[index].configurations || {},
43+
'sets': mockSplits.ff.d[index].sets || [],
44+
'defaultTreatment': mockSplits.ff.d[index].defaultTreatment,
45+
'impressionsDisabled': false,
46+
'prerequisites': []
4647
});
4748

4849
assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.');
4950
assert.deepEqual(splitObj, expectedSplitObj(0), 'If we ask for an existent one we receive the expected split view.');
5051

5152
const splitObjects = manager.splits();
52-
assert.equal(splitObjects.length, mockSplits.splits.length, 'The manager.splits() returns the full collection of split views.');
53+
assert.equal(splitObjects.length, mockSplits.ff.d.length, 'The manager.splits() returns the full collection of split views.');
5354
assert.deepEqual(splitObjects[0], expectedSplitObj(0), 'And the split views should match the items of the collection in split view format.');
5455
assert.deepEqual(splitObjects[1], expectedSplitObj(1), 'And the split views should match the items of the collection in split view format.');
5556

0 commit comments

Comments
 (0)