{"library":"statsig-node","title":"Statsig Node.js SDK","type":"library","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install statsig-node"],"cli":null},"imports":["import { Statsig } from 'statsig-node';","import { StatsigUser } from 'statsig-node';","await Statsig.initialize('YOUR_SECRET_KEY');"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://www.statsig.com","github":"https://github.com/statsig-io/node-js-server-sdk","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/statsig-node","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { Statsig, StatsigUser } from 'statsig-node';\n\nconst STATSIG_SECRET_KEY = process.env.STATSIG_SERVER_SECRET_KEY ?? '';\n\nasync function runStatsigExample() {\n  if (!STATSIG_SECRET_KEY) {\n    console.error('STATSIG_SERVER_SECRET_KEY environment variable is not set.');\n    return;\n  }\n\n  try {\n    await Statsig.initialize(STATSIG_SECRET_KEY, {\n      localMode: false, // Set to true for local testing without network calls\n      // Additional options like 'environment', 'api' can be passed here\n    });\n\n    const user: StatsigUser = {\n      userID: 'unique-user-id-123',\n      email: 'test@example.com',\n      country: 'US',\n      custom: { membershipTier: 'premium' },\n      // Additional custom properties can be added\n    };\n\n    if (await Statsig.checkGate(user, 'my_new_feature_gate')) {\n      console.log('Feature \"my_new_feature_gate\" is ENABLED for the user!');\n    } else {\n      console.log('Feature \"my_new_feature_gate\" is DISABLED for the user.');\n    }\n\n    const config = await Statsig.getConfig(user, 'product_pricing_config');\n    console.log('Product pricing level:', config.get('priceLevel', 'standard'));\n\n    Statsig.logEvent(user, 'checkout_completed', 99.99, { currency: 'USD', items: 3 });\n\n  } catch (error) {\n    console.error('Statsig initialization or usage failed:', error);\n  } finally {\n    await Statsig.shutdown(); // Important to call shutdown for graceful exit and event flushing\n  }\n}\n\nrunStatsigExample();","lang":"typescript","description":"Initializes the Statsig SDK, checks a feature gate, fetches a dynamic config, logs an event, and gracefully shuts down. Demonstrates core SDK functionality.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}