JavaScript implementation of the Confidence OpenFeature web provider, to be used in conjunction wth the OpenFeature JS SDK. This implements the dynamic paradigm of OpenFeature.
To add the packages to your dependencies run:
yarn add @openfeature/server-sdk @spotify-confidence/openfeature-server-provider @openfeature/core
import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider';
import { OpenFeature } from '@openfeature/server-sdk';
const provider = createConfidenceServerProvider({
clientSecret: 'your-client-secret',
fetchImplementation: fetch,
timeout: 1000,
});
OpenFeature.setProvider(provider);
const client = OpenFeature.getClient();
client
.getBooleanValue('flagName.bool', false, {
targetingKey: `your targeting key`,
})
.then(result => {
console.log('result:', result);
});
The region option is used to set the region for the network request to the Confidence backend. When the region is not set, the default (global) region will be used.
The current regions are: eu
and us
, the region can be set as follows:
const provider = createConfidenceServerProvider({
region: 'eu', // or 'us'
// ... other options
});
The timeout option is used to set the timeout for the network request to the Confidence backend. When the timeout is reached, default values will be returned.
See apply concept.
Backend apply is the only supported method in the ConfidenceServerProvider
.