Node provider
Get Started
An OpenFeature Provider is a pluggable integration layer that connects the OpenFeature SDK to a specific feature flag management system (e.g., VWO or custom in-house solutions). OpenFeature is an open-source standard for feature flagging, designed to provide a vendor-agnostic approach, enabling organizations to switch between feature flagging tools without rewriting application code.
This VWO Openfeature Provider for Node helps you integrate feature management and experimentation systems within your Node.js based server applications.
Resource | Link |
---|---|
GitHub repository | https://github.com/wingify/vwo-openfeature-provider-node |
Published on | https://www.npmjs.com/package/vwo-openfeature-provider-node |
Openfeature Java docs | https://openfeature.dev/docs/reference/technologies/server/javascript/ |
Please Note
This library is intended to be used in server-side contexts and has not been evaluated for use on mobile devices.
Requirements
Node.js 10+
SDK Installation
# via npm
npm install vwo-openfeature-provider-node --save
# via yarn
yarn add vwo-openfeature-provider-node
Usage
const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
const VWOProvider = require('vwo-openfeature-provider-node').VWOProvider;
const vwo = require('vwo-fme-node-sdk');
async function start() {
const vwoClient = await vwo.init({
sdkKey: '<enter-vwo-sdk-key-here>',
accountId: '<vwo-account-id>'
});
const context = {
user: {
id: 'unique-user-id',
},
};
const provider = new VWOProvider(vwoClient);
OpenFeature.setProvider(provider);
const newClient = OpenFeature.getClient();
newClient.setContext(context);
console.log(
'BOOLEAN',
await newClient.getBooleanValue(
'unique-feature-key',
false,
Object.assign({}, context, { key: 'boolean_variable' }),
),
); //pass 'key' if you want to fetch value of a specific variable. Otherwise it will return feature on/off
console.log(
'STRING',
await newClient.getStringValue('unique-feature-key', '', Object.assign({}, context, { key: 'string-variable' })),
); //will return undefined without key
console.log(
'NUMERIC',
await newClient.getNumberValue('unique-feature-key', 10, Object.assign({}, context, { key: 'number-variable' })),
); //will return undefined without key
console.log(
'FLOAT',
await newClient.getNumberValue('unique-feature-key', 10.0, Object.assign({}, context, { key: 'float-variable' })),
); //will return undefined without key
console.log(
'JSON',
await newClient.getObjectValue('unique-feature-key', {}, Object.assign({}, context, { key: 'json-variable' })),
); //pass 'key' if you want to fetch value of a specific variable of type JSON. Otherwise it will return all the variables.
}
start();
Updated about 18 hours ago