Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.5.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.

1.4.0 (September 18, 2025)
- Added the `wrapper` option to the SDK's `InLocalStorage` module, to allow passing a custom storage for persisting the SDK rollout plan. The default is `window.localStorage`.
- Added the `initialRolloutPlan` configuration option for the SDK in standalone mode, to allow preloading the SDK storage with a snapshot of the rollout plan.
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-browserjs",
"version": "1.4.0",
"version": "1.5.0",
"description": "Split SDK for JavaScript on Browser",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down Expand Up @@ -59,7 +59,7 @@
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
"dependencies": {
"@splitsoftware/splitio-commons": "2.6.0",
"@splitsoftware/splitio-commons": "2.7.0",
"tslib": "^2.3.1",
"unfetch": "^4.2.0"
},
Expand Down
32 changes: 32 additions & 0 deletions src/__tests__/logger/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ tape('## E2E Logger Tests ##', assert => {
t.end();
});

assert.test('debug settings: custom logger', async (t) => {
const customLogger = {
debug: sinon.spy(),
info: sinon.spy(),
warn: sinon.spy(),
error: sinon.spy()
};

const factory = SplitFactory({ ...minConfig, debug: 'INFO', logger: customLogger });

t.equal(factory.settings.log.options.logLevel, 'DEBUG', 'When combined with the `logger` option, any log level other than `NONE` (false) will be set to `DEBUG` (true)');

await factory.client().destroy();
t.true(customLogger.debug.calledWithMatch('splitio => '), 'should log messages with level DEBUG');
t.true(customLogger.info.calledWithMatch('splitio => '), 'should log messages with level INFO');

logSpy.resetHistory();
t.end();
});

assert.test('debug settings: localStorage.splitio_debug = "enable"', async (t) => {
const factory = SplitFactory(minConfig);
await Promise.resolve();
Expand All @@ -79,6 +99,18 @@ tape('## E2E Logger Tests ##', assert => {
factory.Logger.setLogLevel('invalid');
t.equal(factory.settings.log.options.logLevel, 'WARN');

// attempt to set invalid logger
factory.Logger.setLogger('invalid logger');
t.equal(factory.settings.log.logger, undefined);

// set logger
factory.Logger.setLogger(console);
t.equal(factory.settings.log.logger, console);

// unset logger
factory.Logger.setLogger(undefined);
t.equal(factory.settings.log.logger, undefined);

factory.client().destroy();
}

Expand Down
2 changes: 1 addition & 1 deletion src/settings/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type SplitIO from '@splitsoftware/splitio-commons/types/splitio';
import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/logger/index';
import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';

const packageVersion = '1.4.0';
const packageVersion = '1.5.0';

/**
* In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
Expand Down
5 changes: 5 additions & 0 deletions ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ let asyncClient: SplitIO.IBrowserAsyncClient;
let asyncManager: SplitIO.IAsyncManager;
// Utility interfaces
let impressionListener: SplitIO.IImpressionListener;
let MyLogger: SplitIO.Logger = console;

/**** Custom Types ****/

Expand Down Expand Up @@ -248,6 +249,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);
Expand All @@ -256,6 +258,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 ****/

Expand Down Expand Up @@ -598,6 +601,7 @@ let fullBrowserSettings: SplitIO.IClientSideSettings = {
storage: syncStorageFactory,
impressionListener: impressionListener,
debug: true,
logger: MyLogger,
integrations: [],
streamingEnabled: true,
sync: {
Expand Down Expand Up @@ -645,6 +649,7 @@ let fullBrowserAsyncSettings: SplitIO.IClientSideAsyncSettings = {
}),
impressionListener: impressionListener,
debug: true,
logger: MyLogger,
integrations: [],
sync: {
impressionsMode: 'DEBUG',
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare module JsSdk {
/**
* Persistent storage. By default, it uses the browser's LocalStorage API if available.
*
* @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/browser-sdk/#configuring-persistent-cache-for-the-sdk}
* @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/browser-sdk/#configuring-cache}
*/
export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory;

Expand Down