This product is not supported for your selected Datadog site. ().
Overview
This guide outlines the process for migrating your feature flagging logic from Statsig to Datadog Feature Flags. It covers conceptual mappings, SDK installation, initialization, and flag evaluation.
Summary checklist
Replace @statsig/js-client with @datadog/openfeature-browser.
Swap statsig.initialize with OpenFeature.setProviderAndWait.
Convert checkGate to client.getBooleanValue.
Convert getDynamicConfig to client.getObjectValue or client.getStringValue.
Convert getLayer to client.getObjectValue and dereference fields from the returned JSON object.
Use targetingKey in the context to identify users and drive percentage-based randomization.
Recreate your Statsig flags in Datadog.
For server-side apps, use @openfeature/server-sdk and pass a per-request evaluation context instead of a single global context.
Recreate flags in Datadog
Before you switch SDK calls in your application, recreate your Statsig gates, dynamic configs, and layers as flags in Datadog. In the Datadog UI, go to Software Delivery > Feature Flags and create flags that match your Statsig keys, variant types, and targeting rules.
Conceptual mapping
The core concepts between Statsig and Datadog are similar, but the terminology differs slightly.
Statsig Concept
Datadog Concept
Notes
Feature Gate
Feature Flag (Boolean)
Basic on/off toggles.
Dynamic Config
Feature Flag (JSON/String variants)
Flags in Datadog can return strings, JSON, or numbers, covering Statsig’s Dynamic Config use cases.
Layer
Feature Flag (JSON variant)
Use a JSON-valued flag and read fields from the returned object, similar to dereferencing values from a Statsig layer.
Experiment
Feature Flag (with targeting)
A Datadog flag can be configured with percentage-based rollouts and specific targeting rules to run experiments. Connect flags to Datadog Experiments to measure impact on user outcomes.
User/StatsigUser
Evaluation Context
The context (attributes) passed to the SDK to evaluate flags.
Installation
Datadog designs its feature flagging SDKs for use with OpenFeature. This provides a vendor-neutral API while using Datadog as the underlying provider.
You must replace the statsig.initialize() call with the OpenFeature provider setup. Pass the evaluation context to setProviderAndWait at registration time so flags are evaluated for the correct user from the start.
// Configure the Datadog provider
constprovider=newDatadogProvider({clientToken:'<CLIENT_TOKEN>',applicationId:'<APPLICATION_ID>',site:'datadoghq.com',// or datadoghq.eu, etc.
env:'production',// Environment from which to fetch flag configurations
});// Set the evaluation context and register the provider together
constevaluationContext={targetingKey:'user-123',// Identifies the user and drives percentage-based randomization
email:'employee@company.com',plan:'premium',};awaitOpenFeature.setProviderAndWait(provider,evaluationContext);
The targetingKey is used as the randomization subject for percentage-based targeting. When a flag targets a percentage of subjects (for example, 50%), the targetingKey determines which bucket a user falls into. Users with the same targetingKey always receive the same variant for a given flag.
For more information on creating client tokens and application IDs, see API and Application Keys.
Evaluate flags (check gates)
Replace checkGate calls with OpenFeature’s getBooleanValue.
Statsig (old)
constisEnabled=client.checkGate('new_homepage_design');if(isEnabled){// Show new design
}else{// Show old design
}
Datadog (new)
constclient=OpenFeature.getClient();// The second argument is the fallback value (default) if the flag fails to fetch
constisEnabled=client.getBooleanValue('new_homepage_design',false);if(isEnabled){// Show new design
}else{// Show old design
}
Get configuration (dynamic configs)
If you were using getDynamicConfig or getExperiment to retrieve non-Boolean values (strings, JSON, numbers), use the appropriate typed method in OpenFeature.
constclient=OpenFeature.getClient();// Assuming your Datadog flag 'banner_config' returns a JSON object variant
constbannerConfig=client.getObjectValue<{title: string}>('banner_config',{title:'Welcome'});consttitle=bannerConfig.title;
Map layers to JSON object flags
Statsig layers group related parameters under one evaluation. In Datadog, use a JSON-valued flag and read the fields you need from the returned object.
Statsig (old)
constlayer=client.getLayer('user_promo_experiments');constpromoTitle=layer.get('title','Welcome to Statsig!');constdiscount=layer.get('discount',0.1);
Statsig updates user context using updateUser. In OpenFeature and Datadog, update the context after initialization with OpenFeature.setContext(), for example after a user logs in.
// Update the context for all future flag evaluations
awaitOpenFeature.setContext({targetingKey:'user-456',// Identifies the user and drives percentage-based randomization
email:'employee@company.com',plan:'premium',});
Tracking and exposure
In Statsig, checking a gate automatically logs an exposure.
In Datadog, flag telemetry falls into two categories:
Exposure logging records that a subject received a specific flag variant. Each exposure event includes the flag key, variant served, and evaluation context. Use exposure data to analyze experiment results and feature adoption.
Evaluation logging records how often each variant is returned. Client SDKs send aggregated evaluation counts by default. Server SDKs emit the feature_flag.evaluations metric only after you enable evaluation logging.
Client SDKs: Exposure logging is enabled by default. The SDK sends exposure events to the exposures intake. You can view them in the Feature Flags list. Set enableExposureLogging: false in the DatadogProvider config if you do not need exposure tracking.
Setting enableRumFeatureFlagTracking to true can impact RUM costs, as it adds flag evaluations to RUM events. Both enableExposureLogging and enableRumFeatureFlagTracking are on by default for client SDKs.
Server SDKs: Exposure logging is on by default. Evaluation logging is off by default. To send evaluation metrics from server SDKs, enable OpenTelemetry metrics (for example, DD_METRICS_OTEL_ENABLED=true) and follow the language-specific guidance in Server-Side Feature Flags.
Server-side and dynamic context
The previous sections cover browser and client-side migration, where the evaluation context is typically static for the length of a user’s session. Server-side applications use a different SDK and authenticate with a Datadog API key instead of a client token. They also typically build a new evaluation context for each incoming request.
Configure the required environment variables before initializing the server SDK:
The browser SDK uses whatever evaluation context is set for every flag evaluation. You can update that context with OpenFeature.setContext() when the user logs in or their attributes change. The server SDK instead passes a new evaluation context into each flag evaluation call, since one process handles many different users.