Skip to content

Rule-based segments and prerequisites #146

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

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
Expand Down
41 changes: 23 additions & 18 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.3.0 (May 22, 2025)
- Added support for targeting rules based on rule-based segments.
- Added support for feature flag prerequisites.
- Updated @splitsoftware/splitio-commons package to version 2.4.0.

1.2.0 (March 31, 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.
- Added two new configuration options for the SDK's `InLocalStorage` module to control the behavior of the persisted rollout plan cache in the browser:
Expand All @@ -8,10 +13,10 @@

1.1.0 (January 17, 2025)
- Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on `SplitView` type objects. Read more in our docs.
- Bugfixing - Updated @splitsoftware/splitio-commons package to version 2.1.0, which properly handles rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).
- Bugfix - Updated @splitsoftware/splitio-commons package to version 2.1.0, which properly handles rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).

1.0.1 (November 11, 2024)
- Bugfixing - Revert removal of TypeScript `SplitIO` namespace at `/types/splitio.d.ts` to allow explicit imports of types from the Browser SDK package. E.g., `import type { IClientSideSettings } from '@splitsoftware/splitio-browserjs/types/splitio';`.
- Bugfix - Revert removal of TypeScript `SplitIO` namespace at `/types/splitio.d.ts` to allow explicit imports of types from the Browser SDK package. E.g., `import type { IClientSideSettings } from '@splitsoftware/splitio-browserjs/types/splitio';`.

1.0.0 (November 1, 2024)
- Added support for targeting rules based on large segments.
Expand All @@ -33,8 +38,8 @@

0.14.1 (June 14, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.16.0 that includes some vulnerability and bug fixes.
- Bugfixing - Restored some input validation error logs that were removed in version 0.12.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
- Bugfixing - Fixed localhost mode to emit SDK_UPDATE when mocked feature flags are updated in the `features` object map of the config object (Related to issue https://github.com/splitio/javascript-browser-client/issues/119).
- Bugfix - Restored some input validation error logs that were removed in version 0.12.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
- Bugfix - Fixed localhost mode to emit SDK_UPDATE when mocked feature flags are updated in the `features` object map of the config object (Related to issue https://github.com/splitio/javascript-browser-client/issues/119).

0.14.0 (May 6, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.14.0 that includes minor updates:
Expand All @@ -44,7 +49,7 @@

0.13.2 (March 26, 2024)
- Updated some transitive dependencies for vulnerability fixes.
- Bugfixing - Added tslib as an explicit dependency to avoid issues with some package managers that don't resolve it automatically as a transitive dependency from @splitsoftware/splitio-commons (Related to issue https://github.com/splitio/javascript-client/issues/795).
- Bugfix - Added tslib as an explicit dependency to avoid issues with some package managers that don't resolve it automatically as a transitive dependency from @splitsoftware/splitio-commons (Related to issue https://github.com/splitio/javascript-client/issues/795).

0.13.1 (January 18, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.13.1 and some transitive dependencies for vulnerability fixes.
Expand All @@ -53,7 +58,7 @@
- Added support for Flag Sets in "consumer" and "partial consumer" modes (pluggable storage).
- Updated SDK cache for browsers using localStorage, to clear cached feature flag definitions before initiating the synchronization process if the cache was previously synchronized with a different SDK key (i.e., a different environment) or different Split Filter criteria, to avoid using invalid cached data when the SDK is ready from cache.
- Updated @splitsoftware/splitio-commons package to version 1.12.1 that includes flag sets support for consumer modes, and other improvements.
- Bugfixing - Fixed manager methods in consumer modes to return results in a promise when the SDK is not operational (not ready or destroyed).
- Bugfix - Fixed manager methods in consumer modes to return results in a promise when the SDK is not operational (not ready or destroyed).

0.12.0 (November 3, 2023)
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
Expand All @@ -80,7 +85,7 @@
- Updated some transitive dependencies for vulnerability fixes.
- Updated @splitsoftware/splitio-commons package to version 1.8.3 that includes:
- Updated SDK_READY_TIMED_OUT event to be emitted immediately when a connection error occurs using pluggable storage (i.e., when the wrapper `connect` promise is rejected) in consumer and partial consumer modes.
- Bugfixing - The `destroy` method has been updated to immediately flag the SDK client as destroyed, to prevent unexpected behaviors when `getTreatment` and `track` methods are called synchronously after `destroy` method is called.
- Bugfix - The `destroy` method has been updated to immediately flag the SDK client as destroyed, to prevent unexpected behaviors when `getTreatment` and `track` methods are called synchronously after `destroy` method is called.

0.9.5 (May 15, 2023)
- Updated @splitsoftware/splitio-commons package to version 1.8.2 that includes minor improvements.
Expand All @@ -90,18 +95,18 @@

0.9.4 (May 4, 2023)
- Updated some transitive dependencies for vulnerability fixes.
- Bugfixing - Updated `unfetch` package as a runtime dependency, required when using the "full" import (`import { SplitFactory } from '@splitsoftware/splitio-browserjs/full'`).
- Bugfix - Updated `unfetch` package as a runtime dependency, required when using the "full" import (`import { SplitFactory } from '@splitsoftware/splitio-browserjs/full'`).

0.9.3 (March 20, 2023)
- Updated @splitsoftware/splitio-commons package to version 1.8.1 that includes minor improvements.
- Updated some transitive dependencies for vulnerability fixes.

0.9.2 (December 16, 2022)
- Updated some transitive dependencies for vulnerability fixes.
- Bugfixing - Upgrade @splitsoftware/splitio-commons package to version 1.7.3 which includes a memory leak fix for localhost mode (Related to issue https://github.com/splitio/javascript-commons/issues/181) among other improvements.
- Bugfix - Upgrade @splitsoftware/splitio-commons package to version 1.7.3 which includes a memory leak fix for localhost mode (Related to issue https://github.com/splitio/javascript-commons/issues/181) among other improvements.

0.9.1 (October 14, 2022)
- Bugfixing - Upgrade @splitsoftware/splitio-commons package to version 1.7.2, that handles `Navigator.sendBeacon` API exceptions in the browser, and fallback to regular Fetch/XHR transport in case of error.
- Bugfix - Upgrade @splitsoftware/splitio-commons package to version 1.7.2, that handles `Navigator.sendBeacon` API exceptions in the browser, and fallback to regular Fetch/XHR transport in case of error.

0.9.0 (October 5, 2022)
- Added a new impressions mode for the SDK called NONE, to be used in factory when there is no desire to capture impressions on an SDK factory to feed Split's analytics engine. Running NONE mode, the SDK will only capture unique keys evaluated for a particular feature flag instead of full blown impressions.
Expand All @@ -118,23 +123,23 @@
- Added a new config option to control the tasks that listen or poll for updates on feature flags and segments, via the new config `sync.enabled`. Running online, Split will always pull the most recent updates upon initialization, this only affects updates fetching on a running instance. Useful when a consistent session experience is a must or to save resources when updates are not being used.
- Updated telemetry logic to track the anonymous config for user consent flag set to declined or unknown.
- Updated submitters logic, to avoid duplicating the post of impressions to Split cloud when the SDK is destroyed while its periodic post of impressions is running.
- Bugfixing - Updated submitters logic, to avoid dropping impressions and events that are being tracked while POST request is pending.
- Bugfix - Updated submitters logic, to avoid dropping impressions and events that are being tracked while POST request is pending.

0.6.0 (May 24, 2022)
- Added `scheduler.telemetryRefreshRate` property to SDK configuration.
- Updated SDK telemetry storage, metrics and updater to be more effective and send less often.
- Bugfixing - Updated default values for `scheduler.impressionsRefreshRate` config parameter: 300s for OPTIMIZED impression mode and 60s for DEBUG impression mode (previously it was 60s for both).
- Bugfix - Updated default values for `scheduler.impressionsRefreshRate` config parameter: 300s for OPTIMIZED impression mode and 60s for DEBUG impression mode (previously it was 60s for both).

0.5.0 (April 7, 2022)
- Added user consent feature to allow delaying or disabling the data tracking from SDK until user consent is explicitly granted or declined. Read more in our docs.
- Added `scheduler.impressionsQueueSize` property to SDK configuration to limit the amount of impressions tracked in memory. Read more in our docs.
- Updated format for MySegments keys in LocalStorage, keeping backwards compatibility (issue https://github.com/splitio/javascript-client/issues/638).
- Updated some dependencies for vulnerability fixes.
- Bugfixing - Updated internal isObject utility function, to avoid unexpected behaviors on frameworks and libraries that uses multiple VM contexts, like NuxtJS dev server.
- Bugfixing - Fixed validation of `core.key` SDK configuration param, to parse it into a string and log a warning when passing a number (Related to issue https://github.com/splitio/react-native-client/issues/19).
- Bugfixing - Fixed validation of `sync.impressionsMode` SDK configuration param, to avoid an exception on SplitFactory instantiation when passing a non-string value.
- Bugfixing - Fixed streaming synchronization issue when using multiple clients.
- Bugfixing - Fixed issue with internal Map ponyfill that results in logger not working properly on IE11 browser.
- Bugfix - Updated internal isObject utility function, to avoid unexpected behaviors on frameworks and libraries that uses multiple VM contexts, like NuxtJS dev server.
- Bugfix - Fixed validation of `core.key` SDK configuration param, to parse it into a string and log a warning when passing a number (Related to issue https://github.com/splitio/react-native-client/issues/19).
- Bugfix - Fixed validation of `sync.impressionsMode` SDK configuration param, to avoid an exception on SplitFactory instantiation when passing a non-string value.
- Bugfix - Fixed streaming synchronization issue when using multiple clients.
- Bugfix - Fixed issue with internal Map ponyfill that results in logger not working properly on IE11 browser.

0.4.1 (February 22, 2022)
- Updated karma and some transitive dependencies for vulnerability fixes.
Expand All @@ -150,7 +155,7 @@
- Updated @splitsoftware/splitio-commons dependency to version 1.1.0, which includes:
- Updated multiple modules due to general polishing and improvements, including the replacement of default exports with named exports,
to avoid runtime errors with some particular configurations of Webpack projects.
- Bugfixing - Fixed issue returning dynamic configs if treatment name contains a dot (".").
- Bugfix - Fixed issue returning dynamic configs if treatment name contains a dot (".").

0.2.0 (October 20, 2021)
- Added localhost mode support (Read more in our docs here: https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode).
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.

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.2.0",
"version": "1.2.1-rc.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.2.0",
"@splitsoftware/splitio-commons": "2.3.1-rc.0",
"tslib": "^2.3.1",
"unfetch": "^4.2.0"
},
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/browserSuites/fetch-specific-splits.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export default function fetchSpecificSplits(fetchMock, assert) {
const queryString = queryStrings[i] || '';
let factory;

fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.2&since=-1' + queryString, { status: 200, body: { splits: [], since: -1, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.2&since=1457552620999' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.2&since=1457552620999' + queryString, function () {
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.3&since=-1&rbSince=-1' + queryString, { status: 200, body: { splits: [], since: -1, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.3&since=1457552620999&rbSince=-1' + queryString, { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(urls.sdk + '/splitChanges?s=1.3&since=1457552620999&rbSince=-1' + queryString, function () {
factory.client().destroy().then(() => {
assert.pass(`splitFilters #${i}`);
});
return { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } };
return { status: 200, body: { ff: { d: [], s: 1457552620999, t: 1457552620999 } } };
});
fetchMock.get(urls.sdk + '/memberships/nicolas%40split.io', { status: 200, body: { 'ms': {} } });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export default function (fetchMock, assert) {

// Mock GET endpoints before creating the client
const settings = settingsFactory(config);
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=1457552620999'), { status: 200, body: { splits: [], since: 1457552620999, till: 1457552620999 } });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.getOnce(url(settings, `/memberships/${encodeURIComponent(config.core.key)}`), { status: 200, body: { ms: {} } });

// Init Split client
Expand Down
4 changes: 1 addition & 3 deletions src/__tests__/browserSuites/impressions.debug.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SplitFactory } from '../../';
import { settingsFactory } from '../../settings';
import splitChangesMock1 from '../mocks/splitchanges.since.-1.json';
import splitChangesMock2 from '../mocks/splitchanges.since.1457552620999.json';
import membershipsFacundo from '../mocks/memberships.facundo@split.io.json';
import { DEBUG } from '@splitsoftware/splitio-commons/src/utils/constants';
import { truncateTimeFrame } from '@splitsoftware/splitio-commons/src/utils/time';
Expand All @@ -24,8 +23,7 @@ let truncatedTimeFrame;

export default function (fetchMock, assert) {
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?s=1.2&since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/memberships/facundo%40split.io'), { status: 200, body: membershipsFacundo });

const splitio = SplitFactory({
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/browserSuites/impressions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ let truncatedTimeFrame;

export default function (fetchMock, assert) {
// Mocking this specific route to make sure we only get the items we want to test from the handlers.
fetchMock.getOnce(url(settings, '/splitChanges?s=1.2&since=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?s=1.2&since=1457552620999'), { status: 200, body: splitChangesMock2 });
fetchMock.getOnce(url(settings, '/splitChanges?s=1.3&since=-1&rbSince=-1'), { status: 200, body: splitChangesMock1 });
fetchMock.get(url(settings, '/splitChanges?s=1.3&since=1457552620999&rbSince=100'), { status: 200, body: splitChangesMock2 });
fetchMock.get(url(settings, '/memberships/facundo%40split.io'), { status: 200, body: membershipsFacundo });

const splitio = SplitFactory({
Expand Down
Loading