diff --git a/CHANGES.txt b/CHANGES.txt index 8cdc48f85..6695ed5ec 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +10.24.0 (October XX, 2023) + - 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). + - Updated @splitsoftware/splitio-commons package to version 1.10.0 that includes vulnerability fixes, and adds the `defaultTreatment` property to the `SplitView` object. + 10.23.1 (September 22, 2023) - 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). diff --git a/package-lock.json b/package-lock.json index 27b3e9e61..686434b17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "10.23.1", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "1.9.1", + "@splitsoftware/splitio-commons": "1.10.0", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", @@ -874,9 +874,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.9.1.tgz", - "integrity": "sha512-+1lFUBj+Jgfd8l7nT49+rZodwgZXJ6c20+4PPb0O+iTmUZXHtYvfS2AK8A9j6QREubeccc6UMlfjH3SQVgwEbg==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.10.0.tgz", + "integrity": "sha512-se4jrBr0wMYJCeOKOx8xfICNSyRM9fpKT/7BtPy5mJERqfDWS+hjMLH+PweBNgW6YJeG1c4F0j9lBUE5CwgPjw==", "dependencies": { "tslib": "^2.3.1" }, @@ -8443,9 +8443,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.9.1.tgz", - "integrity": "sha512-+1lFUBj+Jgfd8l7nT49+rZodwgZXJ6c20+4PPb0O+iTmUZXHtYvfS2AK8A9j6QREubeccc6UMlfjH3SQVgwEbg==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.10.0.tgz", + "integrity": "sha512-se4jrBr0wMYJCeOKOx8xfICNSyRM9fpKT/7BtPy5mJERqfDWS+hjMLH+PweBNgW6YJeG1c4F0j9lBUE5CwgPjw==", "requires": { "tslib": "^2.3.1" } diff --git a/package.json b/package.json index 10c413c7f..44e84cc2e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "node": ">=6" }, "dependencies": { - "@splitsoftware/splitio-commons": "1.9.1", + "@splitsoftware/splitio-commons": "1.10.0", "@types/google.analytics": "0.0.40", "@types/ioredis": "^4.28.0", "bloom-filters": "^3.0.0", @@ -100,7 +100,7 @@ "check:version": "cross-env NODE_ENV=test tape -r ./ts-node.register src/settings/__tests__/defaults.spec.js", "test-browser": "npm run test-browser-unit && npm run test-browser-e2e", "test-browser-unit": "cross-env NODE_ENV=test karma start karma/unit.karma.conf.js", - "test-browser-e2e": "npm run test-browser-e2e-online && npm run test-browser-e2e-offline && npm run test-browser-e2e-destroy && npm run test-browser-e2e-errorCatching && npm run test-browser-e2e-push && npm run test-browser-e2e-gaIntegration", + "test-browser-e2e": "npm run test-browser-e2e-online && npm run test-browser-e2e-offline && npm run test-browser-e2e-destroy && npm run test-browser-e2e-errorCatching && npm run test-browser-e2e-push", "test-browser-e2e-online": "cross-env NODE_ENV=test karma start karma/e2e.online.karma.conf.js", "test-browser-e2e-offline": "cross-env NODE_ENV=test karma start karma/e2e.offline.karma.conf.js", "test-browser-e2e-destroy": "cross-env NODE_ENV=test karma start karma/e2e.destroy.karma.conf.js", diff --git a/src/__tests__/browserSuites/manager.spec.js b/src/__tests__/browserSuites/manager.spec.js index 856242a5d..6c3b42b60 100644 --- a/src/__tests__/browserSuites/manager.spec.js +++ b/src/__tests__/browserSuites/manager.spec.js @@ -39,7 +39,8 @@ export default async function (settings, fetchMock, assert) { 'killed': mockSplits.splits[index].killed, 'changeNumber': mockSplits.splits[index].changeNumber, 'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment), - 'configs': mockSplits.splits[index].configurations || {} + 'configs': mockSplits.splits[index].configurations || {}, + 'defaultTreatment': mockSplits.splits[index].defaultTreatment }); assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.'); diff --git a/src/__tests__/browserSuites/ready-promise.spec.js b/src/__tests__/browserSuites/ready-promise.spec.js index 5fae9c999..bdd3fc20f 100644 --- a/src/__tests__/browserSuites/ready-promise.spec.js +++ b/src/__tests__/browserSuites/ready-promise.spec.js @@ -31,7 +31,7 @@ function assertGetTreatmentWhenReady(assert, client) { function assertGetTreatmentControlNotReady(assert, client) { consoleSpy.log.resetHistory(); assert.equal(client.getTreatment('hierarchical_splits_test'), 'control', 'We should get control if client is not ready.'); - 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.'); + 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.'); } function assertGetTreatmentControlNotReadyOnDestroy(assert, client) { diff --git a/src/__tests__/nodeSuites/manager.spec.js b/src/__tests__/nodeSuites/manager.spec.js index 2658d2ebc..2f65b6e93 100644 --- a/src/__tests__/nodeSuites/manager.spec.js +++ b/src/__tests__/nodeSuites/manager.spec.js @@ -38,7 +38,8 @@ export default async function (settings, fetchMock, assert) { 'killed': mockSplits.splits[index].killed, 'changeNumber': mockSplits.splits[index].changeNumber, 'treatments': map(mockSplits.splits[index].conditions[0].partitions, partition => partition.treatment), - 'configs': mockSplits.splits[index].configurations || {} + 'configs': mockSplits.splits[index].configurations || {}, + 'defaultTreatment': mockSplits.splits[index].defaultTreatment }); assert.equal(manager.split('non_existent'), null, 'Trying to get a manager.split() of a Split that does not exist returns null.'); diff --git a/src/__tests__/nodeSuites/ready-promise.spec.js b/src/__tests__/nodeSuites/ready-promise.spec.js index 66f0bbdf2..9a0edff4c 100644 --- a/src/__tests__/nodeSuites/ready-promise.spec.js +++ b/src/__tests__/nodeSuites/ready-promise.spec.js @@ -28,7 +28,7 @@ function assertGetTreatmentWhenReady(assert, client, key) { function assertGetTreatmentControlNotReady(assert, client, key) { consoleSpy.log.resetHistory(); assert.equal(client.getTreatment(key, 'hierarchical_splits_test'), 'control', 'We should get control if client is not ready.'); - 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.'); + 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.'); } function assertGetTreatmentControlNotReadyOnDestroy(assert, client, key) { diff --git a/src/__tests__/offline/browser.spec.js b/src/__tests__/offline/browser.spec.js index ee3baf2fc..fc37b468e 100644 --- a/src/__tests__/offline/browser.spec.js +++ b/src/__tests__/offline/browser.spec.js @@ -166,10 +166,10 @@ tape('Browser offline mode', function (assert) { // Manager tests const expectedSplitView1 = { - name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {} + name: 'testing_split', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['on'], configs: {}, defaultTreatment: 'control' }; const expectedSplitView2 = { - name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' } + name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['off'], configs: { off: '{ "color": "blue" }' }, defaultTreatment: 'control' }; assert.deepEqual(manager.names(), ['testing_split', 'testing_split_with_config']); assert.deepEqual(manager.split('testing_split'), expectedSplitView1); @@ -267,7 +267,7 @@ tape('Browser offline mode', function (assert) { // Manager tests const expectedSplitView3 = { - name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {} + name: 'testing_split_with_config', trafficType: 'localhost', killed: false, changeNumber: 0, treatments: ['nope'], configs: {}, defaultTreatment: 'control' }; assert.deepEqual(manager.names(), ['testing_split', 'testing_split_2', 'testing_split_3', 'testing_split_with_config']); assert.deepEqual(manager.split('testing_split'), expectedSplitView1); diff --git a/src/__tests__/offline/node.spec.js b/src/__tests__/offline/node.spec.js index 9fb3cb511..95b8573cd 100644 --- a/src/__tests__/offline/node.spec.js +++ b/src/__tests__/offline/node.spec.js @@ -249,15 +249,15 @@ function ManagerDotSplitTests(assert) { const expectedView1 = { name: 'testing_split', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['on'], configs: {} + treatments: ['on'], configs: {}, defaultTreatment: 'control' }; const expectedView2 = { name: 'testing_split2', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['off'], configs: {} + treatments: ['off'], configs: {}, defaultTreatment: 'control' }; const expectedView3 = { name: 'testing_split3', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['custom_treatment'], configs: {} + treatments: ['custom_treatment'], configs: {}, defaultTreatment: 'control' }; assert.deepEqual(manager.split('testing_split'), expectedView1); @@ -289,7 +289,8 @@ function ManagerDotYamlTests(mockFileName, assert) { killed: false, trafficType: 'localhost', treatments: ['on'], - configs: {} + configs: {}, + defaultTreatment: 'control' }; const expectedView2 = { name: 'testing_split_only_wl', @@ -297,7 +298,8 @@ function ManagerDotYamlTests(mockFileName, assert) { killed: false, trafficType: 'localhost', treatments: ['whitelisted'], - configs: {} + configs: {}, + defaultTreatment: 'control' }; const expectedView3 = { name: 'testing_split_with_wl', @@ -308,13 +310,19 @@ function ManagerDotYamlTests(mockFileName, assert) { configs: { not_in_whitelist: '{"color": "green"}', multi_key_wl: '{"color": "brown"}' - } + }, + defaultTreatment: 'control' }; const expectedView4 = { - name: 'testing_split_off_with_config', changeNumber: 0, killed: false, trafficType: 'localhost', - treatments: ['off'], configs: { + name: 'testing_split_off_with_config', + changeNumber: 0, + killed: false, + trafficType: 'localhost', + treatments: ['off'], + configs: { off: '{"color": "green"}' - } + }, + defaultTreatment: 'control' }; assert.deepEqual(manager.split('testing_split_on'), expectedView1); diff --git a/ts-tests/index.ts b/ts-tests/index.ts index 51d2322f0..3c39b01f8 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -123,7 +123,8 @@ splitView = { changeNumber: 18294, configs: { off: '{"dimensions":"{\"height\":20,\"width\":40}"}' - } + }, + defaultTreatment: 'off' }; splitViews = [splitView]; diff --git a/ts-tests/package.json b/ts-tests/package.json index 3ea5704a1..d359b9e25 100644 --- a/ts-tests/package.json +++ b/ts-tests/package.json @@ -6,7 +6,7 @@ "license": "Apache-2.0", "repository": "splitio/javascript-client", "dependencies": { - "@types/node": "^14.18.52", + "@types/node": "^14.18.63", "typescript": "^3.7.4" } } diff --git a/types/splitio.d.ts b/types/splitio.d.ts index 38f9c2edc..450019190 100644 --- a/types/splitio.d.ts +++ b/types/splitio.d.ts @@ -663,7 +663,12 @@ declare namespace SplitIO { */ configs: { [treatmentName: string]: string - } + }, + /** + * The default treatment of the feature flag. + * @property {string} defaultTreatment + */ + defaultTreatment: string, }; /** * A promise that resolves to a feature flag view.