Registry / aws / vwo-fme-node-sdk

vwo-fme-node-sdk

JSON →
library1.41.0jsnpmunverified

The VWO Feature Management and Experimentation SDK (vwo-fme-node-sdk) provides robust capabilities for integrating feature flagging and experimentation directly into Node.js and browser-based JavaScript applications. Currently stable at version 1.41.0, the library receives consistent updates, indicated by frequent minor and patch releases. It allows developers to dynamically manage feature rollouts, conduct A/B tests, and track user interaction events within the VWO platform. Key features include the ability to specify custom bucketing seeds for consistent user group assignments (v1.41.0), automatic session management (v1.37.0) to link server-side decisions with client-side experiences, and a flexible `Connector` API (v1.35.0) for custom persistent storage of VWO settings. Notably, a significant architectural change in v1.36.0 shifted the SDK from a singleton model to supporting multiple isolated instances, enhancing flexibility for complex application architectures.

npm install vwo-fme-node-sdk
INSTALL
IMPORT
SIG · VWO-FME-NODE-SDK
V
vwo-fme-node-sdk
awsjavascriptv1.41.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

init
import { init } from 'vwo-fme-node-sdk';
const { init } = require('vwo-fme-node-sdk');
While `require` syntax works, prefer ESM `import` for modern Node.js and browser environments for consistency and tree-shaking benefits. The `init` function is the primary entry point for client initialization.
IVWOClient
import { IVWOClient } from 'vwo-fme-node-sdk';
This is a TypeScript interface for type-safe interaction with the VWO client instance. It's used for type annotations, not for runtime instantiation.
Flag
import { Flag } from 'vwo-fme-node-sdk';
This is a TypeScript interface representing the result of a feature flag evaluation, providing methods like `isEnabled()` and `getVariable()`. Use it for type-checking flag results.
IVWOOptions
import { IVWOOptions } from 'vwo-fme-node-sdk';
This TypeScript interface defines the configuration object passed to the `init()` function, ensuring type safety for your SDK initialization parameters.

Demonstrates initializing the VWO client, evaluating a feature flag, retrieving a variable, tracking an event, and gracefully shutting down the client in a TypeScript environment.

import { init, IVWOClient, IVWOOptions, Flag } from 'vwo-fme-node-sdk'; (async () => { const options: IVWOOptions = { accountId: process.env.VWO_ACCOUNT_ID ?? '123456', sdkKey: process.env.VWO_SDK_KEY ?? '32-alpha-numeric-sdk-key' }; const vwoClient: IVWOClient = await init(options); const userContext = { id: 'unique_user_id', customData: { role: 'admin' } }; const feature: Flag = await vwoClient.getFlag('premium_feature', userContext); if (feature.isEnabled()) { console.log('Premium feature is enabled for the user!'); const discountLevel: number = feature.getVariable('discount_level', 0); console.log(`User receives a ${discountLevel}% discount.`); } else { console.log('Premium feature is not enabled.'); } // Track an event after a feature decision or user action vwoClient.trackEvent('premium_feature_used', userContext); // Gracefully shut down the client in long-running processes (Node.js servers) vwoClient.shutdown(); })();
Debug
Known issues
gotchaThe `shutdown()` API was introduced in v1.42.0 to support graceful teardown in long-running environments. Failing to call `shutdown()` can lead to resource leaks and prevent batched events from being flushed, especially in serverless or containerized setups where processes terminate without explicit cleanup.
fix
Ensure `vwoClient.shutdown()` is called before your application process exits or when the client is no longer needed. For example, in a server, call it during the server's graceful shutdown hook.
affects: >=1.42.0
breakingIn v1.36.0, the SDK refactored from a singleton pattern to support multiple isolated instances. If your application implicitly relied on shared state across what you considered separate client initializations (which previously all pointed to the same singleton), their behavior will change. Each `init()` call now creates a truly independent client instance with its own state and utilities.
fix
Review any code that might have depended on shared state across `vwoClient` instances. Ensure each instance is managed and configured independently. If global access is still desired, manually manage a single instance or pass it explicitly.
affects: >=1.36.0
gotchaVersion 1.41.0 introduced support for `bucketingSeed` in the context object. This allows users to be bucketed by a shared identifier (e.g., `companyId`) instead of the individual `userId`, ensuring all users within the same group receive the same variation. Without this, bucketing is strictly per individual user ID.
fix
To enable group-based bucketing, include `bucketingSeed: 'your-group-id'` in your user context object when calling `getFlag` or `trackEvent`.
affects: >=1.41.0
gotchaSince v1.38.0, the SDK allows using the context `id` directly as the visitor UUID instead of generating a new one. This is crucial if you need to maintain a consistent UUID across server-side and client-side interactions, especially when integrating with the VWO web client.
fix
When initializing `vwoClient` or in the user context, if you want your `id` to be the UUID, ensure it's a stable identifier. You can retrieve the assigned UUID via `flag.getUUID()` to pass to other clients.
affects: >=1.38.0
gotchaV1.35.0 introduced the `Connector` class for enabling persistent storage and retrieval of VWO settings via custom storage connectors. If you need to cache settings or visitor data between application restarts or across different instances, you must implement and provide a custom `Connector`.
fix
Extend the `StorageConnector` class and implement `getSettings`, `setSettings`, `get`, and `set` methods. Pass an instance of your custom connector to the `init()` options: `{ storage: new MyCustomStorageConnector() }`.
affects: >=1.35.0
Errors
Common errors & fixes
TypeError: (0, _vwoFmeNodeSdk.init) is not a function
Attempting to destructure `init` from a CommonJS `require()` call when the SDK is primarily an ES module or when using an older Node.js version that treats `.js` files as CommonJS by default, while the SDK expects ES module imports.
fix
If using Node.js with ES modules (`"type": "module"` in `package.json` or `.mjs` files), use `import { init } from 'vwo-fme-node-sdk';`. If strictly using CommonJS, ensure your environment correctly handles the module interoperability or use a bundler that transpiles correctly. Often, switching to ESM imports is the most straightforward fix.
UnhandledPromiseRejectionWarning: VWOClientError: SDK not initialized. Call init() first.
The SDK client (`vwoClient`) was used before the asynchronous `init()` function completed, or `init()` failed to resolve.
fix
Always `await` the `init()` call to ensure the VWO client is fully initialized before attempting to use any of its methods like `getFlag` or `trackEvent`. Wrap SDK usage in an `async` function.
TypeError: Cannot read properties of undefined (reading 'isEnabled')
This typically occurs when `vwoClient.getFlag()` returns `undefined` (e.g., due to an invalid flag key, network issue, or client not being fully initialized), and you attempt to call a method like `isEnabled()` on it.
fix
Always check if the `Flag` object returned by `getFlag()` is valid before accessing its properties or methods, e.g., `if (feature && feature.isEnabled()) { ... }`. Ensure your `sdkKey` and `flagKey` are correct and the client is properly initialized.
Upgrade
Version history
1.41.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
30
Resources