summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-03 12:08:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-03 12:08:26 +0000
commit36b6f5bfe2e86059edfc88e344ff4865c3e50933 (patch)
tree79d438bfc9f89177fcedb52d56bbcb3c4eaa70bb /doc
parent32efe23e1831718f15a0c24a2eab5fcb7f073a6d (diff)
downloadgitlab-ce-36b6f5bfe2e86059edfc88e344ff4865c3e50933.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc')
-rw-r--r--doc/development/experiment_guide/index.md33
1 files changed, 26 insertions, 7 deletions
diff --git a/doc/development/experiment_guide/index.md b/doc/development/experiment_guide/index.md
index 8c696926dec..00a39ac0fc6 100644
--- a/doc/development/experiment_guide/index.md
+++ b/doc/development/experiment_guide/index.md
@@ -67,25 +67,44 @@ addressed.
```
- Make the experiment available to the frontend in a controller:
-
+
```ruby
before_action do
push_frontend_experiment(:signup_flow)
- end
+ end
```
-
+
The above will check whether the experiment is enabled and push the result to the frontend.
-
+
You can check the state of the feature flag in JavaScript:
-
+
```javascript
import { isExperimentEnabled } from '~/experimentation';
-
+
if ( isExperimentEnabled('signupFlow') ) {
// ...
}
```
-
+
+ - It is also possible to run an experiment outside of the controller scope, for example in a worker:
+
+ ```ruby
+ class SomeWorker
+ def perform
+ # Check if the experiment is enabled at all (the percentage_of_time_value > 0)
+ return unless Gitlab::Experimentation.enabled?(:experiment_key)
+
+ # Since we cannot access cookies in a worker, we need to bucket models based on a unique, unchanging attribute instead.
+ # Use the following method to check if the experiment is enabled for a certain attribute, for example a username or email address:
+ if Gitlab::Experimentation.enabled_for_attribute?(:experiment_key, some_attribute)
+ # execute experimental code
+ else
+ # execute control code
+ end
+ end
+ end
+ ```
+
1. Track necessary events. See the [telemetry guide](../telemetry/index.md) for details.
1. After the merge request is merged, use [`chatops`](../../ci/chatops/README.md) in the
[appropriate channel](../feature_flags/controls.md#communicate-the-change) to start the experiment for 10% of the users.