The Statsig Node.js SDK (current stable version 6.5.1) provides robust tools for managing feature gates, dynamic configurations, and A/B testing within multi-user server environments. It enables developers to implement continuous deployment strategies and understand the impact of new features on key performance indicators. The package sees frequent updates, typically releasing bug fixes and minor improvements multiple times a month, as evidenced by recent changelogs. Key differentiators include its comprehensive A/B testing capabilities, detailed analytics, and a focus on server-side performance and data consistency, contrasting with client-side SDKs that handle single-user contexts. It is designed for use cases where server-side evaluation of features is critical for performance and security.
npm install statsig-nodeVerified import paths — ran on the pinned version, not inferred.
Initializes the Statsig SDK, checks a feature gate, fetches a dynamic config, logs an event, and gracefully shuts down. Demonstrates core SDK functionality.
Ensure all timestamps passed to Statsig evaluation logic (e.g., in `StatsigUser` custom properties) are consistently in milliseconds or upgrade to v6.5.1+.
Upgrade to `statsig-node` v6.4.7 or later to benefit from memory leak fixes.
Upgrade `statsig-node` to v6.4.8 or newer to include the patched `sha.js` dependency and mitigate the security risk.
Upgrade to `statsig-node` v6.4.3 or later, which includes a workaround for runtimes without `AbortSignal`.
Upgrade to `statsig-node` v6.4.5 or later to ensure secret keys are masked in logs during initialization failures.
Ensure `await Statsig.initialize('YOUR_SECRET_KEY');` is called and awaited at the start of your application before any other Statsig SDK methods are invoked.Use ES module `import { Statsig } from 'statsig-node';` syntax. If using CommonJS, ensure your environment and build tools correctly transpile or interpret named exports, or use `const Statsig = require('statsig-node').Statsig;` if available, though direct named imports are preferred.Verify that `YOUR_STATSIG_SERVER_SECRET_KEY` is a valid Statsig server secret key (starting with `secret-`) obtained from your Statsig console, and that no leading/trailing whitespace is present.
Ensure your Node.js environment is v18+ (where `fetch` is native) or provide a global `fetch` polyfill (e.g., `node-fetch`) if running on older Node.js versions or restricted environments.