2021-02-25 16:01:36 +01:00
---
title: Strategy Constraints
---
2023-10-11 21:20:16 +02:00
import VideoContent from '@site/src/components/VideoContent.jsx'
2021-02-25 16:01:36 +01:00
2021-12-20 14:28:00 +01:00
:::info Availability
2022-10-04 14:13:52 +02:00
Before Unleash 4.16, strategy constraints were only available to Unleash Pro and Enterprise users. From 4.16 onwards, they're **available to everyone** .
2022-03-07 18:25:41 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Unleash 4.9 introduced a more comprehensive set of constraint operators. These require that both Unleash *and* your client SDK of choice support them. See the [SDK compatibility table ](../reference/sdks/index.md#strategy-constraints ) for more information. Prior to Unleash 4.9, the only available operators were `IN` and `NOT_IN` .
2022-10-04 14:13:52 +02:00
2021-12-20 14:28:00 +01:00
:::
2021-02-25 16:01:36 +01:00
2022-03-16 10:05:41 +01:00
:::caution undefined behavior
2022-10-04 14:13:52 +02:00
2022-03-18 12:19:49 +01:00
When using _advanced strategy constraints_ (any operator that isn't `IN` or `NOT_IN` ), *make sure your client SDK is up to date* and supports this feature. For older versions of the client SDKs we **cannot guarantee** any specific behavior. Please see the [incompatibilities section ](#incompatibilities ) for more information.
2022-10-04 14:13:52 +02:00
2021-12-20 14:51:32 +01:00
:::
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
**Strategy constraints** are conditions that must be satisfied for an [activation strategy ](../reference/activation-strategies ) to be evaluated for a feature toggle.
2022-03-08 11:02:24 +01:00
With strategy constraints, you can:
- roll out a feature **only to users in a specific region**
- schedule a feature to be **released at a specific time**
- make a feature available for **a limited time only**
- release a feature to users with one of a set of **email addresses**
- ... and much more!
2021-02-25 16:01:36 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Strategy constraints use fields from the [Unleash Context ](../reference/unleash-context ) to determine whether a strategy should apply or not.
You can constrain both on [standard context fields ](../reference/unleash-context#structure ) and on [custom context fields ](../reference/unleash-context#custom-context-fields ).
2021-02-25 16:01:36 +01:00
2022-03-16 10:05:41 +01:00
This page explains what strategy constraints are in Unleash and how they work. If you want to know *how you add* strategy constraints to an activation strategy, see [the corresponding how-to guide ](../how-to/how-to-add-strategy-constraints.md "how to add strategy constraints" ).
2023-10-11 21:20:16 +02:00
< VideoContent videoUrls = {["https://www.youtube.com/embed/kqtqMFhLRBE"]}/ >
2022-03-08 11:02:24 +01:00
## Constraining on custom context fields
:::info Making custom context fields available
To be able to constrain on a field, it must be listed under the Context Field menu. If a field isn't listed, you can add it yourself. See [the how-to guide for creating your own custom fields ](../how-to/how-to-define-custom-context-fields.md ) for more info.
:::
Unleash only provides a limited set of context fields by default, and they may not fulfill all your needs.
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
By using [custom context fields ](../reference/unleash-context#custom-context-fields ), you can tailor strategy constraints to your specific use case, such as:
2022-03-09 10:56:48 +01:00
- based on tenant IDs, release a feature to only specific tenants in a multi-tenant setup
2022-03-08 11:02:24 +01:00
- release a feature to users in a specific region
- release a feature only to beta testers
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
You can also combine strategy constraints with the [gradual rollout strategy ](../reference/activation-strategies#gradual-rollout ) to do a gradual rollout to a **specific segment** of your user base.
2021-02-25 16:01:36 +01:00
2022-09-29 11:43:04 +02:00
![A toggle with the gradual rollout strategy. The toggle is constrained on the custom content field "region" and set to only activate if the region is Africa or Europe. ](/img/strategy-constraints.png )
2021-12-14 11:19:16 +01:00
2022-03-07 17:21:25 +01:00
## Constraint structure
Each strategy constraint has three parts:
- a **context field** : The context field to use for evaluation.
- an **operator** : One of the [operators listed below ](#strategy-constraint-operators ).
- a **value** /**list of values**: A value or list of values to use in the evaluation of the constraint.
These parts turn the strategy constraint into an expression that evaluates to either `true` or `false` .
To clarify, here's a few example strategy constraints and what they do:
| Context field | Operator | Value(s) | Description |
|-----------------|-----------------|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| `userId` | `STR_ENDS_WITH` | `@example.com, @mycompany.com` | Evaluates to `true` for users whose user IDs end with `@example.com` or `@mycompany.com` . |
| `currentTime` | `DATE_AFTER` | `2022-06-05 21:43:22Z` | Evaluates to `true` if the current time is after `2022-06-05 21:43:22Z` . |
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
| `userScore` [^1] | `NUM_GTE` | `1000` | Evaluates to `true` if the [custom context field ](../reference/unleash-context#custom-context-fields ) `userScore` has a value of `1000` or higher. |
2022-03-07 17:21:25 +01:00
2022-03-07 15:39:32 +01:00
## Strategy constraint operators
2022-03-07 18:25:41 +01:00
:::note Placeholder context field
In this section, `<context-field>` is used as a placeholder for an arbitrary context field. With the exception of the `currentTime` field, you can use any context field in its place.
:::
2022-03-07 15:39:32 +01:00
Unleash currently supports 15 different constraint operators.
The operators can be grouped into four different categories based on their method of comparison.
2022-03-08 13:44:02 +01:00
### Constraint negation / inversion {#constraint-negation}
2022-03-07 17:00:45 +01:00
2022-03-08 13:44:02 +01:00
All constraint expressions can be **negated** , meaning that they get their opposite value. Constraints are evaluated to either `true` or `false` . Negating a constraint would turn a `true` value into a `false` and a `false` value into a `true` value.
2022-03-07 17:00:45 +01:00
For instance, using the numeric equivalence operator `NUM_EQ` , the following truth table shows the how value negation affects the result:
| Expression | Value | Negated |
|--------------|---------|---------|
| 4 `NUM_EQ` 4 | `true` | `false` |
| 4 `NUM_EQ` 5 | `false` | `true` |
2022-03-07 15:39:32 +01:00
### Numeric operators
2022-03-07 18:25:41 +01:00
Numeric operators compare the numeric values of context fields with your provided value.
Numeric operators only accept single values.
| Name | `true` if `<context-field>` is ... |
|-----------|--------------------------------------------------------------------------------|
2022-03-07 17:00:45 +01:00
| `NUM_EQ` | **equal** to the provided value; the mathematical `=` operator |
| `NUM_GT` | **strictly greater than** the provided value; the mathematical `>` operator |
| `NUM_GTE` | **greater than or equal to** the provided value; the mathematical `⩾` operator |
| `NUM_LT` | **strictly less than** the provided value; the mathematical `<` operator |
| `NUM_LTE` | **less than or equal to** the provided value; the mathematical `⩽` operator |
2022-03-07 15:39:32 +01:00
You can read more about [numeric equality ](https://en.wikipedia.org/wiki/Equality_(mathematics ) "Mathematical equality at Wikipedia") or [numeric inequality operators at Wikipedia ](https://en.wikipedia.org/wiki/Inequality_(mathematics )).
### Date and time operators
2022-03-07 18:25:41 +01:00
:::info `currentTime` and date and time operators
The date and time operators are **only available on the `currentTime`** context field. Furthermore, the `currentTime` context field **can not be used** with any of the other operators.
2022-03-07 15:39:32 +01:00
:::
With the date and time operators, you can enable a feature before and/or after a specified time.
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
The operators compare the [Unleash context's ](../reference/unleash-context ) `currentTime` property against the provided value.
2022-03-07 15:39:32 +01:00
2022-03-07 18:25:41 +01:00
You can create a **time span** by combining the two constraint operators using two different constraints on the same strategy.
2022-03-07 15:39:32 +01:00
In that case the strategy will be evaluated from `DATE_AFTER` and until `DATE_BEFORE` .
2022-03-07 18:25:41 +01:00
Date and time operators only support single values.
2022-03-07 17:00:45 +01:00
| Name | `true` if `currentTime` is ... |
|---------------|--------------------------------|
| `DATE_AFTER` | **after** the provided date |
| `DATE_BEFORE` | **before** the provided date |
2022-03-07 15:39:32 +01:00
### String operators
2022-03-07 18:25:41 +01:00
String operators differ from the other categories in two different ways:
- all operators accept multiple values
- most operators also consider [letter case ](https://en.wikipedia.org/wiki/Letter_case "letter case on Wikipedia" ) and can be set to be case-sensitive or case-insensitive
2022-03-07 17:00:45 +01:00
2022-03-08 12:57:09 +01:00
| Name | `true` if `<context-field>` ... | Supports case-insensitivity | Available since |
|-------------------|------------------------------------------------|-----------------------------|-----------------|
| `IN` | is **equal** to any of the provided values | No | v3.3 |
| `NOT_IN` | is **not equal** to any of the provided values | No | v3.3 |
| `STR_CONTAINS` | **contains** any of the provided strings | Yes | v4.9 |
| `STR_ENDS_WITH` | **ends** with any of the provided strings | Yes | v4.9 |
| `STR_STARTS_WITH` | **starts** with any of the provided strings | Yes | v4.9 |
2022-03-07 15:39:32 +01:00
2022-03-07 18:25:41 +01:00
### Versioning (SemVer) operators
The SemVer operators are used to compare version numbers such as application versions, dependency versions, etc.
2022-03-08 13:27:19 +01:00
The SemVer input must follow a few rules:
2022-03-09 10:51:24 +01:00
- The value you enter **must** start with and contain at least major, minor, and patch versions: Example: `1.2.3`
2022-03-08 13:27:19 +01:00
- Optionally, you can also add pre-release version information by adding a hyphen and series of dot separated identifiers after the patch version. Example: `1.2.3-rc.2`
Versions with pre-release indicators (e.g. `4.8.0-rc.2` ) are considered *less than* versions without (e.g. `4.8.0` ) in accordance with [the SemVer specification, item 11 ](https://semver.org/#spec-item-11 ).
You can read more about SemVer in [the full SemVer specification ](https://semver.org/ ).
2022-03-07 15:39:32 +01:00
2022-03-07 18:25:41 +01:00
SemVer operators only support single values.
2022-03-08 13:27:19 +01:00
| Name | `true` if `<context-field>` is ... |
2022-03-07 17:00:45 +01:00
|-------------|----------------------------------------------|
| `SEMVER_EQ` | **equal** to the provided value |
| `SEMVER_GT` | **strictly greater than** the provided value |
| `SEMVER_LT` | **strictly less than** the provided value |
2022-03-07 15:39:32 +01:00
2022-03-10 10:56:59 +01:00
Additionally, you can use negation to get _less than or equal to_ and _greater than or equal to_ functionality:
| Effect | How | `true` if `<context-field>` is ... |
|--------------------------|--------------------|-------------------------------------------------|
| Greater than or equal to | Negate `SEMVER_LT` | **greater than or equal to** the provided value |
| Less than or equal to | Negate `SEMVER_GT` | **less than or equal to** the provided value |
"Not less than 2.0.0" _is the same as_ "greater than or equal to 2.0.0". The same applies for _less than or equal_ : "Not greater than 1.9.5." _is the same as_ "less than or equal to 1.9.5".
2021-12-20 14:28:00 +01:00
## Interacting with strategy constraints in the client SDKs {#sdks}
2021-12-14 11:19:16 +01:00
2021-12-20 14:28:00 +01:00
:::note
This section gives a brief overview over to use the client SDKs to interact with strategy constraints. The exact steps will vary depending on which client you are using, so make sure to consult the documentation for your specific client SDK.
:::
2021-12-14 11:19:16 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Strategy constraints require [the Unleash Context ](../reference/unleash-context ) to work. All official [Unleash client SDKs ](../reference/sdks/index.md ) support the option to pass [dynamic context values ](../reference/unleash-context#structure "Unleash Context, section: structure" ) to the `isEnabled` function (or the SDK's equivalent).
2021-02-25 16:01:36 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
If the strategy constraint uses a [**standard Unleash Context field** ](../reference/unleash-context#structure ), set the context field to the value you wish to give it.
2021-02-25 16:01:36 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
If the strategy constraint uses a [**custom context field** ](../reference/unleash-context#custom-context-fields ), use the Unleash Context's `properties` field. Use the name of the custom context field as a key and set the value to your desired string.
2021-12-14 11:19:16 +01:00
2022-03-08 13:44:02 +01:00
If you set a context field to a value that the SDKs cannot parse correctly for a chosen constraint operator, the strategy constraint will evaluate to false.
In other words: if you have a strategy constraint operator that expects a number, such as `NUM_GT` , but you set the corresponding context field to a string value, then the expression will be false: `"some string"` is **not** greater than `5` .
This value can still be negated as explained in [the section on negating values ](#constraint-negation ).
2023-02-17 12:06:25 +01:00
## Constraint limitations (or "how many user IDs can I add to a constraint") {#limitations}
2023-04-14 14:59:07 +02:00
:::tip
2023-11-17 14:01:48 +01:00
Explore the content in this subsection in more depth in [the topic guide on using Unleash with large constraints ](/understanding-unleash/managing-constraints.mdx ).
2023-04-14 14:59:07 +02:00
:::
2023-02-17 12:06:25 +01:00
When using a constraint operator that accepts a list of values, it might be tempting to add a large number of values to that list. However, we advise you **not** to do that: Unleash is not a database, and is not intended to store large amounts of data. Instead you should try and find a different way to achieve what you want.
For instance, instead of adding hundreds of user ids to the constraint value list, think about what properties those users share. Are they beta testers? Are they premium members? Are they employees?
Can you map their common feature into an [Unleash context ](../reference/unleash-context ) property instead and set the constraint on that? If they're beta testers, how about using a `betaTester` property? And likewise, for premium members, you could check to see if their `membership` is `premium` ? And if they're employees, maybe you're better off checking whether their user ID ends with `@yourcompany.tld` ?
The **reason** why you should try and keep value lists small has to do with Unleash's evaluation model: Because Unleash's server-side SDKs fetch the full feature toggle configuration from Unleash, every value that you add to that constraint value list will increase the payload size. For small numbers, this isn't an issue, but as the list grows, so will the payload, and so will the time and processing power used by the SDK to evaluate the feature.
2022-03-18 12:19:49 +01:00
## Incompatibilities and undefined behavior {#incompatibilities}
2022-03-08 13:44:02 +01:00
2022-03-18 12:19:49 +01:00
It's important that you use an up-to-date client SDK if you're using the advanced constraint operators introduced in Unleash 4.9. If your client SDK does not support the new operators, we cannot guarantee how it'll react. As a result, you may see different behavior across applications.
If you use the new constraints with old SDKs, here's how it'll affect _some_ of the SDKs (the list is not exhaustive):
- The Node.js and Go client SDKs will ignore the new constraints completely: the constraints will not affect the toggle's status.
- The Python client SDK will evaluate the toggle to false, as it cannot evaluate the constraint successfully.
2022-04-01 10:24:08 +02:00
- The .NET, Ruby, and PHP SDKs raise exceptions if the provided operator is not `IN` or `NOT_IN` .
2022-03-18 12:19:49 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Please inspect the [SDK compatibility table to see which version of your preferred SDK introduced support for this feature ](../reference/sdks/index.md#strategy-constraints ).
2022-03-18 12:19:49 +01:00
2022-03-18 12:21:29 +01:00
After Unleash 4.9, we updated the [Unleash client specification ](https://github.com/Unleash/client-specification ). Going forward, any constraint that a client does not recognize, **must be evaluated as `false`**
2022-03-08 13:44:02 +01:00
2021-12-20 14:28:00 +01:00
## [Deprecated]: Constrain on a specific environment {#constrain-on-a-specific-environment}
2021-12-13 12:44:11 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Before Unleash 4.3, using strategy constraints was the recommended way to have different toggle configurations per environment. Now that Unleash has environment support built in, we no longer recommend you use strategy constraints for this. Instead, see the [environments documentation ](../reference/environments.md ).
2022-03-07 17:21:25 +01:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
[^1]: `userScore` is not a default Unleash field, but can be added as a [custom context field ](../reference/unleash-context#custom-context-fields ).