Skip to content

Commit 7635df4

Browse files
Merge pull request #97 from splitio/add_default_treatment_to_split_view
Add defaultTreatment to SplitView
2 parents 9c0bb91 + dabf51f commit 7635df4

10 files changed

Lines changed: 29 additions & 18 deletions

File tree

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.10.2 (October XX, 2023)
2+
- 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).
3+
- Updated @splitsoftware/splitio-commons package to version 1.10.0 that includes vulnerability fixes, and adds the `defaultTreatment` property to the `SplitView` object.
4+
15
0.10.1 (September 22, 2023)
26
- Updated @splitsoftware/splitio-commons package to version 1.9.1. This update removes the handler for 'unload' DOM events, that can prevent browsers from being able to put pages in the back/forward cache for faster back and forward loads (Related to issue https://github.com/splitio/javascript-client/issues/759).
37

package-lock.json

Lines changed: 7 additions & 7 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
@@ -30,7 +30,7 @@
3030
"build:ga-to-split-autorequire": "terser ./node_modules/@splitsoftware/splitio-commons/src/integrations/ga/autoRequire.js --mangle --output ./scripts/ga-to-split-autorequire.js",
3131
"test": "npm run test:unit && npm run test:e2e",
3232
"test:unit": "jest",
33-
"test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errorCatching && npm run test:e2e-push && npm run test:e2e-gaIntegration && npm run test:e2e-consumer",
33+
"test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errorCatching && npm run test:e2e-push && npm run test:e2e-consumer",
3434
"test:e2e-logger": "karma start karma/e2e.logger.karma.conf.js",
3535
"test:e2e-offline": "karma start karma/e2e.offline.karma.conf.js",
3636
"test:e2e-online": "karma start karma/e2e.online.karma.conf.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.9.1",
67+
"@splitsoftware/splitio-commons": "1.10.0",
6868
"@types/google.analytics": "0.0.40",
6969
"unfetch": "^4.2.0"
7070
},

src/__tests__/browserSuites/manager.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export default async function (settings, fetchMock, assert) {
3939
'killed': mockSplits.splits[index].killed,
4040
'changeNumber': mockSplits.splits[index].changeNumber,
4141
'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment),
42-
'configs': mockSplits.splits[index].configurations || {}
42+
'configs': mockSplits.splits[index].configurations || {},
43+
'defaultTreatment': mockSplits.splits[index].defaultTreatment
4344
});
4445

4546
assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.');

src/__tests__/browserSuites/ready-promise.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function assertGetTreatmentWhenReady(assert, client) {
3131
function assertGetTreatmentControlNotReady(assert, client) {
3232
consoleSpy.log.resetHistory();
3333
assert.equal(client.getTreatment('hierarchical_splits_test'), 'control', 'We should get control if client is not ready.');
34-
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
34+
assert.true(consoleSpy.log.calledWithExactly('[WARN] splitio => getTreatment: the SDK is not ready, results may be incorrect for feature flag hierarchical_splits_test. Make sure to wait for SDK readiness before using this method.'), 'Telling us that calling getTreatment would return CONTROL since SDK is not ready at this point.');
3535
}
3636

3737
function assertGetTreatmentControlNotReadyOnDestroy(assert, client) {

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: {} };
13+
const expectedSplitView = { name: 'hierarchical_splits_testing_on', trafficType: 'user', killed: false, changeNumber: 1487277320548, treatments: ['on', 'off'], configs: {}, 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: {} };
13+
const expectedSplitView = { name: 'hierarchical_splits_testing_on', trafficType: 'user', killed: false, changeNumber: 1487277320548, treatments: ['on', 'off'], configs: {}, defaultTreatment: 'off' };
1414

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

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: {}
184+
name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}, defaultTreatment: 'control'
185185
};
186186
const expectedSplitView2 = {
187-
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }
187+
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }, 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: {}
285+
name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}, 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);

ts-tests/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ splitView = {
135135
changeNumber: 18294,
136136
configs: {
137137
off: '{"dimensions":"{\"height\":20,\"width\":40}"}'
138-
}
138+
},
139+
defaultTreatment: 'off'
139140
};
140141
splitViews = [splitView];
141142

types/splitio.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,12 @@ declare namespace SplitIO {
498498
*/
499499
configs: {
500500
[treatmentName: string]: string
501-
}
501+
},
502+
/**
503+
* The default treatment of the feature flag.
504+
* @property {string} defaultTreatment
505+
*/
506+
defaultTreatment: string,
502507
};
503508
/**
504509
* A promise that resolves to a feature flag view.

0 commit comments

Comments
 (0)