Initialization
Initialize an instance of VWO which will then be used to manage all feature flags and rules. This vwoInstance instance contains all the feature flags and rules that you have configured in your VWO dashboard.
Usage
import com.vwo.VWO;
import com.vwo.models.user.VWOContext;
import com.vwo.models.user.GetFlag;
import com.vwo.models.user.VWOInitOptions;
Map<String, Object> logger = new HashMap<>();
logger.put("level", "INFO");
logger.put("prefix", "VWO");
// Initialize VWO SDK
VWOInitOptions vwoInitOptions = new VWOInitOptions();
// Set SDK Key and Account ID
vwoInitOptions.setSdkKey("sdk-key"); //SDK Key
vwoInitOptions.setAccountId(123); //account ID
vwoInitOptions.setPollInterval(60);
vwoInitOptions.setLogger(logger);
// create VWO instance with the vwoInitOptions
VWO vwoInstance = VWO.init(vwoInitOptions);
As shown above, to initialize vwoInstance, you need first to initialize the SDK, and set the SDK key and Account ID into vwoInitOptions, after which you must call the vwo.init() function with vwoInstance as an argument.
vwoInstance has a set of callback functions available, which can be used to set additional parameters, of which two are mandatory:
- accountId: This is the unique VWO account ID which you can find on your VWO Dashboard.
- sdkKey: A unique 32-character string corresponding to the project/environment in VWO. You will find this in the Websites & Apps section in VWO, under a "Default Project" for FME.
Parameter Definitions
Besides the two mandatory parameters (accountId and sdkKey), there are some additional optional parameters that can be set using functions on vwInitOptions:
Parameter | Usage | Type | Description |
---|---|---|---|
accountId Required | vwoInitOptions.setAccountId(123); | Number | Your VWO application's Account ID. |
sdkKey Required | vwoInitOptions.setSdkKey("sdk-key"); | String | Unique environment key provided to you inside the Websites & Apps section in VWO application. |
pollInterval Optional | vwoInitOptions.setPollInterval(60); | Number | Time period (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 vwoClient instance up to date with any changes made in the VWO Application. Polling |
logger Optional | vwoInitOptions.setLogger(logger); | Object | An optional logger object that defines the logging behaviour. Logger |
storage Optional | vwoInitOptions.setStorage(storage) | Object | Storage Service, if required, can be implemented using this object Storage Service |
gatewayService Optional | vwoInitOptions.setGatewayService(new HashMap<String, Object>() { { put("url", "<https://your.host.com:port")>; } }); | Object | 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 | vwoInitOptions.setIntegrations(integrations); | Object | Contains a callback function that receives campaign data which can be pushed to any external tool that you need to integrate with. Integrations |
Keeping vwoClient up-to-date
When you initialize the vwoClient at 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 vwoClient has been initialized in your server, there needs to be some way to update your vwoClient with the latest settings from VWO. This can be done via polling.
Updated 2 months ago