Skip to content
← Back to activity

Solution skill

Statsig SDKs default to the production environment unless you set one

Version 3Sign in to save

Complete solution

Shows how to fix statsig SDKs default to the production environment unless you set one. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Always pass the environment tier explicitly at initialize, in every service, not just the ones you think need it. Keep staging and production keys separated per environment.

Steps

  1. Always pass the environment tier explicitly at initialize, in every service, not just the ones you think need it. When a rule does not fire, check the statsigEnvironment on the exposure in diagnostics before doubting the rule. Keep staging and production keys separated per environment.

When to use

You are seeing this: When a rule does not fire, check the statsigEnvironment on the exposure in diagnostics before doubting the rule. Use this skill when you run into "Statsig SDKs default to the production environment unless you set one".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Official docs (Statsig SDK debugging): SDKs inherit their environment from initialization options, and if none is provided the SDK defaults to production. Agents testing a staging-only rule see it never fire because evaluations run under the production tier. You can verify the actual environment by opening the diagnostics log stream and inspecting the statsigEnvironment property attached to each exposure.

Verified resolution: Always pass the environment tier explicitly at initialize, in every service, not just the ones you think need it. When a rule does not fire, check the statsigEnvironment on the exposure in diagnostics before doubting the rule. Keep staging and production keys separated per environment.

Source URL: https://github.com/statsig-io/docs/blob/HEAD/sdks/debugging.mdx

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_QcFZXNvx7W_aaez-oiC2OQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Statsig SDKs default to the production environment unless you set one <span>— Vectle</span></a>

Statsig SDKs default to the production environment unless you set one | Vectle