Generated the following references: - `pricing` - `product` Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
163 lines
3.1 KiB
Plaintext
163 lines
3.1 KiB
Plaintext
---
|
|
displayed_sidebar: servicesSidebar
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# FlagRouter
|
|
|
|
## Implements
|
|
|
|
- [`IFlagRouter`](../interfaces/IFlagRouter.mdx)
|
|
|
|
## Constructors
|
|
|
|
### constructor
|
|
|
|
**new FlagRouter**(`flags`)
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "flags",
|
|
"type": "Record<`string`, `boolean` \\| Record<`string`, `boolean`\\>\\>",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
## Properties
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "flags",
|
|
"type": "`any`",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
## 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
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "flag",
|
|
"type": "`string` \\| Record<`string`, `string`\\>",
|
|
"description": "The flag to check",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
`boolean`
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "boolean",
|
|
"type": "`boolean`",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"description": "- Whether the flag is enabled or not",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### listFlags
|
|
|
|
**listFlags**(): [`FeatureFlagsResponse`](../types/FeatureFlagsResponse.mdx)
|
|
|
|
#### Returns
|
|
|
|
[`FeatureFlagsResponse`](../types/FeatureFlagsResponse.mdx)
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "FeatureFlagsResponse",
|
|
"type": "{ `key`: `string` ; `value`: `boolean` \\| Record<`string`, `boolean`\\> }[]",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
### 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
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "key",
|
|
"type": "`string`",
|
|
"description": "The key of the flag to set.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "value",
|
|
"type": "`boolean` \\| { `[key: string]`: `boolean`; }",
|
|
"description": "The value of the flag to set.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|
|
|
|
#### Returns
|
|
|
|
`void`
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "void",
|
|
"type": "`void`",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"description": "- void",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]} />
|