diff --git a/CHANGES.txt b/CHANGES.txt index 62d103e41..61cd21f1c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +11.7.0 (October 7, 2025) + - Added support for custom loggers: added `logger` configuration option and `factory.Logger.setLogger` method to allow the SDK to use a custom logger. + - Updated @splitsoftware/splitio-commons package to version 2.7.0. + 11.6.0 (September 18, 2025) - Added `storage.wrapper` configuration option to allow the SDK to use a custom storage wrapper for the storage type `LOCALSTORAGE`. Default value is `window.localStorage`. - Updated @splitsoftware/splitio-commons package to version 2.6.0. diff --git a/package-lock.json b/package-lock.json index 288f018b8..23598221e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@splitsoftware/splitio", - "version": "11.6.0", + "version": "11.7.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio", - "version": "11.6.0", + "version": "11.7.0", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "2.6.0", + "@splitsoftware/splitio-commons": "2.7.0", "bloom-filters": "^3.0.4", "ioredis": "^4.28.0", "js-yaml": "^3.13.1", @@ -351,9 +351,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.6.0.tgz", - "integrity": "sha512-0xODXLciIvHSuMlb8eukIB2epb3ZyGOsrwS0cMuTdxEvCqr7Nuc9pWDdJtRuN1UwL/jIjBnpDYAc8s6mpqLX2g==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.7.0.tgz", + "integrity": "sha512-w2aemu5HNVQXX/tbmSuFjpWa/AjS+EBiH6ltHMqfg2MZMWayTFJbfjjQcudAVLR+vLjDw2DuCTp/xj3kKlcf5g==", "license": "Apache-2.0", "dependencies": { "@types/ioredis": "^4.28.0", @@ -6529,9 +6529,9 @@ } }, "node_modules/tar-fs": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.3.tgz", - "integrity": "sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -7740,9 +7740,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.6.0.tgz", - "integrity": "sha512-0xODXLciIvHSuMlb8eukIB2epb3ZyGOsrwS0cMuTdxEvCqr7Nuc9pWDdJtRuN1UwL/jIjBnpDYAc8s6mpqLX2g==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-2.7.0.tgz", + "integrity": "sha512-w2aemu5HNVQXX/tbmSuFjpWa/AjS+EBiH6ltHMqfg2MZMWayTFJbfjjQcudAVLR+vLjDw2DuCTp/xj3kKlcf5g==", "requires": { "@types/ioredis": "^4.28.0", "tslib": "^2.3.1" @@ -12526,9 +12526,9 @@ } }, "tar-fs": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.3.tgz", - "integrity": "sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", + "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", "dev": true, "requires": { "chownr": "^1.1.1", diff --git a/package.json b/package.json index c07ef3afc..8a88d9769 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio", - "version": "11.6.0", + "version": "11.7.0", "description": "Split SDK", "files": [ "README.md", @@ -38,7 +38,7 @@ "node": ">=14.0.0" }, "dependencies": { - "@splitsoftware/splitio-commons": "2.6.0", + "@splitsoftware/splitio-commons": "2.7.0", "bloom-filters": "^3.0.4", "ioredis": "^4.28.0", "js-yaml": "^3.13.1", diff --git a/src/__tests__/offline/node.spec.js b/src/__tests__/offline/node.spec.js index 8c9698615..48e9fd010 100644 --- a/src/__tests__/offline/node.spec.js +++ b/src/__tests__/offline/node.spec.js @@ -70,9 +70,16 @@ tape('Node.js Offline Mode', function (t) { t.test('Trying to specify an invalid extension it will timeout', assert => { const config = settingsGenerator('.forbidden'); - sinon.spy(console, 'log'); - - const factory = SplitFactory({ ...config, debug: 'ERROR' }); // enable error level logs to check the message. + sinon.stub(console, 'error'); + sinon.stub(console, 'warn'); + sinon.stub(console, 'info'); + sinon.stub(console, 'debug'); + + const factory = SplitFactory({ + ...config, + debug: 'ERROR', // enable logs to check the message. If logger is provided, any log level different than 'NONE' will be overridden to 'DEBUG'. + logger: console // use console as custom logger. + }); const client = factory.client(); client.on(client.Event.SDK_READY, () => { @@ -84,9 +91,15 @@ tape('Node.js Offline Mode', function (t) { client.on(client.Event.SDK_READY_TIMED_OUT, () => { assert.pass('If tried to load a file with invalid extension, we should emit SDK_READY_TIMED_OUT.'); - assert.ok(console.log.calledWithMatch(`[ERROR] splitio => sync:offline: There was an issue loading the mock feature flags data. No changes will be applied to the current cache. Error: Invalid extension specified for feature flags mock file. Accepted extensions are ".yml" and ".yaml". Your specified file is ${config.features}`)); + assert.ok(console.error.calledWithMatch(`splitio => sync:offline: There was an issue loading the mock feature flags data. No changes will be applied to the current cache. Error: Invalid extension specified for feature flags mock file. Accepted extensions are ".yml" and ".yaml". Your specified file is ${config.features}`)); + assert.notOk(console.warn.called, 'warn should not be called'); + assert.ok(console.info.called, 'info should be called'); + assert.ok(console.debug.called, 'debug should be called'); - console.log.restore(); + console.error.restore(); + console.warn.restore(); + console.info.restore(); + console.debug.restore(); client.destroy(); assert.end(); }); diff --git a/src/settings/defaults/version.js b/src/settings/defaults/version.js index d85530ba7..d51e26fdc 100644 --- a/src/settings/defaults/version.js +++ b/src/settings/defaults/version.js @@ -1 +1 @@ -export const packageVersion = '11.6.0'; +export const packageVersion = '11.7.0'; diff --git a/ts-tests/index.ts b/ts-tests/index.ts index d306a9294..271a437ea 100644 --- a/ts-tests/index.ts +++ b/ts-tests/index.ts @@ -49,6 +49,7 @@ let asyncManager: SplitIO.IAsyncManager; let browserClient: SplitIO.IBrowserClient; // Utility interfaces let impressionListener: SplitIO.IImpressionListener; +let MyLogger: SplitIO.Logger = console; /**** Custom Types ****/ @@ -227,6 +228,7 @@ SDK.Logger.setLogLevel(SDK.Logger.LogLevel.WARN); SDK.Logger.setLogLevel(SDK.Logger.LogLevel.ERROR); SDK.Logger.setLogLevel(SDK.Logger.LogLevel.NONE); SDK.Logger.disable(); +SDK.Logger.setLogger(MyLogger); AsyncSDK.Logger.enable(); AsyncSDK.Logger.setLogLevel(AsyncSDK.Logger.LogLevel.DEBUG); @@ -235,6 +237,7 @@ AsyncSDK.Logger.setLogLevel(AsyncSDK.Logger.LogLevel.WARN); AsyncSDK.Logger.setLogLevel(AsyncSDK.Logger.LogLevel.ERROR); AsyncSDK.Logger.setLogLevel(AsyncSDK.Logger.LogLevel.NONE); AsyncSDK.Logger.disable(); +AsyncSDK.Logger.setLogger(MyLogger); /**** Tests for IClient interface ****/ @@ -571,6 +574,7 @@ let fullBrowserSettings: SplitIO.IBrowserSettings = { }, impressionListener: impressionListener, debug: true, + logger: MyLogger, streamingEnabled: true, sync: { splitFilters: splitFilters,