@vtex/openfeature-featurehub-client
v0.0.30
Published
This project provides a FeatureHub provider for the OpenFeature SDK. It allows you to use FeatureHub as a feature flag management system with OpenFeature.
Maintainers
Keywords
Readme
FeatureHub Provider for OpenFeature
This project provides a FeatureHub provider for the OpenFeature SDK. It allows you to use FeatureHub as a feature flag management system with OpenFeature.
Getting Started
Prerequisites
- Node.js
- npm or yarn
Installation
- Install the dependencies:
npm install @vtex/openfeature-featurehub-clientUsage
To use the FeatureHub provider in your project, you need to import and set it as the provider for OpenFeature:
import { FeaturehubClientProvider } from "@vtex/openfeature-featurehub-client";
//or
const {
FeaturehubClientProvider,
} = require("@vtex/openfeature-featurehub-client");
const provider = new FeaturehubClientProvider();You can then use the OpenFeature API to evaluate feature flags:
const context = {
targetingKey: "mytargetingKey",
country: "Brazil",
account: "myaccount",
};
const booleanFlag = await provider.resolveBooleanEvaluation(
"booleanFlag",
true,
context
);
const stringFlag = await provider.resolveStringEvaluation(
"stringFlag",
"default",
context
);
const numberFlag = await provider.resolveNumberEvaluation(
"numberFlag",
0,
context
);
const jsonFlag = await provider.resolveObjectEvaluation(
"jsonFlag",
{ default: "value" },
context
);Environment Variables
Add to tag:
<meta name="featurehub-url" content="https://featurehub.url" />
<meta name="featurehub-apiKey" content="apiKey" />
<meta name="featurehub-interval" content="15000" />