Quick-start

Installation

Refer to the installation page for installation steps.

Getting started

Below is a simple example that describes the instantiation of the AB Tasty Provider. Please see the OpenFeature Documentation for details on how to use the OpenFeature SDK.

Add the AB Tasty provider

npm install @flagship-io/openfeature-provider-js

Confirm peer dependencies are installed

npm install @openfeature/server-sdk

Register the AB Tasty provider with OpenFeature

const { ABTastyProvider } = require("@flagship.io/openfeature-provider-js");
const { OpenFeature } = require("@openfeature/server-sdk");
const provider = new ABTastyProvider("<ENV_ID>", "<API_KEY>");
await OpenFeature.setProviderAndWait(provider);

Use of OpenFeature with AB Tasty

After the initial setup you can use OpenFeature according to their documentation.

⚠️ The AB Tasty 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 which contains the targeting key.

An example flag evaluation

Server environment

⚠️ When running your server in a TypeScript environment, it's essential to call setProviderAndWait within each endpoint to ensure that every request creates a new visitor context with up-to-date feature flag values. This method initializes a new visitor—using the provided targeting key and any additional context—and fetches the latest flag configurations before any flag evaluations occur. Without this step, subsequent requests might operate on outdated visitor data, leading to inconsistent or stale flag evaluations. For more information, please refers to our JS SDK documentation.

An example of this implementation

Last updated

Was this helpful?