FlagRouter
admin/discounts.internal.FlagRouter
Implements
Properties
flags
anyRequiredMethods
isFeatureEnabled
isFeatureEnabled(flag
): boolean
Check if a feature flag is enabled. There are two ways of using this method:
isFeatureEnabled("myFeatureFlag")
isFeatureEnabled({ myNestedFeatureFlag: "someNestedFlag" })
We use 1. for top-level feature flags and 2. for nested feature flags. Almost all flags are top-level. An example of a nested flag is workflows. To use it, you would do:isFeatureEnabled({ workflows: Workflows.CreateCart })
Parameters
flag
string | Record<string, string>RequiredThe flag to check
Returns
boolean
boolean
boolean
Whether the flag is enabled or not
Implementation of
listFlags
listFlags(): FeatureFlagsResponse
Returns
FeatureFlagsResponse
{ key: string ; value: boolean | Record<string, boolean> }[]RequiredSchema FeatureFlagsResponse type: array items: type: object required: - key - value properties: key: description: The key of the feature flag. type: string value: description: The value of the feature flag. type: boolean
Implementation of
setFlag
setFlag(key
, value
): void
Sets a feature flag. Flags take two shapes: setFlag("myFeatureFlag", true) setFlag("myFeatureFlag", { nestedFlag: true }) These shapes are used for top-level and nested flags respectively, as explained in isFeatureEnabled.
Parameters
key
stringRequiredThe key of the flag to set.
value
boolean | { [key: string]: boolean; }RequiredThe value of the flag to set.
Returns
void
void
void
void
Was this section helpful?