You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -119,7 +119,7 @@ The Azure App Configuration service also delivers the feature flags to your appl
119
119
120
120
The App Configuration JavaScript provider provides feature flags in a `Map` object. The built-in `ConfigurationMapFeatureFlagProvider` helps to load feature flags in this case.
@@ -137,7 +137,7 @@ const featureManager = new FeatureManager(featureProvider);
137
137
138
138
The following example shows the format used to set up feature flags in a JSON file.
139
139
140
-
```json
140
+
```json
141
141
{
142
142
"feature_management": {
143
143
"feature_flags": [
@@ -184,7 +184,7 @@ The `requirement_type` property of a feature flag is used to determine if the fi
184
184
185
185
A `requirement_type` of `All` changes the traversal. First, if there are no filters, the feature is disabled. Then, the feature filters are traversed until one of the filters decides that the feature should be disabled. If no filter indicates that the feature should be disabled, it's considered enabled.
186
186
187
-
```json
187
+
```json
188
188
{
189
189
"feature_management": {
190
190
"feature_flags": [
@@ -223,7 +223,7 @@ The basic form of feature management is checking if a feature flag is enabled an
Creating a feature filter provides a way to enable features based on criteria that you define. To implement a feature filter, the `IFeatureFilter` interface must be implemented. `IFeatureFilter` has a `name` property and a method named `evaluate`. The `name` should be used in configuration to reference the feature filter within a feature flag. When a feature specifies that it can be enabled for a feature filter, the `evaluate` method is called. If `evaluate` returns `true`, it means the feature should be enabled.
Some feature filters require parameters to decide whether a feature should be turned on or not. For example, a browser feature filter may turn on a feature for a certain set of browsers. It may be desired that Edge and Chrome browsers enable a feature, while Firefox does not. To do this, a feature filter can be designed to expect parameters. These parameters would be specified in the feature configuration, and in code would be accessible via the `IFeatureFilterEvaluationContext` parameter of `IFeatureFilter.Evaluate`.
@@ -331,7 +331,7 @@ This filter provides the capability to enable a feature based on a time window.
331
331
332
332
This filter provides the capability to enable a feature for a target audience. An in-depth explanation of targeting is explained in the [targeting](#targeting) section below. The filter parameters include an `Audience` object that describes users, groups, excluded users/groups, and a default percentage of the user base that should have access to the feature. Each group object that is listed in the `Groups` section must also specify what percentage of the group's members should have access. If a user is specified in the `Exclusion` section, either directly or if the user is in an excluded group, the feature is disabled. Otherwise, if a user is specified in the `Users` section directly, or if the user is in the included percentage of any of the group rollouts, or if the user falls into the default rollout percentage then that user will have the feature enabled.
333
333
334
-
```JavaScript
334
+
```typescript
335
335
"client_filters": [
336
336
{
337
337
"name": "Microsoft.Targeting",
@@ -385,15 +385,15 @@ This strategy for rolling out a feature is built into the library through the in
385
385
386
386
The targeting filter relies on a targeting context to evaluate whether a feature should be turned on. This targeting context contains information such as what user is currently being evaluated, and what groups the user is in. The targeting context must be passed directly when `isEnabled` is called.
When defining an audience, users and groups can be excluded from the audience. Exclusions are useful for when a feature is being rolled out to a group of users, but a few users or groups need to be excluded from the rollout. Exclusion is defined by adding a list of users and groups to the `Exclusion` property of the audience.
395
395
396
-
```json
396
+
```json
397
397
"Audience": {
398
398
"Users": [
399
399
"Jeff",
@@ -416,11 +416,6 @@ When defining an audience, users and groups can be excluded from the audience. E
416
416
417
417
In the above example, the feature is enabled for users named `Jeff` and `Alicia`. It's also enabled for users in the group named `Ring0`. However, if the user is named `Mark`, the feature is disabled, regardless of if they are in the group `Ring0` or not. Exclusions take priority over the rest of the targeting filter.
418
418
419
-
:::zone target="docs" pivot="stable-version"
420
-
:::zone-end
421
-
422
-
:::zone target="docs" pivot="preview-version"
423
-
424
419
## Variants
425
420
426
421
When new features are added to an application, there may come a time when a feature has multiple different proposed design options. A common solution for deciding on a design is some form of A/B testing, which involves providing a different version of the feature to different segments of the user base and choosing a version based on user interaction. In this library, this functionality is enabled by representing different configurations of a feature with variants.
@@ -431,7 +426,7 @@ Variants enable a feature flag to become more than a simple on/off flag. A varia
431
426
432
427
For each feature, a variant can be retrieved using the `FeatureManager`'s `getVariant` method. The variant assignment is dependent on the user currently being evaluated, and that information is obtained from the targeting context you passed in.
// Do something with the resulting variant and its configuration
441
436
```
442
437
443
-
444
438
### Variant feature flag declaration
445
439
446
440
Compared to normal feature flags, variant feature flags have two more properties: `variants` and `allocation`. The `variants` property is an array that contains the variants defined for this feature. The `allocation` property defines how these variants should be allocated for the feature. Just like declaring normal feature flags, you can set up variant feature flags in a JSON file. Here's an example of a variant feature flag.
447
441
448
-
```json
442
+
```json
449
443
{
450
444
"feature_management": {
451
445
"feature_flags": [
@@ -483,7 +477,7 @@ Each variant has two properties: a name and a configuration. The name is used to
483
477
484
478
A list of all possible variants is defined for each feature under the `variants` property.
485
479
486
-
```json
480
+
```json
487
481
{
488
482
"feature_management": {
489
483
"feature_flags": [
@@ -513,7 +507,7 @@ A list of all possible variants is defined for each feature under the `variants`
513
507
514
508
The process of allocating a feature's variants is determined by the `allocation` property of the feature.
515
509
516
-
```json
510
+
```json
517
511
"allocation": {
518
512
"default_when_enabled": "Small",
519
513
"default_when_disabled": "Small",
@@ -571,7 +565,6 @@ If the feature is enabled, the feature manager checks the `user`, `group`, and `
571
565
572
566
Allocation logic is similar to the [Microsoft.Targeting](#microsofttargeting) feature filter, but there are some parameters that are present in targeting that aren't in allocation, and vice versa. The outcomes of targeting and allocation aren't related.
573
567
574
-
575
568
### Overriding enabled state with a variant
576
569
577
570
You can use variants to override the enabled state of a feature flag. Overriding gives variants an opportunity to extend the evaluation of a feature flag. When calling `is_enabled` on a flag with variants, the feature manager will check if the variant assigned to the current user is configured to override the result. Overriding is done using the optional variant property `status_override`. By default, this property is set to `None`, which means the variant doesn't affect whether the flag is considered enabled or disabled. Setting `status_override` to `Enabled` allows the variant, when chosen, to override a flag to be enabled. Setting `status_override` to `Disabled` provides the opposite functionality, therefore disabling the flag when the variant is chosen. A feature with an `enabled` state of `false` can't be overridden.
@@ -655,7 +648,7 @@ You can register an `onFeatureEvaluated` callback function when creating `Featur
655
648
656
649
The following example shows how to implement a custom callback function to send telemetry with the information extracted from the feature evaluation result and register it to the feature manager.
657
650
658
-
```javascript
651
+
```typescript
659
652
const sendTelemetry = (evaluationResult) => {
660
653
const featureId =evaluationResult.feature.id;
661
654
const featureEnabled =evaluationResult.enabled;
@@ -678,7 +671,7 @@ The Application Insights offers different sdks for [web](https://www.npmjs.com/p
678
671
679
672
If your application runs in the browser, install the [`"@microsoft/feature-management-applicationinsights-browser"`](https://www.npmjs.com/package/@microsoft/feature-management-applicationinsights-browser) package. The following example shows how you can create a built-in Application Insights telemetry publisher and register it to the feature manager.
If your application runs in the Node.js, install the [`"@microsoft/feature-management-applicationinsights-node"`](https://www.npmjs.com/package/@microsoft/feature-management-applicationinsights-node) package. The following example shows how you can create a built-in Application Insights telemetry publisher and register it to the feature manager.
The telemetry publisher sends `FeatureEvaluation` custom events to the Application Insights when a feature flag enabled with telemetry is evaluated. The custom event follows the [FeatureEvaluationEvent](https://github.com/microsoft/FeatureManagement/tree/main/Schema/FeatureEvaluationEvent) schema.
721
714
722
-
:::zone-end
723
-
724
715
## Next steps
725
716
726
717
To learn how to use feature flags in your applications, continue to the following quickstarts.
0 commit comments