Skip to content

[Custom InLocalStorage] #883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: development
Choose a base branch
from
Draft
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: 2 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build

- name: Store assets
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }}
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/inlocalstorage' || github.ref == 'refs/heads/master') }}
uses: actions/upload-artifact@v4
with:
name: assets
Expand All @@ -68,7 +68,7 @@ jobs:
name: Upload assets
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/inlocalstorage' }}
strategy:
matrix:
environment:
Expand Down
14 changes: 13 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
11.5.0 (August XX, 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`.

11.4.1 (June 3, 2025)
- Updated @splitsoftware/splitio-commons package to version 2.4.1, which improves the Proxy fallback to flag spec version 1.2 by handling the case when the Proxy does not return an end-of-stream marker in 400 status code responses.

Expand All @@ -10,7 +13,7 @@
- Updated @splitsoftware/splitio-commons package to version 2.3.0, which optimizes the Redis storage to:
- Avoid lazy require of the `ioredis` dependency when the SDK is initialized, and
- Flag the SDK as ready from cache immediately to allow queueing feature flag evaluations before SDK_READY event is emitted.
- Bugfix - Enhanced HTTP client module to implement timeouts for failing requests that might otherwise remain pending indefinitely on some Fetch API implementations.
- Bugfix - Enhanced HTTP client module to implement timeouts for failing requests that might otherwise remain pending indefinitely on some Fetch API implementations, pausing the SDK synchronization process.

11.2.0 (March 28, 2025)
- 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.
Expand Down Expand Up @@ -51,6 +54,15 @@
- Removed the deprecated `GOOGLE_ANALYTICS_TO_SPLIT` and `SPLIT_TO_GOOGLE_ANALYTICS` integrations. The `integrations` configuration option has been removed from the SDK factory configuration, along with the associated interfaces in the TypeScript definitions.
- Removed the `core.trafficType` configuration option (`SplitIO.IBrowserSettings['core']['trafficType]`) and the `trafficType` parameter from the SDK `client()` method in Browser (`SplitIO.IBrowserSDK['client']`). As a result, traffic types can no longer be bound to SDK clients, and the traffic type must be provided in the `track` method.

10.28.1 (July 25, 2025)
- Updated @splitsoftware/splitio-commons package to version 1.17.1 that includes some vulnerability and bug fixes.
- Updated the Redis storage to avoid lazy require of the `ioredis` dependency when the SDK is initialized.
- Bugfix - Enhanced HTTP client module to implement timeouts for failing requests that might otherwise remain pending indefinitely on some Fetch API implementations, pausing the SDK synchronization process.
- Bugfix - Properly handle rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).
- Bugfix - Sanitize the `SplitSDKMachineName` header value to avoid exceptions on HTTP/S requests when it contains non ISO-8859-1 characters (Related to issue https://github.com/splitio/javascript-client/issues/847).
- Bugfix - Fixed an issue with the SDK_UPDATE event on server-side, where it was not being emitted if there was an empty segment and the SDK received a feature flag update notification.
- Bugfix - Fixed an issue with the server-side polling manager that caused dangling timers when the SDK was destroyed before it was ready.

10.28.0 (September 6, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio",
"version": "11.4.1",
"version": "11.4.2-rc.2",
"description": "Split SDK",
"files": [
"README.md",
Expand Down Expand Up @@ -38,7 +38,7 @@
"node": ">=14.0.0"
},
"dependencies": {
"@splitsoftware/splitio-commons": "2.4.1",
"@splitsoftware/splitio-commons": "2.4.2-rc.2",
"bloom-filters": "^3.0.4",
"ioredis": "^4.28.0",
"js-yaml": "^3.13.1",
Expand Down Expand Up @@ -111,7 +111,7 @@
"test-ts-decls": "tsc --build ts-tests",
"test": "npm run test-node && npm run test-browser",
"all": "npm run check && npm run build && npm run test-ts-decls && npm run test",
"publish:rc": "npm run check && npm run build && npm publish --tag canary",
"publish:rc": "npm run check && npm run build && npm publish --tag rc",
"publish:stable": "npm run check && npm run build && npm publish"
},
"greenkeeper": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function testSynchronizationRetries(fetchMock, assert) {
});

// initial auth
fetchMock.getOnce(url(settings, `/v2/auth?s=1.3&users=${encodeURIComponent(userKey)}&users=${encodeURIComponent(otherUserKeySync)}`), function (url, opts) {
fetchMock.getOnce(url(settings, `/v2/auth?s=1.3&users=${encodeURIComponent(otherUserKeySync)}&users=${encodeURIComponent(userKey)}`), function (url, opts) {
if (!opts.headers['Authorization']) assert.fail('`/v2/auth` request must include `Authorization` header');
assert.pass('auth success');
return { status: 200, body: authPushEnabledNicolas };
Expand All @@ -144,7 +144,7 @@ export function testSynchronizationRetries(fetchMock, assert) {
// initial split and memberships sync
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(url(settings, '/memberships/nicolas%40split.io'), { status: 200, body: membershipsNicolasMock1 });
fetchMock.get({ url: url(settings, '/memberships/marcio%40split.io'), repeat: 3 }, { status: 200, body: membershipsMarcio });
fetchMock.get({ url: url(settings, '/memberships/marcio%40split.io'), repeat: 4 }, { status: 200, body: membershipsMarcio });

// split and segment sync after SSE opened
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=1457552620999&rbSince=100'), function () {
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/browserSuites/ready-from-cache.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,14 @@ export default function (fetchMock, assert) {
let client = splitio.client();
let manager = splitio.manager();

t.true(console.log.calledWithMatch('clearOnInit was set and cache was not cleared in the last 24 hours. Cleaning up cache'), 'It should log a message about cleaning up cache');

client.once(client.Event.SDK_READY_FROM_CACHE, () => {
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
});

await client.ready();

t.true(console.log.calledWithMatch('clearOnInit was set and cache was not cleared in the last 24 hours. Cleaning up cache'), 'It should log a message about cleaning up cache');

t.equal(manager.names().sort().length, 36, 'active splits should be present for evaluation');

await splitio.destroy();
Expand Down
2 changes: 1 addition & 1 deletion src/platform/getEventSource/eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ that accepts a custom agent.

The MIT License

Copyright (c) EventSource GitHub organisation
Copyright (c) EventSource GitHub organization

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion src/settings/defaults/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const packageVersion = '11.4.1';
export const packageVersion = '11.4.2-rc.2';
4 changes: 3 additions & 1 deletion src/settings/storage/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export function validateStorage(settings) {
options = {},
prefix,
expirationDays,
clearOnInit
clearOnInit,
wrapper
} = { type: STORAGE_MEMORY },
} = settings;
let __originalType;
Expand Down Expand Up @@ -42,6 +43,7 @@ export function validateStorage(settings) {
prefix,
expirationDays,
clearOnInit,
wrapper,
__originalType
};
}
3 changes: 2 additions & 1 deletion ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ let fullBrowserSettings: SplitIO.IBrowserSettings = {
type: 'LOCALSTORAGE',
prefix: 'PREFIX',
expirationDays: 1,
clearOnInit: true
clearOnInit: true,
wrapper: window.sessionStorage
},
impressionListener: impressionListener,
debug: true,
Expand Down