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 feature flag
const flagResult: GetFlagResult = await vwoClient.getFlag('feature_flag_key', userContext);

Please note that the flag must already be defined in FM&E for this.

Parameter Definitions

ParameterTypeDescription
feature_flag_key
Required
Stringunique 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.
userContext
Required
ObjectContains information about the current user, including a required unique identifier for each user. Read more about userContext here.

isEnabled()

// check if flag is enabled
const isEnabled = flagResult.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'.