Skip to main content
Skip to main content

FlagRouter

admin/discounts.internal.FlagRouter

Implements

Properties

flagsanyRequired

Methods

isFeatureEnabled

isFeatureEnabled(flag): boolean

Check if a feature flag is enabled. There are two ways of using this method:

  1. isFeatureEnabled("myFeatureFlag")
  2. 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

flagstring | Record<string, string>Required
The flag to check

Returns

boolean

booleanboolean
Whether the flag is enabled or not

Implementation of

IFlagRouter.isFeatureEnabled


listFlags

listFlags(): FeatureFlagsResponse

Returns

FeatureFlagsResponse

FeatureFlagsResponse{ key: string ; value: boolean | Record<string, boolean> }[]Required
Schema 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

IFlagRouter.listFlags


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

keystringRequired
The key of the flag to set.
valueboolean | { [key: string]: boolean; }Required
The value of the flag to set.

Returns

void

voidvoid
void
Was this section helpful?