Skip to content

Commit 6086084

Browse files
Merge pull request #16 from splitio/development
release v1.1.0
2 parents 709a49b + c579174 commit 6086084

24 files changed

+8492
-466
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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: Install Redis
20+
run: |
21+
sudo add-apt-repository ppa:redislabs/redis
22+
sudo apt-get install -y redis-tools redis-server
23+
24+
- name: Check Redis
25+
run: redis-cli ping
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 'lts/*'
31+
cache: 'npm'
32+
33+
- name: npm ci
34+
run: npm ci
35+
36+
- name: npm check
37+
run: npm run check
38+
39+
- name: npm test
40+
run: npm run test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8+
dump.rdb
89

910
# Diagnostic reports (https://nodejs.org/api/report.html)
1011
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

.nvmrc

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

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-json
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace

CHANGES.txt

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
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
1+
1.1.0 (September 12, 2025)
2+
- Updated @openfeature/server-sdk to 1.19.0
3+
- Updated @splitsoftware/splitio to 11.4.1
4+
- Added support for tracking feature
5+
- Added support for evaluate with details feature
6+
- Added support for provider initialization using splitFactory and apiKey
7+
- Replace @openfeature/js-sdk with @openfeature/server-sdk
8+
129
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
10+
- Fixes issue with TS build
11+
- Up to date with spec 0.5.0 and @openfeature/js-sdk 0.5.0
12+
13+
1.0.3
14+
- Adds types definitions for TypeScript
15+
- Up to date with spec 0.4.0 and @openfeature/js-sdk 0.4.0
16+
17+
1.0.2
18+
- Changes name from Node-specific implementation to generic JSON
19+
- Up to date with spec 0.4.0 and @openfeature/js-sdk 0.4.0
20+
21+
1.0.1
22+
- Fixes issues with flag details and error codes in negative cases, adds unit tests
23+
- Up to date with spec 0.4.0 and @openfeature/nodejs-sdk v0.3.2
24+
25+
1.0.0
26+
- First release. Up to date with spec 0.4.0, and @openfeature/nodejs-sdk v0.2.0

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright © 2022 Split Software, Inc.
1+
Copyright © 2025 Split Software, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

README.md

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
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

77
## Compatibility
8+
It supports **Node.js version 14.x or later**.
89

910

1011
## Getting started
@@ -19,19 +20,41 @@ npm install @splitsoftware/openfeature-js-split-provider
1920
### Confirm peer dependencies are installed
2021
```sh
2122
npm install @splitsoftware/splitio
22-
npm install @openfeature/js-sdk
23+
npm install @openfeature/server-sdk
2324
```
2425

25-
### Register the Split provider with OpenFeature
26+
### Register the Split provider with OpenFeature using sdk apiKey
2627
```js
27-
const OpenFeature = require('@openfeature/js-sdk').OpenFeature;
28+
const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
29+
const OpenFeatureSplitProvider = require('@splitsoftware/openfeature-js-split-provider').OpenFeatureSplitProvider;
30+
31+
const authorizationKey = 'your auth key'
32+
const provider = new OpenFeatureSplitProvider(authorizationKey);
33+
OpenFeature.setProvider(provider);
34+
```
35+
36+
### Register the Split provider with OpenFeature using splitFactory
37+
```js
38+
const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
39+
const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
40+
const OpenFeatureSplitProvider = require('@splitsoftware/openfeature-js-split-provider').OpenFeatureSplitProvider;
41+
42+
const authorizationKey = 'your auth key'
43+
const splitFactory = SplitFactory({core: {authorizationKey}});
44+
const provider = new OpenFeatureSplitProvider(splitFactory);
45+
OpenFeature.setProvider(provider);
46+
```
47+
48+
### Register the Split provider with OpenFeature using splitClient
49+
```js
50+
const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
2851
const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
2952
const OpenFeatureSplitProvider = require('@splitsoftware/openfeature-js-split-provider').OpenFeatureSplitProvider;
3053

3154
const authorizationKey = 'your auth key'
3255
const splitClient = SplitFactory({core: {authorizationKey}}).client();
3356
const provider = new OpenFeatureSplitProvider({splitClient});
34-
openFeature.setProvider(provider);
57+
OpenFeature.setProvider(provider);
3558
```
3659

3760
## Use of OpenFeature with Split
@@ -59,9 +82,40 @@ const context: EvaluationContext = {
5982
targetingKey: 'TARGETING_KEY',
6083
};
6184
OpenFeatureAPI.getInstance().setCtx(context)
62-
````
85+
```
6386
If the context was set at the client or api level, it is not required to provide it during flag evaluation.
6487

88+
## Evaluate with details
89+
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"]
90+
91+
```js
92+
const booleanTreatment = await client.getBooleanDetails('boolFlag', false, context);
93+
94+
const config = booleanTreatment.flagMetadata.config
95+
```
96+
97+
## Tracking
98+
99+
To use track(eventName, context, details) you must provide:
100+
101+
- A non-blank `eventName`.
102+
- A context with:
103+
- `targetingKey` (non-blank).
104+
- `trafficType` (string, e.g. "user" or "account").
105+
106+
Optional:
107+
108+
- details with:
109+
- `value`: numeric event value (defaults to 0).
110+
- `properties`: map of attributes (prefer primitives: string/number/boolean/null).
111+
112+
Example:
113+
```js
114+
const context = { targetingKey: 'user-123', trafficType: 'account' }
115+
const details = { value: 19.99, plan: 'pro', coupon: 'WELCOME10' }
116+
117+
client.track('checkout.completed', context, details)
118+
```
65119
## Submitting issues
66120

67121
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.
@@ -80,16 +134,24 @@ To learn more about Split, contact [email protected], or get started with feature f
80134

81135
Split has built and maintains SDKs for:
82136

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)
86137
* .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)
91138
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
139+
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
140+
* 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)
141+
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
142+
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
92143
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
144+
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
145+
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
146+
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
147+
* Node.js [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
148+
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
149+
* 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)
150+
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
151+
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
152+
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
153+
* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
154+
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
93155

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

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+
8+
export default defineConfig([
9+
{
10+
files: ["**/*.{js,ts}"],
11+
plugins: { js },
12+
extends: ["js/recommended"],
13+
languageOptions: {
14+
globals: globals.browser
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: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
module.exports = {
22
displayName: 'js-split-provider',
3-
preset: '../../jest.preset.js',
4-
globals: {
5-
'ts-jest': {
6-
tsconfig: '<rootDir>/tsconfig.spec.json',
7-
},
8-
},
3+
preset: 'ts-jest',
4+
5+
// Test files are .js and .ts files inside of __tests__ folders and with a suffix of .test or .spec
6+
testMatch: ['<rootDir>/src/**/__tests__/**/?(*.)+(spec|test).[jt]s'],
7+
8+
// Included files for test coverage (npm run test:coverage)
9+
collectCoverageFrom: [
10+
'src/**/*.{js,ts}',
11+
'!src/**/__tests__/**',
12+
'!src/**/*.d.ts'
13+
],
14+
915
transform: {
1016
'^.+\\.[tj]s$': 'ts-jest',
1117
},

0 commit comments

Comments
 (0)