Initialization
To create a VWO Client instance, you need to initialize the VWO FME Ruby SDK. This client instance serves as the core interface for conducting feature management and experimentation(A/B and personalization) within your application.
Usage
require 'vwo'
# Initialize VWO client
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key'
});
The init()
function is called with the sdk_key
and account_id
. It initializes and returns a VWO Client Objectvwo_client
, 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 |
---|---|---|
account_id Required | Integer | Your VWO application's Account ID. |
sdk_key Required | String | A unique environment key is provided to you inside the Websites & Apps section in the VWO application, under Default Project. |
poll_interval Optional | Integer | Time (in milliseconds) at which VWO should check with the server for any updates to the feature flag or rules in the VWO Dashboard. Useful to keep your VWO Client instance up-to-date with any changes made in the VWO Application. For more details, please check -Polling |
logger Optional | Hash | An optional logger object that defines the logging behavior. For more details, please check - Logging |
storage Optional | Hash | Storage Service, if required, can be implemented using this parameter. For more details, please check - Storage Service |
gateway_service Optional | Hash | If using the FME Gateway Service, this object will specify the location and port of where the gateway service is deployed on your servers. |
integrations Optional | Hash | 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 |
threading | Hash | Toggle threading for better performance (enabled by default). |
Poll Interval (Keeping VWO client up-to-date)
When you initialize the vwo_client on your server, it pulls the latest configurations you've done in the VWO application.
If/when you make any changes to the feature flags or rules within VWO after the vwo_client has been initialized in your server, there needs to be some way to update your vwo_client with the latest settings from VWO. 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 VWO server at specified intervals. Setting this parameter ensures your application always uses the latest configuration.
# Init options with poll_interval
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key',
poll_interval: 60000
});
Logger
VWO by default logs all ERROR level messages to your server console. To gain more control over VWO's logging behavior, you can use the logger parameter in the init configuration.
# Init options with logger
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '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 get_flag 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
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key',
storage: StorageConnector.new
})
Please click here to learn more about storage implementation.
Gateway Service
The VWO FME Gateway Service enhances Feature Management and Experimentation (FME) 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
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key',
gateway_service: {
url: 'http://custom.gateway.com',
},
});
Please click here to learn more about gateway service.
Integrations
VWO 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.
def callback(data)
puts "Integration data: #{data}"
end
# Init options with integrations
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key',
integrations: {
callback: method(:callback)
}
})
Please click here to learn more about Integrations,.
Threading
The SDK leverages threading to efficiently manage concurrent operations. Threading is enabled by default, but can be disabled by configuring the threading parameter during initialization. This gives you control over the SDK's concurrency behavior based on your application's needs.
Disable Threading: When threading is disabled, all tracking calls will block the main execution thread until they complete. This means your application will wait for each VWO operation before continuing.
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key',
threading: {
enabled: false
},
})
Enable Threading (Default): When enabled, all tracking calls are processed asynchronously in the background. This prevents these network calls from blocking your application's main execution flow. The SDK uses a thread pool to manage these concurrent operations efficiently. The default pool size of 5 threads is suitable for most applications, but you can adjust it based on your needs:
vwo_client = VWO.init({
account_id: '123456',
sdk_key: '32-alpha-numeric-sdk-key',
threading: {
enabled: true,
max_pool_size: 10
},
})
Updated 28 days ago