Registry / devops / statsig-node-vercel

statsig-node-vercel

JSON →
library0.8.1jsnpmunverified

This package, `statsig-node-vercel`, provides a first-party integration between the Statsig server-side Node.js SDK and Vercel's Edge Config. It allows developers to store and retrieve Statsig configuration, including feature gates, dynamic configs, and ID lists, directly from Vercel Edge Config, leveraging its low-latency, globally distributed data store. The current stable version is 0.8.1, and its release cadence appears to be tied to updates in the main Statsig Node.js SDK and Vercel's Edge Config features, with a focus on optimization and direct data parsing. Key differentiators include seamless integration with Vercel infrastructure, reduced network latency for Statsig evaluations by utilizing Edge Config, and specific optimizations for ID list handling. It significantly streamlines the deployment and management of Statsig configurations within Vercel environments.

npm install statsig-node-vercel
INSTALL
IMPORT
SIG · STATSIG-NODE-VERCE
S
statsig-node-vercel
devopsjavascriptv0.8.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EdgeConfigDataAdapter
✓ import { EdgeConfigDataAdapter } from 'statsig-node-vercel';
✗ const { EdgeConfigDataAdapter } = require('statsig-node-vercel');
Primarily designed for ESM environments; CommonJS `require` might work with transpilation but isn't the idiomatic import.
createClient
✓ import { createClient } from '@vercel/edge-config';
✗ const { createClient } = require('@vercel/edge-config');
This is an import from the peer dependency `@vercel/edge-config`, crucial for initializing the Edge Config client.
StatsigServer
✓ import statsig from 'statsig-node';
✗ import { StatsigServer } from 'statsig-node';
The main Statsig SDK is typically imported as a default export `statsig` (or `Statsig` if using a different casing convention).

This quickstart demonstrates how to initialize the Statsig Node.js SDK using the Vercel Edge Config adapter, showing setup, environment variable usage, and a basic feature gate check.

import { EdgeConfigDataAdapter } from 'statsig-node-vercel'; import { createClient } from '@vercel/edge-config'; import statsig from 'statsig-node'; async function initializeStatsigWithVercel() { const edgeConfigClient = createClient(process.env.EDGE_CONFIG_CONNECTION_STRING ?? ''); if (!process.env.EDGE_CONFIG_CONNECTION_STRING) { console.error('EDGE_CONFIG_CONNECTION_STRING is not set. Please configure your Vercel Edge Config.'); return; } const dataAdapter = new EdgeConfigDataAdapter({ edgeConfigClient: edgeConfigClient, edgeConfigItemKey: process.env.STATSIG_EDGE_CONFIG_ITEM_KEY ?? 'statsig-ITEM_KEY', }); if (!process.env.STATSIG_SERVER_SECRET_KEY) { console.error('STATSIG_SERVER_SECRET_KEY is not set. Please provide your Statsig server secret key.'); return; } await statsig.initialize(process.env.STATSIG_SERVER_SECRET_KEY, { dataAdapter: dataAdapter, // These options are recommended for optimal performance with Edge Config // to avoid blocking network calls for ID Lists on initialization. // Omit if you need ID list evaluation immediately on init. initStrategyForIDLists: 'none', disableIdListsSync: true }); console.log('Statsig initialized successfully with Vercel Edge Config!'); // Example: Check a feature gate const user = { userID: 'test-user-123' }; const gateResult = await statsig.checkGate(user, 'a_feature_gate'); console.log(`Feature gate 'a_feature_gate' for user ${user.userID}: ${gateResult}`); statsig.shutdown(); } initializeStatsigWithVercel().catch(console.error);
Debug
Known issues
breakingThe `0.4.0` release removed the need for manual JSON stringification/parsing. Previously, users might have manually `JSON.stringify` values before passing them to the adapter or `JSON.parse` values received. This is no longer necessary, as the adapter now directly passes object values.
fix
Remove any manual `JSON.stringify` or `JSON.parse` calls when interacting with data fetched via `EdgeConfigDataAdapter`. The adapter handles object serialization/deserialization automatically.
affects: >=0.4.0
gotchaWhen using `EdgeConfigDataAdapter`, it is recommended to set `initStrategyForIDLists: 'none'` and `disableIdListsSync: true` in the Statsig SDK initialization options. Omitting these will cause a blocking network call to fetch ID lists during initialization, potentially impacting cold start performance.
fix
Ensure `initStrategyForIDLists: 'none'` and `disableIdListsSync: true` are included in the Statsig initialization options. If immediate ID list evaluation is critical on startup, consider the performance implications or pre-warm your Edge Config.
affects: >=0.1.0
gotchaThe `edgeConfigItemKey` is a crucial identifier linking your adapter to the correct item in Vercel Edge Config. A misconfigured key will result in the adapter failing to fetch Statsig data.
fix
Double-check that the `edgeConfigItemKey` provided to `EdgeConfigDataAdapter` precisely matches the key generated during the Statsig Vercel Integration installation in your Vercel project settings (e.g., 'statsig-5FSfBpWM9kUPqeKRlZPkod').
affects: >=0.1.0
Errors
Common errors & fixes
Error: Missing Edge Config connection string. Make sure to set EDGE_CONFIG_CONNECTION_STRING in your environment variables.
The `@vercel/edge-config` client could not be initialized because the `EDGE_CONFIG_CONNECTION_STRING` environment variable was not found.
fix
Set the `EDGE_CONFIG_CONNECTION_STRING` environment variable in your Vercel project or local development environment. This string is provided by Vercel for your Edge Config.
Statsig data not found in Edge Config for key: [YOUR_ITEM_KEY]
The `EdgeConfigDataAdapter` was initialized with an `edgeConfigItemKey` that does not correspond to any valid Statsig data item within your Vercel Edge Config.
fix
Verify that the `edgeConfigItemKey` passed to `EdgeConfigDataAdapter` is correct and that the Statsig Vercel Integration has been successfully installed and populated data into your Edge Config instance.
TypeError: Cannot read properties of undefined (reading 'initialize')
The `statsig` object was undefined, indicating the `statsig-node` SDK was not correctly imported or initialized before being used.
fix
Ensure `import statsig from 'statsig-node';` is at the top of your file and that `await statsig.initialize()` is called before any other Statsig functions.
Upgrade
Version history
0.8.1latest on npm
Audit
Dependencies
statsig-noderequiredCore Statsig Node.js SDK for server-side feature evaluation.
@vercel/edge-configrequiredRequired to interact with Vercel Edge Config for data storage.
Agent activity
25 hits · last 30 days
node
20
Bingbot
1
OpenAI (training)
1
Resources
statsig-node-vercel — npm install statsig-node-vercel · libregistry