Overview
This developer guide will assist you in configuring your server-side Node.js platform for Feature Flags using the Mixpanel Node.js SDK. Feature Flags allow you to control the rollout of your features, conduct A/B testing, and manage application behavior without deploying new code.
Prerequisites
Before implementing Feature Flags, ensure:
Flag Evaluation Scenarios
There are two scenarios available for using the Node.js SDK for feature flagging: Local Evaluation and Remote Evaluation.
For local evaluation, the SDK will poll Mixpanel servers for feature flag configurations. Assignment of user contexts to variants will be done locally within the SDK. This mode is recommended for low latency since there is no network call made at assignment time.
For remote evaluation, the SDK will make a network call to Mixpanel servers at assignment time. This mode is recommended for use cases where you want to leverage Mixpanel cohorts for user targeting or sticky variants for persistent variant assignments.
In either case there is also the capability to evaluate all flags for a given user context at once, to avoid needing to make multiple calls to get individual flag variants for the same user. This is particularly useful for remote evaluation to avoid incurring additional network calls.
Local Evaluation
Support for runtime targeting has not yet been released. Thus runtime rules other than a single-condition, exact match key-value pair, will ALWAYS be evaluated to true.
Targeting by Mixpanel cohorts and sticky variants are not supported in Local Evaluation mode.
-
The SDK is configured with a
local_flags_config object that specifies parameters:
api_host - If your project is in the EU/IN region, this should be set to route to api-eu.mixpanel.com/api-in.mixpanel.com respectively.
enable_polling - This should be set to true to enable polling for new flag configurations.
polling_interval_in_seconds - This is the interval in seconds at which the SDK will poll Mixpanel servers for feature flag configurations.
-
The SDK will continue to poll for the lifetime of the SDK instance or until stopped.
Remote Evaluation
- The SDK is configured with a
remote_flags_config object to use remote evaluation.
Suppress automatic exposure tracking
To suppress automatic exposure tracking, pass false as the optional 4th parameter, then manually call trackExposureEvent when you’re ready to expose the user to the variant. This applies to both local and remote evaluation.
Evaluate all flags at once
Below is a remote evaluation sample of evaluating all flags for a given user context at once.