Skip to content

Migrate from Statsig

featureflip import statsig, part of the featureflip CLI from version 0.3.0, copies a Statsig project’s configuration into Featureflip. That still leaves your code, which calls checkGate and getConfig in every service, and the switch itself, which should happen without a single user noticing. This guide covers the import and then both of those.

What moves: feature gates become boolean flags, dynamic configs become JSON flags, and segments stay segments. Rules, environments, overrides and rollout percentages come with them. Experiments, layers, holdouts and autotunes stay behind. The last section lists everything the importer refuses and why.

The importer reads your project through Statsig’s Console API, which takes a Console key. Server and client SDK keys won’t work here. In Statsig, open Project Settings, then Keys & Environments, and create a Console API key, where read-only is enough because the importer never writes anything back to Statsig.

Terminal window
export STATSIG_CONSOLE_API_KEY=console-...
Terminal window
featureflip import statsig

A dry run reads everything, translates it and prints a report. It writes nothing on either side, so it needs no Featureflip token, and you can run it as often as you like while you clean up the Statsig side. Add --json for the same report as one JSON document, with the translated project included.

Statsig environment names become Featureflip environment keys. When your Featureflip project names them differently, map them:

Terminal window
featureflip import statsig --env-map development=dev,production=prod

A report starts with the environment mapping and a count, then lists problems in three groups:

Statsig import: dry run, nothing was written.
Environments
development -> development
production -> production
Flags 24 read: 21 ready (4 with warnings), 3 blocked
Segments 4 read: 3 ready, 1 blocked
Blocked: these are not imported
segment partial: rule "Half" includes only 50% of matching users; Featureflip segments include all of them
flag gate_on_gate: rule "Needs public": it checks another gate (passes_gate), which has no Featureflip equivalent
flag Launched Gate: Statsig marks it Launched, and the Console API doesn't say what a launched gate serves. Recreate it by hand, or remove it from your code if the launch is done
Warnings: imported, but check these
flag Dup Key: imported with the key "dup-key", so the code that reads "Dup Key" must use the new key
flag rollout_gate: rule "Fraction": its 33.33% rollout is imported as 33%; Featureflip rollouts are whole percentages
flag fancy_conditions: rule "Mixed": Statsig fills "country" from the request's IP address when the app doesn't send it; Featureflip reads only what your app puts in the context
flag stable_gate: it is in a Statsig holdout, which is not imported: held-out users will get the flag
Notes
Skipped the archived gate "old_gate".
Experiments, layers, holdouts and autotunes are not read. Only feature gates, dynamic configs and segments are imported.
Rollouts keep their percentage but not their membership: Featureflip buckets users with its own hash, so a 30% rollout reaches a different 30%.
Context attributes the imported rules read (your evaluation context must carry them):
user_id, companyID, country, email, plan
  • Blocked items would behave differently in Featureflip, so the importer leaves them out. Each line says why. Most can be fixed in Statsig. Some need recreating by hand.
  • Warnings import, but each one asks something of you. A renamed key means the code reading it changes. A derived attribute means your app has to start sending it.
  • Notes record what was skipped on purpose and how a value was read.

The report’s last line names every context attribute the imported rules read, and your evaluation context has to carry each of them. The SDK section shows how.

When the report reads the way you want, write it to a Featureflip project. This step does need a Featureflip token (see Sign in) with the Member role or higher:

Terminal window
featureflip import statsig --env-map production=prod --project web --apply

Each environment you import has to exist in the Featureflip project already, and the importer stops before writing anything if one is missing and lists the environments the project does have.

Apply keeps your live traffic safe by default:

  • Every flag arrives off. Nothing serves until you turn it on. Pass --carry-state to turn each flag on wherever it is on in Statsig. A disabled gate arrives off either way.
  • Existing items are left alone. A flag or segment that already exists with other targeting is reported as differing and stays as it is. Pass --overwrite to replace it.
  • Re-running is safe. Items that already match are unchanged, so running the same import twice writes nothing the second time.
  • Flags are server-side only. Statsig serves every gate to its client SDKs. Featureflip serves a flag to browser and mobile SDKs only once it is marked client-side. Pass --client-side to mark every created flag, or mark the ones your apps read in the dashboard.

The importer checks your plan’s flag cap first. It asks you to type the environment key before it changes live flags in an environment that requires confirmation, the same way flags on does. It waits out the API’s rate limit on a big project and prints each wait. Its writes record the change reason “Imported from Statsig with featureflip import” in the audit log, or the reason you pass with --reason.

Each server SDK keeps the shape you already know: a flag key, a context and a default. Three things change.

  1. checkGate(user, "x") becomes a boolean variation. It returns the gate’s value, or your default when the flag can’t be evaluated.
  2. getConfig(user, "x").get("field", fallback) becomes a JSON variation. It returns the whole config value as an object, and you read the field from it.
  3. StatsigUser becomes the evaluation context, a flat set of attributes.

The context mapping works like this:

StatsigUserFeatureflip context
userIDuser_id
email, country, locale, appVersionthe same names
custom.planplan, at the top level
customIDs.companyIDcompanyID, named after the unit type
customIDs.stableIDstableID

Unit types matter for rollouts. A gate with the unit type companyID buckets by the companyID attribute, so a context without that attribute skips the rollout. Gate keys stay as they were unless the report says they were renamed. Statsig allows spaces and capitals in an ID, and Featureflip keys are lowercase letters, digits, - and _.

The examples below read the gate new_checkout and the field max_items from the dynamic config checkout_config, for a user on a company account.

Node.js
const context = {
user_id: 'u-123',
email: 'ana@example.com',
plan: 'pro', // was custom.plan
companyID: 'c-9', // was customIDs.companyID
};
const newCheckout = client.boolVariation('new_checkout', context, false);
const config = client.jsonVariation('checkout_config', context, { max_items: 10 });
const maxItems = config.max_items;
Python
context = {"user_id": "u-123", "email": "ana@example.com", "plan": "pro", "companyID": "c-9"}
new_checkout = client.variation("new_checkout", context, default=False)
config = client.variation("checkout_config", context, default={"max_items": 10})
max_items = config["max_items"]
Go
ctx := featureflip.EvaluationContext{
UserID: "u-123",
Attributes: map[string]any{"email": "ana@example.com", "plan": "pro", "companyID": "c-9"},
}
newCheckout := client.BoolVariation("new_checkout", ctx, false)
config := client.JSONVariation("checkout_config", ctx, map[string]any{"max_items": 10})
maxItems := config.(map[string]any)["max_items"]
Java
EvaluationContext context = EvaluationContext.builder("u-123")
.set("email", "ana@example.com")
.set("plan", "pro")
.set("companyID", "c-9")
.build();
boolean newCheckout = client.boolVariation("new_checkout", context, false);
CheckoutConfig config = client.jsonVariation("checkout_config", context, new CheckoutConfig(10), CheckoutConfig.class);
int maxItems = config.maxItems;
C#
var context = new EvaluationContext { UserId = "u-123", Email = "ana@example.com" };
context.Set("plan", "pro");
context.Set("companyID", "c-9");
bool newCheckout = client.BoolVariation("new_checkout", context, false);
var config = client.JsonVariation("checkout_config", context, new CheckoutConfig { MaxItems = 10 });
int maxItems = config.MaxItems;
Ruby
context = { user_id: "u-123", email: "ana@example.com", plan: "pro", companyID: "c-9" }
new_checkout = client.bool_variation("new_checkout", context, false)
config = client.json_variation("checkout_config", context, { "max_items" => 10 })
max_items = config["max_items"]
PHP
$context = ['user_id' => 'u-123', 'email' => 'ana@example.com', 'plan' => 'pro', 'companyID' => 'c-9'];
$newCheckout = $client->boolVariation('new_checkout', $context, false);
$config = $client->jsonVariation('checkout_config', $context, ['max_items' => 10]);
$maxItems = $config['max_items'];

On Cloudflare Workers, the edge SDK takes the same calls on the snapshot it loads per request: snapshot.boolVariation(...) and snapshot.jsonVariation(...). Client setup for each language is on its SDK reference page.

Statsig fills some user fields on its own servers. It reads country from the request’s IP address, and the OS name and version, browser name and version and device model from the user agent. Featureflip evaluates only what your app puts in the context, so a rule on country that worked in Statsig without your code sending a country will match nobody in Featureflip.

The report flags each rule that reads one of these, and the attribute list at the end of the report includes them. For each one, decide where the value comes from. Country often comes from a CDN header (Cloudflare sends CF-IPCountry) or from the user’s billing record. OS and browser come from parsing the user agent with the library you already use for analytics.

Two more value formats can surprise you:

  • Dates. Featureflip reads a date attribute as an ISO 8601 string or Unix seconds. Statsig apps usually send milliseconds. The importer converts the dates in your rules, but your app has to send seconds or ISO strings from now on.
  • Versions. Featureflip compares versions as full semantic versions (1.2.0). A rule written against 1.2 gets a warning, and the context should send three parts.

Matching is also looser in a couple of places. Featureflip compares strings in lists without regard to case, so a Statsig condition marked case-sensitive gets a warning, and ID lists match case-insensitively too.

Featureflip buckets users with its own hash, so a gate at 30% in Statsig reaches 30% in Featureflip, but not the same 30%. Some users who had the feature lose it, and others get it for the first time.

You have three ways to handle that:

  • Cut over at 0% or 100%. Finish the rollout in Statsig or roll it back before you switch. A gate fully on or fully off moves with no change for anyone.
  • Accept the reshuffle. A faster search index can change hands without anyone noticing. A redesigned checkout page can’t.
  • Restart the rollout. Import it at 0% and ramp it again in Featureflip with a rollout ramp. Statsig’s scheduled rollout steps aren’t imported, so this is also how you get the schedule back.

Fractions round to whole percentages (33.33% becomes 33%). A rollout followed by more rules gets a warning too. A context without the bucketing attribute skips a Featureflip rollout and falls through to the next rule, where Statsig would have stopped at the rollout.

The safest switch runs both systems for one release and compares them before anyone depends on Featureflip.

  1. Apply the import with flags off. Nothing serves yet.
  2. Ship code that reads both systems, returns Statsig’s answer and logs any difference.
  3. Turn the flags on in Featureflip with --carry-state --overwrite. Where only the on/off state differs, that’s all it changes.
  4. Watch the mismatch log for a release. Expect differences inside partial rollouts, for the reason above. Anywhere else, a mismatch usually means a missing context attribute.
  5. Return Featureflip’s answer instead, then remove the Statsig SDK.

A wrapper for step 2, in Node.js:

function isEnabled(flag: string, user: StatsigUser, context: EvaluationContext): boolean {
const fromStatsig = statsig.checkGate(user, flag);
const fromFeatureflip = featureflip.boolVariation(flag, context, false);
if (fromStatsig !== fromFeatureflip) {
logger.warn({ flag, userID: user.userID, fromStatsig, fromFeatureflip }, 'flag mismatch');
}
return fromStatsig;
}

The import is a snapshot. If someone edits a gate in Statsig during the comparison, re-run the import with --overwrite to bring the change across, or ask the team to leave Statsig alone until the switch is done.

The importer reads feature gates, dynamic configs and segments. Everything else stays in Statsig.

Not read at all: experiments, layers, holdouts and autotunes. Experiment analysis needs a home outside Featureflip. The analytics integration guide shows how to send exposures to the tool you pick. A gate inside a holdout imports with a warning, because held-out users will now get the flag.

Blocked, so you rebuild or drop them:

  • rules that check another gate (passes_gate and fails_gate). Featureflip’s prerequisite flags cover the same need, set up by hand.
  • conditions on time, IP address, user agent, URL, target app, experiment group or a JavaScript expression
  • gates Statsig marks Launched, because the Console API doesn’t say what a launched gate serves
  • a dynamic config rollout when the config has three or more values, and rules that split users across several values
  • segments with a partial pass percentage, segments that differ by environment, and analysis list segments the Console API can’t read
  • two gates or segments whose IDs become the same key, such as Beta Users and beta-users

Imported with a change:

  • a segment with several rules can’t be one Featureflip segment, so its rules are copied into each flag that uses it instead
  • target apps are dropped, so the flag reaches every app using the environment’s SDK key
  • a dynamic config’s JSON schema is dropped, because Featureflip doesn’t validate JSON values
  • templates and archived gates are skipped

Run the dry run again after each change in Statsig. When the blocked list holds only items you’ve decided to rebuild by hand, apply it.