Skip to content

Commit ba977bc

Browse files
Merge pull request #4 from splitio/development
Release v1.0.0
2 parents e230252 + f116e26 commit ba977bc

35 files changed

+8353
-3200
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @splitio/sdk

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: test
2+
on:
3+
pull_request:
4+
branches:
5+
- '*'
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build:
13+
name: Run tests
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 'lts/*'
23+
cache: 'npm'
24+
25+
- name: npm ci
26+
run: npm ci
27+
28+
- name: npm check
29+
run: npm run check
30+
31+
- name: npm test
32+
run: npm run test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ dist
105105

106106
# Build output
107107
es/
108-
lib/
108+
/lib/
109109
types/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

CHANGES.txt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
1.0.0
2-
- First release. Up to date with spec 0.4.0, and @openfeature/nodejs-sdk v0.2.0
3-
1.0.1
4-
- Fixes issues with flag details and error codes in negative cases, adds unit tests
5-
- Up to date with spec 0.4.0 and @openfeature/nodejs-sdk v0.3.2
6-
1.0.2
7-
- Changes name from Node-specific implementation to generic JSON
8-
- Up to date with spec 0.4.0 and @openfeature/js-sdk 0.4.0
9-
1.0.3
10-
- Adds types definitions for TypeScript
11-
- Up to date with spec 0.4.0 and @openfeature/js-sdk 0.4.0
12-
1.0.4
13-
- Fixes issue with TS build
14-
- Up to date with spec 0.5.0 and @openfeature/js-sdk 0.5.0
15-
1.1.0
16-
- Uses renamed @openfeature/js-sdk to @openfeature/server-sdk
17-
- Up to date with spec 0.8.0 and @openfeature/server-sdk 1.18.0
18-
- Uses split sdk 11.4.0
1+
1.0.0 (October 1, 2025)
2+
- First release.
3+
- Up to date with @openfeature/web-sdk v1.6.1, and @splitsoftware/splitio-browserjs 1.4.0

README.md

Lines changed: 73 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,97 @@
44
## Overview
55
This Provider is designed to allow the use of OpenFeature with Split, the platform for controlled rollouts, serving features to your users via the Split feature flag to manage your complete customer experience.
66

7-
## Compatibility
8-
9-
107
## Getting started
118
Below is a simple example that describes the instantiation of the Split Provider. Please see the [OpenFeature Documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api) for details on how to use the OpenFeature SDK.
129

1310
### Add the Split provider
1411

1512
```sh
16-
npm install @splitsoftware/openfeature-js-split-provider
13+
npm install @splitsoftware/openfeature-web-split-provider
1714
```
1815

1916
### Confirm peer dependencies are installed
2017
```sh
21-
npm install @splitsoftware/splitio
22-
npm install @openfeature/server-sdk
18+
npm install @splitsoftware/splitio-browserjs
19+
npm install @openfeature/web-sdk
2320
```
2421

25-
### Register the Split provider with OpenFeature
22+
### Register the Split provider with OpenFeature using splitFactory
2623
```js
27-
const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
28-
const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
29-
const OpenFeatureSplitProvider = require('@splitsoftware/openfeature-js-split-provider').OpenFeatureSplitProvider;
30-
31-
const authorizationKey = 'your auth key'
32-
const splitClient = SplitFactory({core: {authorizationKey}}).client();
33-
const provider = new OpenFeatureSplitProvider({splitClient});
34-
openFeature.setProvider(provider);
24+
import { OpenFeature } from '@openfeature/web-sdk';
25+
import { SplitFactory } from '@splitsoftware/splitio-browserjs';
26+
import { OpenFeatureSplitProvider } from '@splitsoftware/openfeature-web-split-provider';
27+
28+
const splitFactory = SplitFactory({
29+
core: {
30+
authorizationKey: 'your auth key'
31+
}
32+
});
33+
const provider = new OpenFeatureSplitProvider(splitFactory);
34+
OpenFeature.setProvider(provider);
3535
```
3636

3737
## Use of OpenFeature with Split
3838
After the initial setup you can use OpenFeature according to their [documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api/).
3939

4040
One important note is that the Split Provider **requires a targeting key** to be set. Often times this should be set when evaluating the value of a flag by [setting an EvaluationContext](https://docs.openfeature.dev/docs/reference/concepts/evaluation-context) which contains the targeting key. An example flag evaluation is
4141
```js
42-
const client = openFeature.getClient('CLIENT_NAME');
43-
4442
const context: EvaluationContext = {
4543
targetingKey: 'TARGETING_KEY',
44+
trafficType: 'account'
4645
};
47-
const boolValue = await client.getBooleanValue('boolFlag', false, context);
46+
OpenFeature.setContext(context)
4847
```
49-
If the same targeting key is used repeatedly, the evaluation context may be set at the client level
48+
49+
## Evaluate with details
50+
Use the get*Details(...) APIs to get the value and rich context (variant, reason, error code, metadata). This provider includes the Split treatment config as a raw JSON string under flagMetadata["config"]
51+
5052
```js
51-
const context: EvaluationContext = {
52-
targetingKey: 'TARGETING_KEY',
53-
};
54-
client.setEvaluationContext(context)
53+
const booleanTreatment = client.getBooleanDetails('boolFlag', false);
54+
55+
const config = booleanTreatment.flagMetadata.config;
5556
```
56-
or at the OpenFeatureAPI level
57+
58+
## Evaluate with attributes
59+
Evaluation attributes must be set in context before evaluation
60+
5761
```js
5862
const context: EvaluationContext = {
5963
targetingKey: 'TARGETING_KEY',
64+
trafficType: 'account',
65+
plan: 'premium',
66+
couppon: 'WELCOME10'
6067
};
61-
OpenFeatureAPI.getInstance().setCtx(context)
62-
````
63-
If the context was set at the client or api level, it is not required to provide it during flag evaluation.
68+
OpenFeature.setContext(context);
69+
const booleanTreatment = client.getBooleanDetails('boolFlag', false);
70+
```
71+
72+
## Tracking
73+
74+
To use track(eventName, context, details) you must provide:
75+
76+
- A non-blank `eventName`.
77+
- A context with:
78+
- `targetingKey` (non-blank).
79+
- `trafficType` (string, e.g. "user" or "account", "user" by default).
6480

81+
Optional:
82+
83+
- details with:
84+
- `value`: numeric event value (defaults to 0).
85+
- `properties`: map of attributes (prefer primitives: string/number/boolean/null).
86+
87+
Example:
88+
```js
89+
const context = { targetingKey: 'user-123', trafficType: 'account' }
90+
const details = { value: 19.99, properties: { plan: 'pro', coupon: 'WELCOME10' }}
91+
92+
client.setEvaluationContext(context)
93+
client.track('checkout.completed', details)
94+
```
6595
## Submitting issues
6696

67-
The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/split-openfeature-provider-nodejs/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
97+
The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/split-openfeature-provider-web-js/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
6898

6999
## Contributing
70100
Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to submit a Pull Request (PR).
@@ -80,16 +110,24 @@ To learn more about Split, contact hello@split.io, or get started with feature f
80110

81111
Split has built and maintains SDKs for:
82112

83-
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
84-
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
85-
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
86113
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
87-
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
88-
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
89-
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
90-
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
91114
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
115+
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
116+
* Elixir thin-client [Github](https://github.com/splitio/elixir-thin-client) [Docs](https://help.split.io/hc/en-us/articles/26988707417869-Elixir-Thin-Client-SDK)
117+
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
118+
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
92119
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
120+
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
121+
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
122+
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
123+
* Node.js [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
124+
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
125+
* PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK)
126+
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
127+
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
128+
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
129+
* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
130+
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
93131

94132
For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
95133

eslint.config.mts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import tseslint from "typescript-eslint";
4+
import { defineConfig } from "eslint/config";
5+
import jestPlugin from 'eslint-plugin-jest';
6+
7+
export default defineConfig([
8+
{
9+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
10+
plugins: { js },
11+
extends: ["js/recommended"],
12+
languageOptions: { globals: globals.browser },
13+
rules: {
14+
semi: ["error", "always"],
15+
}
16+
},
17+
{
18+
files: ['**/*.{test,spec}.{js,ts,jsx,tsx}', '**/__tests__/**/*.{js,ts,jsx,tsx}'],
19+
plugins: { jest: jestPlugin },
20+
rules: {
21+
...jestPlugin.configs.recommended.rules,
22+
},
23+
languageOptions: {
24+
globals: {
25+
...globals.jest,
26+
},
27+
},
28+
},
29+
tseslint.configs.recommended,
30+
]);

jest.config.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
module.exports = {
2-
displayName: 'js-split-provider',
3-
preset: '../../jest.preset.js',
1+
export default {
2+
displayName: 'openfeature-web-split-provider',
3+
testEnvironment: 'jsdom',
4+
testMatch: ['**/*.spec.js', '**/integration/*.test.js'],
45
globals: {
56
'ts-jest': {
6-
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
tsconfig: '<rootDir>/tsconfig.json',
78
},
89
},
910
transform: {
10-
'^.+\\.[tj]s$': 'ts-jest',
11+
'^.+\\.[tj]sx?$': 'ts-jest',
1112
},
12-
moduleFileExtensions: ['ts', 'js', 'html'],
13-
coverageDirectory: '../../coverage/packages/js-split-provider',
13+
transformIgnorePatterns: [
14+
'node_modules/(?!(fetch-mock)/)'
15+
],
16+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
17+
coverageDirectory: './coverage',
1418
};

0 commit comments

Comments
 (0)