Skip to content

Commit

Permalink
docs: feature flag naming patterns (#4632)
Browse files Browse the repository at this point in the history
This PR adds a reference doc and a how-to doc for feature flag naming
patterns.

Extra thanks to @sebastian-bury for the draft from the offsite 👏🏼
  • Loading branch information
thomasheartman authored Sep 11, 2023
1 parent f88e15c commit 4de3ff3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
28 changes: 28 additions & 0 deletions website/docs/how-to/how-to-add-feature-flag-naming-patterns.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: How to add feature flag naming patterns
---

:::info Availability

Feature flag naming patterns is an in-development, **enterprise-only** feature.

:::

This short guide will show you how to add [feature flag naming patterns](../reference/feature-flag-naming-patterns.mdx) to a project.

## Prerequisites

- You must be using an Unleash Enterprise instance.
- You must have permissions to edit project settings for the project you want to add feature flag naming patterns to.

## Step 1: Navigate to project settings

Navigate to the project settings page for the project you want to add feature flag naming patterns to.

## Step 2: Add a feature flag naming pattern

Use the "feature flag naming pattern" section of the project settings form to add a feature flag naming pattern, plus the optional example and/or description.

When you've entered you're data, save the changes.

![The "feature flag naming pattern" part of the form. Input fields for pattern, example, and description](/img/naming-pattern-forms.png)
30 changes: 30 additions & 0 deletions website/docs/reference/feature-flag-naming-patterns.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Feature Flag Naming Patterns
---

:::info Availability

Feature flag naming patterns is an in-development, **enterprise-only** feature.

:::

A feature flag naming pattern is [JavaScript regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) that is used to validate the name of a feature flag before the flag can be created. The pattern is defined in the project settings and is enforced when creating a new feature flag. The pattern is also enforced when creating a new feature flag via the API.

Feature flag naming patterns are defined on a per-project basis.

In addition to the pattern itself, you can also define a an example and a description of the pattern. If defined, both the example and the description will be shown to the user when they are creating a new feature flag.

## Overview

The naming pattern consists of three parts:

<dl>
<dt><strong>Pattern</strong> (required)</dt>
<dd>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">regular expression</a> that is used to validate the name of the feature flag. Must be a valid regular expression. Flags (such as case insensitivity) are not available.</dd>
<dt><strong>Example</strong> (optional)</dt>
<dd>An example of a name that is valid according to the provided pattern. Note: the example <strong>must</strong> be valid against the described pattern for it to be saved.</dd>
<dt><strong>Description</strong> (optional)</dt>
<dd>Any additional text that you would like to display to users to provide extra information. This can be anything that you think they would find useful and can be as long or short as you want.</dd>
</dl>

For instance, you might define a pattern that requires all feature flags to follow a specific pattern, such as `^(red|blue|green|yellow)\.[a-z-]+\.[0-9]+$`. You could then provide an example of a valid feature flag name (for instance "blue.water-gun.64") and a description of what the pattern should reflect: "`<team>.<feature>.<ticket>`".
2 changes: 2 additions & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module.exports = {
label: 'Feature toggles, strategies, context',
items: [
'how-to/how-to-add-strategy-constraints',
'how-to/how-to-add-feature-flag-naming-patterns',
'how-to/how-to-capture-impression-data',
'how-to/how-to-create-feature-toggles',
'how-to/how-to-define-custom-context-fields',
Expand Down Expand Up @@ -347,6 +348,7 @@ module.exports = {
'reference/custom-activation-strategies',
'reference/environments',
'reference/strategy-variants',
'reference/feature-flag-naming-patterns',
'reference/feature-toggles',
'reference/feature-toggle-types',
'reference/feature-toggle-variants',
Expand Down
Binary file added website/static/img/naming-pattern-forms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4de3ff3

Please sign in to comment.