{"id":19541291,"url":"https://github.com/wingify/vwo-fme-node-sdk","last_synced_at":"2026-02-16T08:13:20.018Z","repository":{"id":237941312,"uuid":"795500530","full_name":"wingify/vwo-fme-node-sdk","owner":"wingify","description":"VWO Feature Management and Experimentation SDK for Node.js and JavaScript(browser)","archived":false,"fork":false,"pushed_at":"2026-02-09T08:35:29.000Z","size":12442,"stargazers_count":14,"open_issues_count":1,"forks_count":7,"subscribers_count":10,"default_branch":"master","last_synced_at":"2026-02-09T13:52:23.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developers.vwo.com/v2/docs/fme-node","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wingify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-03T12:20:46.000Z","updated_at":"2026-02-09T08:35:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc9ffa5c-9986-4042-8397-88ccb646ae42","html_url":"https://github.com/wingify/vwo-fme-node-sdk","commit_stats":{"total_commits":117,"total_committers":6,"mean_commits":19.5,"dds":0.4871794871794872,"last_synced_commit":"541d1c7a67a447c810f2c993cb5ea12f0dcebe20"},"previous_names":["wingify/vwo-fme-node-sdk"],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/wingify/vwo-fme-node-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingify%2Fvwo-fme-node-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingify%2Fvwo-fme-node-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingify%2Fvwo-fme-node-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingify%2Fvwo-fme-node-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wingify","download_url":"https://codeload.github.com/wingify/vwo-fme-node-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wingify%2Fvwo-fme-node-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29503339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T08:07:58.651Z","status":"ssl_error","status_checked_at":"2026-02-16T08:07:56.823Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T03:09:34.151Z","updated_at":"2026-02-16T08:13:20.011Z","avatar_url":"https://github.com/wingify.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VWO Feature Management and Experimentation SDK for Node.js and JavaScript(Browser)\n\n[![npm version](https://img.shields.io/npm/v/vwo-fme-node-sdk?style=for-the-badge\u0026color=grey\u0026logo=npm)](https://www.npmjs.com/package/vwo-fme-node-sdk)\n[![License](https://img.shields.io/github/license/wingify/vwo-fme-node-sdk?style=for-the-badge\u0026color=blue)](http://www.apache.org/licenses/LICENSE-2.0)\n[](http://img.badgesize.io/wingify/vwo-fme-node-sdk/master/dist/client/vwo-fme-javascript-sdk.min.js?compression=gzip\u0026color=blue\u0026style=for-the-badge)\n\n[![CI](https://img.shields.io/github/actions/workflow/status/wingify/vwo-fme-node-sdk/main.yml?style=for-the-badge\u0026logo=github)](https://github.com/wingify/vwo-fme-node-sdk/actions?query=workflow%3ACI)\n[![codecov](https://img.shields.io/codecov/c/github/wingify/vwo-fme-node-sdk?token=813UYYMWGM\u0026style=for-the-badge\u0026logo=codecov)](https://codecov.io/gh/wingify/vwo-fme-node-sdk)\n![](http://img.badgesize.io/wingify/vwo-fme-node-sdk/master/dist/client/vwo-fme-javascript-sdk.min.js?compression=gzip\u0026color=blue)\n\n## Overview\n\nThe **VWO Feature Management and Experimentation SDK** (VWO FME Node SDK) enables Node.js and JavaScript developers to integrate feature flagging and experimentation into their applications. This SDK provides full control over feature rollout, A/B testing, and event tracking, allowing teams to manage features dynamically and gain insights into user behavior.\n\n## Requirements\n\n- **Node.js v12 or later**\n\n## Installation\n\nInstall the SDK via [**npm**](https://npmjs.com/package/vwo-fme-node-sdk) or [**yarn**](https://classic.yarnpkg.com/en/package/vwo-fme-node-sdk):\n\n```bash\n# via npm\nnpm install vwo-fme-node-sdk --save\n\n# via yarn\nyarn add vwo-fme-node-sdk\n```\n\n## Basic Usage Example\n\nThe following example demonstrates initializing the SDK with a VWO account ID and SDK key, setting a user context, checking if a feature flag is enabled, and tracking a custom event.\n\n```javascript\nconst { init } = require('vwo-fme-node-sdk');\n\n// Initialize VWO client\n(async function () {\n  const vwoClient = await init({\n    accountId: '123456',\n    sdkKey: '32-alpha-numeric-sdk-key',\n  });\n\n  // Check if feature is enabled for user\n  const userContext = { id: 'unique_user_id' };\n  const feature = await vwoClient.getFlag('feature_key', userContext);\n\n  if (feature.isEnabled()) {\n    console.log('Feature is enabled!');\n\n    // Get feature variable\n    const value = feature.getVariable('feature_variable', 'default_value');\n    console.log('Variable value:', value);\n  }\n\n  // Track an event\n  vwoClient.trackEvent('event_name', userContext);\n})();\n```\n\nThe SDK includes TypeScript type definitions for better type safety and IDE support. Here's how to use the SDK with TypeScript:\n\n```typescript\nimport { init, IVWOClient, IVWOOptions, Flag } from 'vwo-fme-node-sdk';\n// Example of using IVWOOptions for type-safe configuration\nconst options: IVWOOptions = {\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n};\n\n// Example of using IVWOClient for type-safe client usage\nconst vwoClient: IVWOClient = await init(options);\n\n// Example of using Flag interface for type-safe flag handling\nconst flag: Flag = await vwoClient.getFlag('feature-key', { id: 'user-123' });\nconst isEnabled: boolean = flag.isEnabled();\n\nconst stringVariable: string = flag.getVariable('variable_key', 'default_value');\nconst booleanVariable: boolean = flag.getVariable('variable_key', true);\nconst numberVariable: number = flag.getVariable('variable_key', 10);\n```\n\n## Advanced Configuration Options\n\nTo customize the SDK further, additional parameters can be passed to the `init()` API. Here's a table describing each option:\n\n| **Parameter**                | **Description**                                                                                                                                             | **Required** | **Type** | **Example**                                   |\n| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | -------- | --------------------------------------------- |\n| `accountId`                  | VWO Account ID for authentication.                                                                                                                          | Yes          | String   | `'123456'`                                    |\n| `sdkKey`                     | SDK key corresponding to the specific environment to initialize the VWO SDK Client. You can get this key from VWO Application.                              | Yes          | String   | `'32-alpha-numeric-sdk-key'`                  |\n| `pollInterval`               | Time interval for fetching updates from VWO servers (in milliseconds).                                                                                      | No           | Number   | `60000`                                       |\n| `gatewayService`             | An object representing configuration for integrating VWO Gateway Service.                                                                                   | No           | Object   | see [Gateway](#gateway) section               |\n| `storage`                    | Custom storage connector for persisting user decisions and campaign data.                                                                                   | No           | Object   | See [Storage](#storage) section               |\n| `clientStorage`              | Browser storage configuration for persisting user data in browser environments.                                                                             | No           | Object   | See [Client Storage](#client-storage) section |\n| `logger`                     | Toggle log levels for more insights or for debugging purposes. You can also customize your own transport in order to have better control over log messages. | No           | Object   | See [Logger](#logger) section                 |\n| `shouldWaitForTrackingCalls` | Ensures tracking calls complete before resolving promises, useful for edge computing environments like Cloudflare Workers                                   | No           | Boolean  | `true`                                        |\n| `integrations`               | A callback function that receives data which can be pushed to any external tool that you need to integrate with.                                            | No           | Object   | See [Integrations](#integrations)             |\n| `batchEventData`             | Configuration for batch event processing to optimize network requests                                                                                       | No           | Object   | See [Batch Events](#batch-events) section     |\n| `retryConfig`                | Configuration for network request retry behavior and exponential backoff strategy                                                                           | No           | Object   | See [Retry Config](#retry-config) section     |\n| `edgeConfig`                 | Configuration for edge/serverless environment optimizations (e.g., Cloudflare Workers)                                                                      | No           | Object   | See [Edge Config](#edge-config) section       |\n\nRefer to the [official VWO documentation](https://developers.vwo.com/v2/docs/fme-node-install) for additional parameter details.\n\n### User Context\n\nThe `context` object uniquely identifies users and is crucial for consistent feature rollouts. A typical `context` includes an `id` for identifying the user. It can also include other attributes that can be used for targeting and segmentation, such as `customVariables`, `userAgent` and `ipAddress`.\n\n#### Parameters Table\n\nThe following table explains all the parameters in the `context` object:\n\n| **Parameter**     | **Description**                                                            | **Required** | **Type** | **Example**                       |\n| ----------------- | -------------------------------------------------------------------------- | ------------ | -------- | --------------------------------- |\n| `id`              | Unique identifier for the user.                                            | Yes          | String   | `'unique_user_id'`                |\n| `customVariables` | Custom attributes for targeting.                                           | No           | Object   | `{ age: 25, location: 'US' }`     |\n| `userAgent`       | User agent string for identifying the user's browser and operating system. | No           | String   | `'Mozilla/5.0 ... Safari/537.36'` |\n| `ipAddress`       | IP address of the user.                                                    | No           | String   | `'1.1.1.1'`                       |\n\n#### Example\n\n```javascript\nconst userContext = {\n  id: 'unique_user_id',\n  customVariables: { age: 25, location: 'US' },\n  userAgent:\n    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',\n  ipAddress: '1.1.1.1',\n};\n```\n\n### Session Management\n\nThe SDK provides automatic session management capabilities to enable seamless integration with VWO's web client testing campaigns. Session IDs are automatically generated and managed to connect server-side feature flag decisions with client-side user sessions.\n\n#### Automatic Session ID Generation\n\nSession IDs are automatically generated using Unix timestamps when not explicitly provided in the context. This ensures consistent session tracking across all feature flag evaluations and event tracking.\n\n#### Session ID Access\n\nYou can access and manage session IDs through the following methods:\n\n- **Get Session ID from Flag**: Use `flag.getSessionId()` to retrieve the session ID used for a specific feature flag evaluation\n- **Set Custom Session ID**: Include `sessionId` in your context object to use a custom session ID (useful for matching web client sessions)\n\n#### Example Usage\n\n```javascript\n// Session ID is automatically generated if not provided\nconst context = { id: 'user-123' };\nconst flag = await vwoClient.getFlag('feature-key', context);\n\n// Access the session ID to pass to web client for session recording\nconst sessionId = flag.getSessionId();\nconsole.log('Session ID for web client:', sessionId);\n```\n\nYou can also explicitly set a session ID to match web client session\n\n```javascript\nconst context = {\n  id: 'user-123',\n  sessionId: 1697123456, // Custom session ID matching web client\n};\nconst flag = await vwoClient.getFlag('feature-key', context);\n```\n\nThis enhancement enables seamless integration between server-side feature flag decisions and client-side session recording, allowing for comprehensive user behavior analysis across both server and client environments.\n\n### Basic Feature Flagging\n\nFeature Flags serve as the foundation for all testing, personalization, and rollout rules within FME.\nTo implement a feature flag, first use the `getFlag` API to retrieve the flag configuration.\nThe `getFlag` API provides a simple way to check if a feature is enabled for a specific user and access its variables. It returns a feature flag object that contains methods for checking the feature's status and retrieving any associated variables.\n\n| Parameter    | Description                                                      | Required | Type   | Example              |\n| ------------ | ---------------------------------------------------------------- | -------- | ------ | -------------------- |\n| `featureKey` | Unique identifier of the feature flag                            | Yes      | String | `'new_checkout'`     |\n| `context`    | Object containing user identification and contextual information | Yes      | Object | `{ id: 'user_123' }` |\n\nExample usage:\n\n```javascript\nconst featureFlag = await vwoClient.getFlag('feature_key', { id: 'unique_user_id' });\nconst isEnabled = featureFlag.isEnabled();\n\nif (isEnabled) {\n  console.log('Feature is enabled!');\n\n  // Get and use feature variable with type safety\n  const variableValue = featureFlag.getVariable('feature_variable', 'default_value');\n  console.log('Variable value:', variableValue);\n} else {\n  console.log('Feature is not enabled!');\n}\n```\n\n### Custom Event Tracking\n\nFeature flags can be enhanced with connected metrics to track key performance indicators (KPIs) for your features. These metrics help measure the effectiveness of your testing rules by comparing control versus variation performance, and evaluate the impact of personalization and rollout campaigns. Use the `trackEvent` API to track custom events like conversions, user interactions, and other important metrics:\n\n| Parameter         | Description                                                            | Required | Type   | Example                |\n| ----------------- | ---------------------------------------------------------------------- | -------- | ------ | ---------------------- |\n| `eventName`       | Name of the event you want to track                                    | Yes      | String | `'purchase_completed'` |\n| `context`         | Object containing user identification and other contextual information | Yes      | Object | `{ id: 'user_123' }`   |\n| `eventProperties` | Additional properties/metadata associated with the event               | No       | Object | `{ amount: 49.99 }`    |\n\nExample usage:\n\n```javascript\nvwoClient.trackEvent('event_name', { id: 'unique_user_id' }, { amount: 49.99 });\n```\n\nSee [Tracking Conversions](https://developers.vwo.com/v2/docs/fme-node-metrics#usage) documentation for more information.\n\n### Pushing Attributes\n\nUser attributes provide rich contextual information about users, enabling powerful personalization. The `setAttribute` method provides a simple way to associate these attributes with users in VWO for advanced segmentation. Here's what you need to know about the method parameters:\n\n| Parameter        | Description                                                            | Required | Type   | Example                 |\n| ---------------- | ---------------------------------------------------------------------- | -------- | ------ | ----------------------- |\n| `attributeKey`   | The unique identifier/name of the attribute you want to set            | Yes      | String | `'plan_type'`           |\n| `attributeValue` | The value to be assigned to the attribute                              | Yes      | Any    | `'premium'`, `25`, etc. |\n| `context`        | Object containing user identification and other contextual information | Yes      | Object | `{ id: 'user_123' }`    |\n\nExample usage:\n\n```javascript\nvwoClient.setAttribute('attribute_name', 'attribute_value', { id: 'unique_user_id' });\n```\n\nSee [Pushing Attributes](https://developers.vwo.com/v2/docs/fme-node-attributes#usage) documentation for additional information.\n\n### Polling Interval Adjustment\n\nThe `pollInterval` is an optional parameter that allows the SDK to automatically fetch and update settings from the VWO server at specified intervals. The polling interval can be configured in three ways:\n\n1. Set via SDK options: If `pollInterval` is specified in the initialization options (must be \u003e= 1000 milliseconds), that interval will be used\n2. VWO Application Settings: If configured in your VWO application settings, that interval will be used\n3. Default Fallback: If neither of the above is set, a 10 minute (600,000 milliseconds) polling interval is used\n\nSetting this parameter ensures your application always uses the latest configuration by periodically checking for and applying any updates.\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  pollInterval: 60000,\n});\n```\n\n### Gateway\n\nThe VWO FME Gateway Service is an optional but powerful component that enhances VWO's Feature Management and Experimentation (FME) SDKs. It acts as a critical intermediary for pre-segmentation capabilities based on user location and user agent (UA). By deploying this service within your infrastructure, you benefit from minimal latency and strengthened security for all FME operations.\n\n#### Why Use a Gateway?\n\nThe Gateway Service is required in the following scenarios:\n\n- When using pre-segmentation features based on user location or user agent.\n- For applications requiring advanced targeting capabilities.\n- It's mandatory when using any thin-client SDK (e.g., Go).\n\n#### How to Use the Gateway\n\nThe gateway can be customized by passing the `gatewayService` parameter in the `init` configuration.\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  gatewayService: {\n    url: 'https://custom.gateway.com',\n  },\n});\n```\n\nRefer to the [Gateway Documentation](https://developers.vwo.com/v2/docs/gateway-service) for further details.\n\n### User Aliasing\n\nUser aliasing lets you associate an existing user ID with an alternate ID (alias) so future evaluations and tracking use a unified identity across systems.\n\nRequirements:\n\n- Gateway must be configured.\n- Aliasing must be enabled during initialization: `isAliasingEnabled: true`\n\nInitialization example:\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  isAliasingEnabled: true,\n  gatewayService: { url: 'https://custom.gateway.com' },\n});\n```\n\nUsage examples:\n\n```javascript\n// Using context object\nconst success1 = await vwoClient.setAlias({ id: 'user-123' }, 'alias-abc');\n\n// Using direct userId\nconst success2 = await vwoClient.setAlias('user-123', 'alias-abc');\n```\n\nBehavior and validations:\n\n- Returns `true` on success, `false` otherwise\n- Requires aliasing to be enabled and gateway configured\n- `aliasId` must be a non-empty string (not an array); it is trimmed before use\n- For context usage, `context.id` must be a non-empty string (not an array); it is trimmed before use\n- `userId` and `aliasId` cannot be the same\n\n### Storage\n\nThe SDK operates in a stateless mode by default, meaning each `getFlag` call triggers a fresh evaluation of the flag against the current user context.\n\nTo optimize performance and maintain consistency, you can implement a custom storage mechanism by passing a `storage` parameter during initialization. This allows you to persist feature flag decisions in your preferred database system (like Redis, MongoDB, or any other data store).\n\nKey benefits of implementing storage:\n\n- Improved performance by caching decisions\n- Consistent user experience across sessions\n- Reduced load on your application\n\nThe storage mechanism ensures that once a decision is made for a user, it remains consistent even if campaign settings are modified in the VWO Application. This is particularly useful for maintaining a stable user experience during A/B tests and feature rollouts.\n\n```javascript\nclass StorageConnector extends StorageConnector {\n  constructor() {\n    super();\n  }\n\n  /**\n   * Get data from storage\n   * @param {string} featureKey\n   * @param {string} userId\n   * @returns {Promise\u003cObject\u003e}\n   */\n  async get(featureKey, userId) {\n    // return await data (based on featureKey and userId)\n  }\n\n  /**\n   * Set data in storage\n   * @param {object} data\n   */\n  async set(data) {\n    // Set data corresponding to a featureKey and user ID\n    // Use data.featureKey and data.userId to store the above data for a specific feature and a user\n  }\n}\n\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  storage: StorageConnector,\n});\n```\n\n### Client Storage\n\nIn browser environments, the SDK automatically uses `localStorage` to persist user data. You can customize this behavior using the `clientStorage` option:\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  clientStorage: {\n    key: 'vwo_data', // defaults to vwo_fme_data\n    provider: sessionStorage, // defaults to localStorage\n    isDisabled: false, // defaults to false, set to true to disable storage\n  },\n});\n```\n\n| **Parameter** | **Description**                                   | **Required** | **Type** | **Default**      |\n| ------------- | ------------------------------------------------- | ------------ | -------- | ---------------- |\n| `key`         | Key used to store data in browser storage         | No           | String   | `'vwo_fme_data'` |\n| `provider`    | Storage provider (localStorage or sessionStorage) | No           | Object   | `localStorage`   |\n| `isDisabled`  | Disable browser storage completely                | No           | Boolean  | `false`          |\n\nNote: This feature is only applicable in browser environments. In Node.js environments, you should continue using the `storage` option for custom storage implementations.\n\n### Logger\n\nVWO by default logs all `ERROR` level messages to your server console.\nTo gain more control over VWO's logging behaviour, you can use the `logger` parameter in the `init` configuration.\n\n| **Parameter** | **Description**                        | **Required** | **Type** | **Example**           |\n| ------------- | -------------------------------------- | ------------ | -------- | --------------------- |\n| `level`       | Log level to control verbosity of logs | Yes          | String   | `DEBUG`               |\n| `prefix`      | Custom prefix for log messages         | No           | String   | `'CUSTOM LOG PREFIX'` |\n| `transport`   | Custom logger implementation           | No           | Object   | See example below     |\n\n#### Example 1: Set log level to control verbosity of logs\n\n```javascript\nconst vwoClient1 = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  logger: {\n    level: 'DEBUG',\n  },\n});\n```\n\n#### Example 2: Add custom prefix to log messages for easier identification\n\n```javascript\nconst vwoClient2 = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  logger: {\n    level: 'DEBUG',\n    prefix: 'CUSTOM LOG PREFIX',\n  },\n});\n```\n\n#### Example 3: Implement custom transport to handle logs your way\n\nThe `transport` parameter allows you to implement custom logging behavior by providing your own logging functions. You can define handlers for different log levels (`debug`, `info`, `warn`, `error`, `trace`) to process log messages according to your needs.\n\nFor example, you could:\n\n- Send logs to a third-party logging service\n- Write logs to a file\n- Format log messages differently\n- Filter or transform log messages\n- Route different log levels to different destinations\n\nThe transport object should implement handlers for the log levels you want to customize. Each handler receives the log message as a parameter.\n\n```javascript\nconst vwoClient3 = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  logger: {\n    transport: {\n      level: 'INFO',\n      log: (level, message) =\u003e {\n        // your custom implementation here\n      },\n    },\n  },\n});\n```\n\nFor multiple transports you can use the `transports` parameter. For example:\n\n```javascript\nconst vwoClient3 = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  logger: {\n    transports: [\n      {\n        level: 'INFO',\n        log: (level, message) =\u003e {\n          // your custom implementation here\n        },\n      },\n      {\n        level: 'ERROR',\n        log: (level, message) =\u003e {\n          // your custom implementation here\n        },\n      },\n    ],\n  },\n});\n```\n\n### Integrations\n\nVWO FME SDKs provide seamless integration with third-party tools like analytics platforms, monitoring services, customer data platforms (CDPs), and messaging systems. This is achieved through a simple yet powerful callback mechanism that receives VWO-specific properties and can forward them to any third-party tool of your choice.\n\n```javascript\nconst vwoClient = await vwo.init({\n  sdkKey: '32-alpha-numeric-sdk-key', //replace with the SDK key for your environment\n  accountId: '123456', //replace with your VWO account ID\n  integrations: {\n    callback(properties) {\n      // your custom implementation here\n    },\n  },\n});\n```\n\n### Wait for Tracking Calls\n\nThe `shouldWaitForTrackingCalls` is an optional parameter that allows you to control whether the SDK should wait for tracking calls to complete before resolving promises. When enabled, tracking API calls will wait for the server response before resolving.\n\nThis is particularly useful for edge computing environments like Cloudflare Workers, where it ensures that tracking calls complete before resolving the promise.\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  shouldWaitForTrackingCalls: true,\n});\n```\n\n### Batch Events\n\nThe `batchEventData` configuration allows you to optimize network requests by batching multiple events together. This is particularly useful for high-traffic applications where you want to reduce the number of API calls.\n\n| **Parameter**         | **Description**                                                         | **Required** | **Type** | **Default** |\n| --------------------- | ----------------------------------------------------------------------- | ------------ | -------- | ----------- |\n| `requestTimeInterval` | Time interval (in seconds) after which events are flushed to the server | No           | Number   | `600`       |\n| `eventsPerRequest`    | Maximum number of events to batch together before sending to the server | No           | Number   | `100`       |\n| `flushCallback`       | Callback function to be executed after events are flushed               | No           | Function | See example |\n\nExample usage:\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  batchEventData: {\n    requestTimeInterval: 60, // Flush events every 60 seconds\n    eventsPerRequest: 100, // Send up to 100 events per request\n    flushCallback: (error, events) =\u003e {\n      console.log('Events flushed successfully');\n      // custom implementation here\n    },\n  },\n});\n```\n\nYou can also manually flush events using the `flushEvents()` method:\n\n```javascript\nvwoClient.flushEvents();\n```\n\n### Retry Config\n\nThe `retryConfig` parameter allows you to customize the retry behavior for network requests. This is particularly useful for applications that need to handle network failures gracefully with exponential backoff strategies.\n\n| **Parameter**       | **Description**                                           | **Required** | **Type** | **Default** | **Validation**                      |\n| ------------------- | --------------------------------------------------------- | ------------ | -------- | ----------- | ----------------------------------- |\n| `shouldRetry`       | Whether to enable automatic retry on network failures     | No           | Boolean  | `true`      | Must be a boolean value             |\n| `maxRetries`        | Maximum number of retry attempts before giving up         | No           | Number   | `3`         | Must be a non-negative integer \u003e= 1 |\n| `initialDelay`      | Initial delay (in seconds) before the first retry attempt | No           | Number   | `2`         | Must be a non-negative integer \u003e= 1 |\n| `backoffMultiplier` | Multiplier for exponential backoff between retry attempts | No           | Number   | `2`         | Must be a non-negative integer \u003e= 2 |\n\n#### How Retry Logic Works\n\nThe SDK implements an exponential backoff strategy for retrying failed network requests:\n\n1. **Initial Request**: The SDK attempts the initial network request\n2. **On Failure**: If the request fails and `shouldRetry` is `true`, the SDK waits for `initialDelay` seconds\n3. **Exponential Backoff**: For subsequent retries, the delay is calculated as: `initialDelay × (backoffMultiplier ^ attempt)`\n4. **Maximum Attempts**: The SDK will retry up to `maxRetries` times before giving up\n\n#### Example Usage\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  retryConfig: {\n    shouldRetry: true, // Enable retries\n    maxRetries: 5, // Retry up to 5 times\n    initialDelay: 3, // Wait 3 seconds before first retry\n    backoffMultiplier: 2, // Double the delay for each subsequent retry\n  },\n});\n```\n\nWith this configuration, the retry delays would be:\n\n- 1st retry: 3 seconds (3 × 2^0)\n- 2nd retry: 6 seconds (3 × 2^1)\n- 3rd retry: 12 seconds (3 × 2^2)\n- 4th retry: 24 seconds (3 × 2^3)\n- 5th retry: 48 seconds (3 × 2^4)\n\n### Edge Config\n\nThe `edgeConfig` option enables edge/serverless environment optimizations. This configuration should only be passed in serverless environments (e.g., Cloudflare Workers). When used in Cloudflare environments, events are automatically flushed using `ctx.waitUntil(vwoClient.flushEvents());` to ensure proper event tracking after execution completes.\n\n| **Parameter**                | **Description**                                           | **Required** | **Type** | **Default** |\n| ---------------------------- | --------------------------------------------------------- | ------------ | -------- | ----------- |\n| `shouldWaitForTrackingCalls` | Ensures tracking calls complete before resolving promises | Yes          | Boolean  | `false`     |\n\n#### Example Usage\n\n```javascript\nconst vwoClient = await init({\n  accountId: '123456',\n  sdkKey: '32-alpha-numeric-sdk-key',\n  edgeConfig: {\n    shouldWaitForTrackingCalls: true,\n  },\n});\n\n// at the end flush all events\nawait vwoClient.flushEvents();\n```\n\n**Note:** In Cloudflare, use `ctx.waitUntil(vwoClient.flushEvents());` to ensure all events flush.\n\n### Get UUID for a user and VWO account\n\nThe `getUUID` method allows you to generate a UUID that gets stored on VWO by providing a `userId` and `accountId`. This UUID is generated using a deterministic algorithm based on the user and account identifiers, ensuring consistent UUID generation for the same user-account combination.\n\n#### Parameters\n\n| **Parameter** | **Description**                    | **Required** | **Type** | **Example**  |\n| ------------- | ---------------------------------- | ------------ | -------- | ------------ |\n| `userId`      | The unique identifier for the user | Yes          | String   | `'user-123'` |\n| `accountId`   | The account ID                     | Yes          | String   | `'123456'`   |\n\n#### Return Value\n\nReturns a UUID string formatted without dashes and in uppercase (e.g., `'CC25A368ADA0542699EAD62489811105'`).\n\n#### Example Usage\n\n```javascript\nconst { getUUID } = require('vwo-fme-node-sdk');\n\n// Generate UUID for a user\nconst userId = 'user-123';\nconst accountId = '123456';\nconst uuid = getUUID(userId, accountId);\n\nconsole.log('Generated UUID:', uuid);\n// Output: Generated UUID: CC25A368ADA0542699EAD62489811105\n```\n\n### Multiple SDK Instances\n\nThe SDK supports creating multiple instances, each with its own isolated configuration, services, and state. This is particularly useful when you need to work with multiple VWO accounts or environments simultaneously.\n\n```javascript\nconst { init } = require('vwo-fme-node-sdk');\n\n// Initialize multiple VWO clients with different account IDs and SDK keys\n(async function () {\n  // First instance for production environment\n  const vwoClientProd = await init({\n    accountId: '123456',\n    sdkKey: '32-alpha-numeric-sdk-key-prod',\n  });\n\n  // Second instance for staging environment\n  const vwoClientStaging = await init({\n    accountId: '789012',\n    sdkKey: '32-alpha-numeric-sdk-key-staging',\n  });\n\n  // Each instance operates independently with its own settings and state\n  const userContext = { id: 'unique_user_id' };\n\n  // Use production client\n  const prodFeature = await vwoClientProd.getFlag('feature_key', userContext);\n  console.log('Production feature enabled:', prodFeature.isEnabled());\n\n  // Use staging client\n  const stagingFeature = await vwoClientStaging.getFlag('feature_key', userContext);\n  console.log('Staging feature enabled:', stagingFeature.isEnabled());\n})();\n```\n\nEach SDK instance maintains its own:\n\n- Settings and configuration\n- Services (storage, logger, network layer, etc.)\n- Utils and helper functions\n- State and cached data\n\nThis ensures complete isolation between instances, allowing you to safely use multiple VWO accounts or environments in the same application without any interference.\n\n### Version History\n\nThe version history tracks changes, improvements, and bug fixes in each version. For a full history, see the [CHANGELOG.md](https://github.com/wingify/vwo-fme-node-sdk/blob/master/CHANGELOG.md).\n\n## Development and Testing\n\n### Install Dependencies and Bootstrap Git Hooks\n\n```bash\nyarn install\n```\n\n### Compile TypeScript to JavaScript\n\n```bash\nyarn build\n```\n\n### Run Tests\n\n```bash\n# production tests\nyarn run test:prod\n\n# development tests\nyarn run test:dev\n```\n\n## Contributing\n\nWe welcome contributions to improve this SDK! Please read our [contributing guidelines](https://github.com/wingify/vwo-fme-node-sdk/blob/master/CONTRIBUTING.md) before submitting a PR.\n\n## Code of Conduct\n\nOur [Code of Conduct](https://github.com/wingify/vwo-fme-node-sdk/blob/master/CODE_OF_CONDUCT.md) outlines expectations for all contributors and maintainers.\n\n## License\n\n[Apache License, Version 2.0](https://github.com/wingify/vwo-fme-node-sdk/blob/master/LICENSE)\n\nCopyright 2024-2026 Wingify Software Pvt. Ltd.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwingify%2Fvwo-fme-node-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwingify%2Fvwo-fme-node-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwingify%2Fvwo-fme-node-sdk/lists"}