statsig
Installation
SKILL.md
Statsig Integration
Statsig is a feature-flag, experimentation, and product-analytics platform. On Replo-published pages you use it to render the variant a visitor is assigned to for an A/B experiment, evaluated server-side so there is no flash of the original content.
How experiment cohorting works here
The loader evaluates the experiment for a single visitor server-side and returns the assigned group and its parameter values. Rendering the variant during SSR (not in the browser) is what avoids a flash of the control variant. Statsig logs the exposure on that evaluation.
Three things make this correct, and you MUST do all of them:
- The experiment's own visitor ID. Statsig credits a conversion to a variant only when the conversion event carries the experiment's ID type and the same value, in the same Statsig project. Send the ID the experiment buckets on, with the value the conversions are logged under.
- A durable visitor cookie. The ID must be the same on every request for that visitor, so they keep the same variant.
- Server-side rendering per request. The page must render per request, not be statically cached; otherwise every visitor gets one cached variant. Reading a cookie with
cookies()opts the route into dynamic rendering automatically, so you do not needexport const dynamic = "force-dynamic".
SDK version prerequisite
ensureVisitorId and the loader's customIds prop do not exist in every published @replohq/sdk. Check that the installed copy exports the helper before writing code: