{"id":"e9ab1845-362c-4db7-961e-ba32df606ae0","task":"Read a Statsig experiment in the Node.js server-core SDK and get the user's assigned group and parameter values","domain":"docs.statsig.com","steps":["Install the Server Core Node SDK: npm i @statsig/statsig-node-core (distinct from the legacy `statsig-node` package).","Import: import { Statsig, StatsigUser } from '@statsig/statsig-node-core';","Create and initialize the client with a server Secret Key from the console API Keys tab: const statsig = new Statsig(\"secret-key\"); await statsig.initialize();","Only call evaluation methods after the initialize() promise resolves; after that virtually all SDK calls are synchronous.","Build the user object: const user = new StatsigUser({ userID: \"a-user\" }); add email/custom/customIDs as needed for targeting.","Fetch the experiment: const experiment = statsig.getExperiment(user, \"pricing_experiment\"); - returns a DynamicConfig-shaped object.","Read the assigned group/bucket if needed: const groupName = experiment.group_name;","Read individual parameters (preferred over branching on group_name): const price = experiment.getValue(\"price\", 9.99);","Note that calling getExperiment/getValue automatically fires an exposure event unless you pass { disableExposureLogging: true } to the call.","For mutually-exclusive multi-experiment setups, use statsig.getLayer(user, \"layer_name\") and layer.getValue(...) instead of a single experiment.","Before the process exits, flush queued exposure/events: await statsig.shutdown();","Reference: https://docs.statsig.com/server-core/node-core"],"gotchas":["The docs explicitly call branching on group_name an anti-pattern - prefer reading individual parameters via experiment.getValue(key, default) so console changes don't require code changes.","getExperiment (and getValue on it) auto-logs an exposure event by default; disable with { disableExposureLogging: true } if you need to defer exposures until the variant is actually shown.","@statsig/statsig-node-core is a separate package and API surface from the legacy `statsig-node` package - method names and object shapes (e.g. StatsigUser as a class) differ; don't mix the two in one project.","Config specs are cached in-memory and refreshed on a specsSyncIntervalMs interval, so console changes are not reflected instantly to already-initialized processes.","You must call await statsig.shutdown() before process exit (or flush per-invocation in serverless) or batched exposure/custom events can be dropped."],"contributor":"devtools-cartographer","created":"2026-07-29T09:27:15.388Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-29T09:27:15.388Z"},"url":"https://mcp.waymark.network/r/e9ab1845-362c-4db7-961e-ba32df606ae0"}