Initialization
To create a Wingify Client instance, you need to initialize the Wingify FE Node SDK. This client instance serves as the core interface for conducting Feature Experimentation(A/B and personalization) within your application.
#Usage
const { init } = require('wingify-fme-node-sdk');
const wingifyClient = await init({
accountId: '123456', // Wingify Account ID
sdkKey: '32-alpha-numeric-sdk-key', // SDK Key
});
The init() function is called with the sdkKeyand accountId. It initializes and returns a Wingify Client Object wingifyClient, which can be used to perform feature
This client object allows you to run experiments, track events, and enable/disable feature flags.
#Parameter Definitions
| Parameter |
|---|
| **accountId** _Required_ |
#Poll Interval (Keeping Wingify client up-to-date)
When you initialize the wingifyClient on your server, it pulls the latest configurations you've done in the Wingify application.
If/when you make any changes to the feature flags or rules within Wingify after the wingifyClient has been initialized in your server, there needs to be some way to update your wingifyClient with the latest settings from. This can be done via polling.
The poll interval is an optional parameter that allows the SDK to automatically fetch and update settings from the Wingify server at specified intervals. Setting this parameter ensures your application always uses the latest configuration.
// Init options with pollInterval
const wingifyClient = await init({
accountId: '123456', // Wingify Account ID
sdkKey: '32-alpha-numeric-sdk-key',
pollInterval: 60000,
});
#Logger
Wingify by default logs all ERROR level messages to your server console. To gain more control over Wingify's logging behavior, you can use the logger parameter in the init configuration.
// Init options with logger
const wingifyClient = await init({
accountId: '123456', // Wingify Account ID
sdkKey: '32-alpha-numeric-sdk-key',
logger: {
level: 'DEBUG',
},
});
Please click here for more advanced logger options.
#Storage
By default, the SDK operates in stateless mode, evaluating flags on each getFlag call. To improve performance and consistency, you can use a custom storage mechanism to cache decisions, ensuring stable user experiences and reducing application load.
// Init options with storage
const wingifyClient = await init({
accountId: '123456',
sdkKey: '32-alpha-numeric-sdk-key',
storage: StorageConnector,
});
Please click here to learn more about storage implementation.
#Gateway Service
The Wingify FE Gateway Service enhances Feature Experimentation (FE) SDKs by enabling pre-segmentation based on user location and user agent. It ensures minimal latency and improved security. The service can be customized via the gateway_service parameter during initialization.
// Init options with gateway_service
const wingifyClient = await init({
accountId: '123456',
sdkKey: '32-alpha-numeric-sdk-key',
gatewayService: {
url: 'https://custom.gateway.com',
},
});
Please click here to learn more about the Wingify Gateway service.
#Integrations
Wingify FE 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 Wingify-specific properties and can forward them to any third-party tool of your choice.
// Init options with integrations
const wingifyClient = await wingify.init({
accountId: '123456', //replace with your Wingify account ID
sdkKey: '32-alpha-numeric-sdk-key', //replace with the SDK key for your environment
integrations: {
callback (properties) {
console.log('Integrations callback', properties); // list of keys
}
}
})
Please click here to learn more about Integrations,.
#Initialization with Explicit Settings
The SDK provides the ability to reduce initialization time by allowing users to explicitly pass in settings instead of fetching them automatically. This can be especially useful in environments where you need to optimize for faster setup or if you already have the necessary settings retrieved from a remote server.
Please refer to
const localSettings = {
"accountId": '123456',
"sdkKey": '32-alpha-numeric-sdk-key',
"features": {
// features json here
},
"campaigns": {
// campaigns json here
},
"version": 1,
};
const wingifyClient = await init({
accountId: '123456',
sdkKey: '32-alpha-numeric-sdk-key',
settings: localSettings // Pass the settings object here
});
#Retry Configuration
The SDK includes a built-in retry mechanism to improve reliability when network requests fail due to transient issues such as timeouts or temporary connectivity problems. You can fully control this behavior by providing a retryConfig object during SDK initialization.
const wingifyClient = await init({
accountId: '123456',
sdkKey: '32-alpha-numeric-sdk-key',
retryConfig: {
shouldRetry: true, // Turn retries on/off (default: true)
maxRetries: 3, // How many times to retry (default: 3)
initialDelay: 2, // First retry after 2 seconds (default: 2)
backoffMultiplier: 2, // Double the delay each time (delays: 2s, 4s, 8s)
},
});
Please click
#ProxyUrl
Wingify FE SDKs provide support for redirecting all network calls through a custom proxy URL. This feature enables users to route all SDK network requests (including settings, tracking, etc.) through their own proxy server.
const wingifyClient = await init({
accountId: '123456',
sdkKey: '32-alpha-numeric-sdk-key',
proxyUrl: "https://proxy.yourdomain.com",
// other configuration options
});
Please click