Initialization
To create a Wingify Client instance, you need to initialize the Wingify FE React Native SDK. This client instance serves as the core interface for conducting Feature Experimentation(A/B and personalization) within your application.
Usage
import { init } from 'wingify-fme-react-native-sdk';
import {
WingifyInitOptions,
WingifyContext,
GetFlagResult,
} from 'wingify-fme-react-native-sdk/src/types';
let WingifyClient;;
// initialize sdk
useEffect(() => {
const initializeSDK = async () => {
const options: WingifyInitOptions = { sdkKey: SDK_KEY, accountId: ACCOUNT_ID };
try {
WingifyClient = await init(options);
console.log('Wingify init success');
} catch (error) {
console.error('Error initialising', error);
}
};
initializeSDK();
}, []);The init() function is called with the sdkKeyand accountId. It initializes and returns a Wingify Client ObjectWingifyClient, 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 | Type | Description |
|---|---|---|
| accountId Required | number | Your Wingify application's Account ID. |
| sdkKey Required | string | A unique environment key is provided to you inside the Websites & Apps section in the Wingify application, under Default Project. |
| logLevel Optional | enum | The level of logging to be used. For more details, please check - Logger |
| logPrefix Optional | string | A prefix to be added to log messages. For more details, please check - Logger |
| integrations Optional | boolean | A callback function that receives data which can be pushed to any external tool that you need to integrate with. For more details, please check - Integrations |
| cachedSettingsExpiryTime Optional | number | Expiry time for cached settings in milliseconds. For more details, please check - Cache Management |
| pollInterval Optional | number | Time (in milliseconds) at which Wingify should check with the server for any updates to the feature flag or rules in the Wingify Dashboard. Useful to keep your Wingify Client instance up-to-date with any changes made in the Wingify Application. For more details, please check -Polling |
| batchMinSize Optional | number | Minimum size of batch to upload. For more detail, please check - Event Batching |
| batchUploadTimeInterval Optional | number | Batch upload time interval in milliseconds. For more detail, please check - Event Batching |
Additional Callbacks
- Integration Callback: Use
Wingify.registerIntegrationCallbackto manage integration events. Refer documentation - Log Callback: Use
Wingify.registerLogCallbackto capture and handle log events. Refer documentation
Polling Interval Adjustment
The pollInterval 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.
Example usage:
const options: WingifyInitOptions = { sdkKey: SDK_KEY, accountId: ACCOUNT_ID, pollInterval: 600000 }; // 10 minutes
WingifyClient = await init(options);Cached Settings Expiry Time
The cachedSettingsExpiryTime parameter allows you to specify how long the cached settings should be considered valid before fetching new settings from the Wingify server. This helps in managing the freshness of the configuration data.
Example usage:
const options: WingifyInitOptions = { sdkKey: SDK_KEY, accountId: ACCOUNT_ID, cachedSettingsExpiryTime: 600000 }; // 10 minutes
WingifyClient = await init(options);Event Batching Configuration
The Wingify SDK supports storing impression events while the device is offline, ensuring no data loss. These events are batched and seamlessly synchronized with Wingify servers once the device reconnects to the internet. Additionally, online event batching allows synchronization of impression events while the device is online. This feature can be configured by setting either the minimum batch size or the batch upload time interval during SDK initialization.
NOTE: The batching will trigger based on whichever condition is met first if using both options.
| Parameter | Description | Required | Type | Example |
|---|---|---|---|---|
batchMinSize | Minimum size of the batch to upload. | No | number | 10 |
batchUploadTimeInterval | Batch upload time interval in milliseconds. Please specify at least a few minutes. | No | number | 300000 |
Example usage:
const options: WingifyInitOptions = { sdkKey: SDK_KEY, accountId: ACCOUNT_ID, batchMinSize: 10, batchUploadTimeInterval: 300000 }; // 5 minutes
WingifyClient = await init(options);Updated 27 days ago