1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/website/docs/reference/custom-activation-strategies.md

70 lines
5.4 KiB
Markdown
Raw Normal View History

---
title: Custom Activation Strategies
---
:::tip
docs: update images using latest UI screenshots (#1992) * Update api_access_history.png * updating images in - How to capture impression data * Update Quickstart image * Update images: How to add strategy constraints * Update images: How to create a feature toggle * Update images: How to define custom context fields * Update images: How to use custom activation strategies * Update images: How to schedule feature releases * Update images: How to add new users to your Unleash instance * Update images: How to create and assign custom project roles * Update images: How to add SSO with OpenId Connect * Update images: How to add SSO with SAML 2.0 Okta * Update images: Slack * Update images: Activation Strategies * Update images: Archived toggles * Update images: The audit log * Update images: Impression data * Update images: Custom Activation Strategies * Update images: Environments * Update images: Feature Toggle Types * Update images: Feature Toggle Variants * Update images: Projects * Update images: Segments * Update images: Stickiness * Update images: Strategy Constraints * Update images: Technical Debt * Update images: Unleash Context * Update images: Unleash introductory overview * Update images: Unleash introductory overview * docs: replace strategy constraints step 2 img * Update website/docs/how-to/how-to-add-strategy-constraints.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * change text request * Updating docs text to match the screenshots * Docs: change audit log to event log and add redirects * Docs: update "archive" page with deletion info * Docs: update constraints how to * Docs: minor tech debt doc fixes * docs-update-images-set1: update overview page * Apply suggestions from code review Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/quickstart.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Activation strategy update * Apply suggestions from code review * Update delete-archive img * Fix prettier formatting for admonitions * Update website/docs/user_guide/environments.md * Update website/docs/user_guide/projects.md Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai> Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-14 09:59:18 +02:00
This document is a reference for custom activation strategies. If you're looking for a guide on how to use them, see the [_how to use custom strategies_ guide](../how-to/how-to-use-custom-strategies.md).
docs: update images using latest UI screenshots (#1992) * Update api_access_history.png * updating images in - How to capture impression data * Update Quickstart image * Update images: How to add strategy constraints * Update images: How to create a feature toggle * Update images: How to define custom context fields * Update images: How to use custom activation strategies * Update images: How to schedule feature releases * Update images: How to add new users to your Unleash instance * Update images: How to create and assign custom project roles * Update images: How to add SSO with OpenId Connect * Update images: How to add SSO with SAML 2.0 Okta * Update images: Slack * Update images: Activation Strategies * Update images: Archived toggles * Update images: The audit log * Update images: Impression data * Update images: Custom Activation Strategies * Update images: Environments * Update images: Feature Toggle Types * Update images: Feature Toggle Variants * Update images: Projects * Update images: Segments * Update images: Stickiness * Update images: Strategy Constraints * Update images: Technical Debt * Update images: Unleash Context * Update images: Unleash introductory overview * Update images: Unleash introductory overview * docs: replace strategy constraints step 2 img * Update website/docs/how-to/how-to-add-strategy-constraints.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * change text request * Updating docs text to match the screenshots * Docs: change audit log to event log and add redirects * Docs: update "archive" page with deletion info * Docs: update constraints how to * Docs: minor tech debt doc fixes * docs-update-images-set1: update overview page * Apply suggestions from code review Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/quickstart.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Activation strategy update * Apply suggestions from code review * Update delete-archive img * Fix prettier formatting for admonitions * Update website/docs/user_guide/environments.md * Update website/docs/user_guide/projects.md Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai> Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-14 09:59:18 +02:00
Custom activation strategies should be considered an advanced feature. In most cases [strategy constraints](https://docs.getunleash.io/reference/strategy-constraints) provides enough control without the additional complexity.
:::
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
**Custom activation strategies** let you define your own activation strategies to use with Unleash. When the [built-in activation strategies](../reference/activation-strategies.md) aren't enough, custom activation strategies are there to provide you with the flexibility you need.
Custom activation strategies work exactly like the built-in activation strategies when working in the admin UI.
## Definition
![A strategy creation form. It has fields labeled "strategy name" — "TimeStamp" — and "description" — "activate toggle after a given timestamp". It also has fields for a parameter named "enableAfter". The parameter is of type "string" and the parameter description is "Expected format: YYYY-MM-DD HH:MM". The parameter is required.](/img/timestamp_create_strategy.png)
You define custom activation strategies on your Unleash instance, either via the admin UI or via the API. A strategy contains:
- A strategy **name**: You'll use this to refer to the strategy in the UI and in code. The strategy name should make it easy to understand what the strategy does. For instance, if a strategy uses contact numbers to determine whether a feature should be enabled, then _ContactNumbers_ would be a good name.
- An optional **description**: Use this to describe what the strategy should do.
- An optional list of **parameters**: The parameter list lets you pass arguments to your custom activation strategy. These will be made available to your custom strategy implementation. How you interact with them differs between SDKs, but refer to the [Node.js example in the how-to guide](../how-to/how-to-use-custom-strategies.md) for a rough idea.
The strategy **name** is the only required parameter, but adding a good **description** will make it easier to remember what a strategy should do. The list of **parameters** lets you pass data from the Unleash instance to the strategy implementation.
### Parameters
docs: update images using latest UI screenshots (#1992) * Update api_access_history.png * updating images in - How to capture impression data * Update Quickstart image * Update images: How to add strategy constraints * Update images: How to create a feature toggle * Update images: How to define custom context fields * Update images: How to use custom activation strategies * Update images: How to schedule feature releases * Update images: How to add new users to your Unleash instance * Update images: How to create and assign custom project roles * Update images: How to add SSO with OpenId Connect * Update images: How to add SSO with SAML 2.0 Okta * Update images: Slack * Update images: Activation Strategies * Update images: Archived toggles * Update images: The audit log * Update images: Impression data * Update images: Custom Activation Strategies * Update images: Environments * Update images: Feature Toggle Types * Update images: Feature Toggle Variants * Update images: Projects * Update images: Segments * Update images: Stickiness * Update images: Strategy Constraints * Update images: Technical Debt * Update images: Unleash Context * Update images: Unleash introductory overview * Update images: Unleash introductory overview * docs: replace strategy constraints step 2 img * Update website/docs/how-to/how-to-add-strategy-constraints.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * change text request * Updating docs text to match the screenshots * Docs: change audit log to event log and add redirects * Docs: update "archive" page with deletion info * Docs: update constraints how to * Docs: minor tech debt doc fixes * docs-update-images-set1: update overview page * Apply suggestions from code review Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/quickstart.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Activation strategy update * Apply suggestions from code review * Update delete-archive img * Fix prettier formatting for admonitions * Update website/docs/user_guide/environments.md * Update website/docs/user_guide/projects.md Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai> Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-14 09:59:18 +02:00
![A strategy with five parameters, one of each type.](/img/strategy-parameters-ui-controls.png)
2021-12-23 11:26:18 +01:00
Parameters let you provide arguments to your strategy that it can access for evaluation. When creating a strategy, each parameter can be either required or optional. This marking is to help the user understand what they need to fill out; they can still save the strategy without filling out a required field.
Each parameter consists of three parts:
- a **name**: must be unique among the strategy's parameters.
- an optional **description**: describe the purpose or format of the parameter.
- a parameter **type**: dictates the kind of input field the user will see in the admin UI and the type of the value in the implementation code.
#### Parameter types
Each parameter has one of five different parameter types. A parameter's type impacts the kind of controls shown in the admin UI and how it's represented in code.
The below table lists the types and how they're represented in the JSON payload returned from the Unleash server. When parsed, the exact types will vary based on your programming language's type system.
All values have an **empty string (`""`) as the default value**. As such, if you don't interact with a control or otherwise set a value, the value will be an empty string.
docs: update images using latest UI screenshots (#1992) * Update api_access_history.png * updating images in - How to capture impression data * Update Quickstart image * Update images: How to add strategy constraints * Update images: How to create a feature toggle * Update images: How to define custom context fields * Update images: How to use custom activation strategies * Update images: How to schedule feature releases * Update images: How to add new users to your Unleash instance * Update images: How to create and assign custom project roles * Update images: How to add SSO with OpenId Connect * Update images: How to add SSO with SAML 2.0 Okta * Update images: Slack * Update images: Activation Strategies * Update images: Archived toggles * Update images: The audit log * Update images: Impression data * Update images: Custom Activation Strategies * Update images: Environments * Update images: Feature Toggle Types * Update images: Feature Toggle Variants * Update images: Projects * Update images: Segments * Update images: Stickiness * Update images: Strategy Constraints * Update images: Technical Debt * Update images: Unleash Context * Update images: Unleash introductory overview * Update images: Unleash introductory overview * docs: replace strategy constraints step 2 img * Update website/docs/how-to/how-to-add-strategy-constraints.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * change text request * Updating docs text to match the screenshots * Docs: change audit log to event log and add redirects * Docs: update "archive" page with deletion info * Docs: update constraints how to * Docs: minor tech debt doc fixes * docs-update-images-set1: update overview page * Apply suggestions from code review Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/quickstart.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Activation strategy update * Apply suggestions from code review * Update delete-archive img * Fix prettier formatting for admonitions * Update website/docs/user_guide/environments.md * Update website/docs/user_guide/projects.md Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai> Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-14 09:59:18 +02:00
| type name | code representation | example value | UI control |
| --- | --- | --- | --- |
| string | `string` | `"a string"` | A standard input field |
| percentage | a `string` representing a number between 0 and 100 (inclusive) | `"99"` | A value slider |
| list | `string` (values are comma-separated) | `"one,two"` | A multi-input text field |
| number | `string` | `"123"` | A numeric text field |
| boolean | a `string`: one of `"true"` or `"false"` | `"true"` | An on/off toggle |
## Implementation
:::note
docs: update images using latest UI screenshots (#1992) * Update api_access_history.png * updating images in - How to capture impression data * Update Quickstart image * Update images: How to add strategy constraints * Update images: How to create a feature toggle * Update images: How to define custom context fields * Update images: How to use custom activation strategies * Update images: How to schedule feature releases * Update images: How to add new users to your Unleash instance * Update images: How to create and assign custom project roles * Update images: How to add SSO with OpenId Connect * Update images: How to add SSO with SAML 2.0 Okta * Update images: Slack * Update images: Activation Strategies * Update images: Archived toggles * Update images: The audit log * Update images: Impression data * Update images: Custom Activation Strategies * Update images: Environments * Update images: Feature Toggle Types * Update images: Feature Toggle Variants * Update images: Projects * Update images: Segments * Update images: Stickiness * Update images: Strategy Constraints * Update images: Technical Debt * Update images: Unleash Context * Update images: Unleash introductory overview * Update images: Unleash introductory overview * docs: replace strategy constraints step 2 img * Update website/docs/how-to/how-to-add-strategy-constraints.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * change text request * Updating docs text to match the screenshots * Docs: change audit log to event log and add redirects * Docs: update "archive" page with deletion info * Docs: update constraints how to * Docs: minor tech debt doc fixes * docs-update-images-set1: update overview page * Apply suggestions from code review Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/quickstart.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Activation strategy update * Apply suggestions from code review * Update delete-archive img * Fix prettier formatting for admonitions * Update website/docs/user_guide/environments.md * Update website/docs/user_guide/projects.md Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai> Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-14 09:59:18 +02:00
If you have not implemented the strategy in your client SDK, the check will always return `false` because the client doesn't recognize the strategy.
docs: update images using latest UI screenshots (#1992) * Update api_access_history.png * updating images in - How to capture impression data * Update Quickstart image * Update images: How to add strategy constraints * Update images: How to create a feature toggle * Update images: How to define custom context fields * Update images: How to use custom activation strategies * Update images: How to schedule feature releases * Update images: How to add new users to your Unleash instance * Update images: How to create and assign custom project roles * Update images: How to add SSO with OpenId Connect * Update images: How to add SSO with SAML 2.0 Okta * Update images: Slack * Update images: Activation Strategies * Update images: Archived toggles * Update images: The audit log * Update images: Impression data * Update images: Custom Activation Strategies * Update images: Environments * Update images: Feature Toggle Types * Update images: Feature Toggle Variants * Update images: Projects * Update images: Segments * Update images: Stickiness * Update images: Strategy Constraints * Update images: Technical Debt * Update images: Unleash Context * Update images: Unleash introductory overview * Update images: Unleash introductory overview * docs: replace strategy constraints step 2 img * Update website/docs/how-to/how-to-add-strategy-constraints.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * change text request * Updating docs text to match the screenshots * Docs: change audit log to event log and add redirects * Docs: update "archive" page with deletion info * Docs: update constraints how to * Docs: minor tech debt doc fixes * docs-update-images-set1: update overview page * Apply suggestions from code review Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/quickstart.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Update website/docs/user_guide/user-management.md Co-authored-by: Thomas Heartman <thomas@getunleash.ai> * Activation strategy update * Apply suggestions from code review * Update delete-archive img * Fix prettier formatting for admonitions * Update website/docs/user_guide/environments.md * Update website/docs/user_guide/projects.md Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai> Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
2022-09-14 09:59:18 +02:00
:::
2021-12-22 13:24:01 +01:00
While custom strategies are _defined_ on the Unleash server, they must be _implemented_ on the client. All official Unleash client SDKs provide a way for you to implement custom strategies. You should refer to the individual SDK's documentation for specifics, but for an example, you can have a look at the [_Node.js client implementation_ section in the _how to use custom strategies_ guide](../how-to/how-to-use-custom-strategies.md#step-3-a).
Source proxy and Edge docs from GitHub (#3122) ## What The main purpose of this PR is to 1. Delete the proxy docs in this repo and replace them with the proxy's GitHub readme. 2. Add the docs for Unleash Edge. ### Detailed change description This PR contains a lot of small changes in a large number of files. To make it easier to get an overview, here's a detailed description of what happens where: #### In the `website/docs`directory Except for the deletion of the proxy doc, all changes in this directory are rewriting internal links, so that they point to the newly generated document instead. #### `package.json` and `yarn.lock` When including the documentation for Edge, we also want to render the mermaid diagrams it uses. Docusaurus supports this via a plugin. All changes in these files are related to installing that plugin. #### `docusaurus.config.js` There's two types of changes in this file: 1. Mermaid-related changes: we ask docusaurus to render mermaid in markdown files and add the plugin 2. Document generation. There's some rewrites to the sdk doc generation plus an entirely new section that generates docs for Edge and the proxy #### `sidebars.js` Two things: 1. Add the edge docs 2. Move both the Edge and the proxy docs up a level, so that they're directly under "reference docs" instead of nested inside "unleash concepts". #### In the `website/remote-content` directory These are the remote content files. Previously, all of this lived only in a `readme-fns.js` file, but with the introduction of Edge and proxy docs, this has been moved into its own directory and refactored into three files (`shared`, `sdks`, `edge-proxy`). #### `custom.css` Style updates to center mermaid diagrams and provide more space around them. #### In `static/img` The image files that were included in the proxy doc and that have been deleted. ## Why For two reasons: 1. Reduce duplication for the proxy. Have one source of truth. 2. Add docs for edge. ## Discussion points and review wishes This is a big PR, and I don't expect anyone to do a line-by-line review of it, nor do I think that is particularly useful. Instead, I'd like to ask reviewers to: 1. Visit the [documentation preview](https://unleash-docs-git-docs-source-proxy-gh-unleash-team.vercel.app/reference/unleash-proxy) and have a look at both the proxy docs and the Edge docs. Potentially have a look at the SDK docs too to verify that everything still works. 2. Consider whether they think moving the proxy and edge docs up a level (in the sidebar) makes sense. 3. Let me know what slug they'd prefer for the Edge docs. I've gone with `unleash-edge` for now (so that it's `docs.getunleash.io/reference/unleash-edge`), but we could potentially also just use `edge`. WDYT? 4. Read through the detailed changes section. 5. Let me know if they have any other concerns or questions. ## Screenies The new proxy doc: ![image](https://user-images.githubusercontent.com/17786332/219043145-1c75c83e-4191-45a3-acb5-775d05d13862.png) The new edge doc: ![image](https://user-images.githubusercontent.com/17786332/219043220-1f5daf13-972e-4d56-8aaf-70ff1812863e.png)
2023-02-16 13:36:28 +01:00
The exact method for implementing custom strategies will vary between SDKs, but the server SDKs follow the same patterns. For front-end client SDKs ([Android](/docs/generated/sdks/client-side/android-proxy.md), [JavaScript](/docs/generated/sdks/client-side/javascript-browser.md), [React](/docs/generated/sdks/client-side/react.md), [iOS](/docs/generated/sdks/client-side/ios-proxy.md), [Flutter](/docs/generated/sdks/client-side/flutter.md)), the custom activation strategy must be implemented in the [Unleash Proxy](../generated/unleash-proxy.md).
When implementing a strategy in your client, you will get access to the strategy's parameters and the Unleash Context. Again, refer to your specific SDK's documentation for more details.