A Node.js-specific feature flag management package for WorkTango applications, built on top of DevCycle and OpenFeature.
npm install @worktango/feature-flags-node
import {
initializeFeatureFlagProvider,
getBooleanFlagValue,
getOpenFeatureClient,
} from '@worktango/feature-flags-node';
// Initialize with your DevCycle SDK key
await initializeFeatureFlagProvider({
sdkKey: 'your-devcycle-sdk-key',
options: {
disableAutomaticEventLogging: true,
configPollingIntervalMS: 5 * 1000,
eventFlushIntervalMS: 1000,
},
});
// Get boolean feature flag value with user context
const isEnabled = await getBooleanFlagValue('my-feature', false, userContext);
import { getOpenFeatureClient } from '@worktango/feature-flags-node';
// Set user context for feature flag evaluation
// Note: Custom data should be placed under privateCustomData
const userContext = {
user_id: 'user123',
email: 'user@example.com',
privateCustomData: {
companyId: 123,
isAdmin: true,
},
};
const client = getOpenFeatureClient();
await client.setContext(userContext);
-
FeatureFlagConfig
: Interface for feature flag configurationinterface FeatureFlagConfig { sdkKey: string; options?: DevCycleOptionsLocalEnabled; // Optional DevCycle configuration strictMode?: boolean; // Optional: When enabled (default: false), will throw an error if the Feature Flag Provider/Client is not properly configured. // When disabled, will only log a warning if the Provider/Client is not correctly configured. }
-
initializeFeatureFlagProvider(config: FeatureFlagConfig)
: Initialize the feature flag provider with DevCycle -
getBooleanFlagValue(flag: string, defaultValue: boolean, context?: FeatureFlagUser, options?: FlagEvaluationOptions)
: Get boolean feature flag value -
getOpenFeatureClient()
: Get the OpenFeature client for additional flag types (string, number) -
getFeatureFlagProvider()
: Get the DevCycle provider instance -
getFeatureFlagClient()
: Get the DevCycle client instance
-
ANONYMOUS_FEATURE_FLAG_USER
: Default anonymous user context