Feature Flags
All the different testing, personalize and rollout rules within FM&E are built on top of "Feature Flags".
As such, the first step is to fetch the particular flag you're looking to implement for, which is done using the getFlag() function.
getFlag()
// Get the featureFlag object for the feature key and context
let featureFlagObj = VWOFme.getFlag(featureKey: "feature_flag_name", context: userContext)
Please note that the flag must already be defined in FM&E for this.
Parameter Definitions
Parameter | Type | Description |
---|---|---|
feature_key Required | String | unique identifier for the particular feature flag that you're implementing. You will see this while creating a feature flag, and you can also find it under 'Settings' for the Feature Flag after creating it. |
context Required | Object | Contains information about the current user, including a required unique identifier for each user. Read more about userContext here. |
isEnabled()
// check if flag is enabled, returns true or false
let isFlagEnabled = featureFlagObj?.isEnabled()
After fetching the flag object, you can call the isEnabled() function, which checks if that particular feature flag is enabled for the current user.
This is evaluated based on the different rules and targeting conditions configured with your feature flag.
If the current user satisfies the conditions for any rollout, testing or personalize rule connected to a specific feature flag, isEnabled() will return 'true', or else it will return 'false'.
Updated about 1 month ago