Skip to main content

OpenFeature Provider for Node.js SDK

Integrate your Node.js applications with Harness FME using the Node.js OpenFeature ProviderAn OpenFeature Provider wraps the Harness FME SDK, acting as a bridge between the OpenFeature SDK and the FME SDK. It translates OpenFeature function calls into operations handled by the FME SDK, which communicates with Harness services to evaluate flags and retrieve configuration updates., a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME Node.js SDK.

This page walks you through installing, configuring, and using the Node.js OpenFeature provider to evaluate feature flagsA feature flag is a conditional toggle in Harness FME that enables or disables specific functionality without deploying new code. It allows for controlled feature rollouts, A/B testing, and quick rollbacks if issues arise. in your Node.js applications.

Prerequisites

Before you begin, ensure you have the following:

  • A valid Harness FME SDK key for your project
  • A Node.js environment running version 14.x or later
  • Access to npm or yarn to install dependencies

Version compatibility

ComponentMinimum Version
Node.js14.x+
@splitsoftware/openfeature-js-split-provider≥ 1.0.0
OpenFeature Node.js SDK≥ 1.0.0

Install the provider and dependencies

Install the Harness FME OpenFeature provider and required peer dependencies:

npm install @splitsoftware/openfeature-js-split-provider
npm install @splitsoftware/splitio
npm install @openfeature/server-sdk

Initialize the provider

You can register the provider with OpenFeature in one of several ways, depending on your setup.

If you are using an SDK API key:

const OpenFeature = require('@openfeature/server-sdk').OpenFeature;
const OpenFeatureSplitProvider = require('@splitsoftware/openfeature-js-split-provider').OpenFeatureSplitProvider;

const authorizationKey = '<YOUR_AUTH_KEY>'
const provider = new OpenFeatureSplitProvider(authorizationKey);
OpenFeature.setProvider(provider);

Construct an evaluation context

Provide an evaluation contextThe Evaluation Context holds contextual information used during flag evaluation. It can include static data (like application or host identifiers) and dynamic data (such as a client IP address), which can be passed explicitly or propagated automatically. Static and dynamic values can be merged for richer, more targeted evaluations. with a targeting keyA unique identifier used to target specific users or entities when evaluating feature flags. It helps determine which variation of a flag should be served based on predefined rules and conditions. to evaluate flags. The evaluation context passes targeting information such as user IDs, email addresses, or plan types for flag targeting.

For example:

const client = openFeature.getClient('<CLIENT_NAME>');

const context: EvaluationContext = {
targetingKey: '<TARGETING_KEY>',
};
const boolValue = await client.getBooleanValue('boolFlag', false, context);

If the same targeting key is reused across evaluations, set the context at the client level:

const context: EvaluationContext = {
targetingKey: '<TARGETING_KEY>',
};
client.setEvaluationContext(context)

Or at the API level:

const context: EvaluationContext = {
targetingKey: '<TARGETING_KEY>',
};
OpenFeatureAPI.getInstance().setCtx(context)

Once the context is set at the client or API level, you don't need to provide it for each evaluation.

Evaluate with details

Use the get*Details(...) APIs to get flag values and metadata (such as variant, reason, error code, and configuration). The FME treatment configuration is returned as a raw JSON string under flagMetadata["config"].

For example:

const booleanTreatment = await client.getBooleanDetails('boolFlag', false, context);
const config = booleanTreatment.flagMetadata.config

Track events

The Harness FME OpenFeature provider supports tracking user actions or conversion eventsEvents allow your application to respond to changes in provider state or flag configuration, such as readiness changes, errors, or updates to flag values. directly from your Node.js application.

To enable event tracking, your evaluation context must include the following:

  • A non-empty targetingKey
  • A trafficType (for example, "user" or "account")
  • A non-blank event name

Optionally, you can include a numeric value (defaults to 0) and additional event properties (prefers primitives such as string, number, boolean, or null). For more information, see Sending Events.

For example:

const context = { targetingKey: 'user-123', trafficType: 'account' }
const details = { value: 19.99, plan: 'pro', coupon: 'WELCOME10' }

client.track('checkout.completed', context, details)

For more information, go to the Harness FME Node.js OpenFeature Provider GitHub repository.