Commit 8e60a8ae authored by 🤖 GitLab Bot 🤖's avatar 🤖 GitLab Bot 🤖 Committed by jejacks0n

Update gitlab-experiment to version 0.7.0

parent a065a997
......@@ -489,7 +489,7 @@ gem 'flipper', '~> 0.21.0'
gem 'flipper-active_record', '~> 0.21.0'
gem 'flipper-active_support_cache_store', '~> 0.21.0'
gem 'unleash', '~> 3.2.2'
gem 'gitlab-experiment', git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-experiment', branch: 'release-0.7.0'
gem 'gitlab-experiment', '~> 0.7.0'
# Structured logging
gem 'lograge', '~> 0.5'
......
GIT
remote: https://gitlab.com/gitlab-org/ruby/gems/gitlab-experiment.git
revision: 176d767486217ae5080785247f29dc4549d85a4a
branch: release-0.7.0
specs:
gitlab-experiment (0.7.0)
activesupport (>= 3.0)
request_store (>= 1.0)
PATH
remote: vendor/gems/mail-smtp_pool
specs:
......@@ -469,6 +460,9 @@ GEM
gitlab-dangerfiles (2.8.0)
danger (>= 8.3.1)
danger-gitlab (>= 8.0.0)
gitlab-experiment (0.7.0)
activesupport (>= 3.0)
request_store (>= 1.0)
gitlab-fog-azure-rm (1.2.0)
azure-storage-blob (~> 2.0)
azure-storage-common (~> 2.0)
......@@ -645,7 +639,7 @@ GEM
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.8.11)
i18n (1.9.1)
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
icalendar (2.4.1)
......@@ -1040,7 +1034,7 @@ GEM
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
request_store (1.5.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.0.0)
actionpack (>= 5.0)
......@@ -1381,7 +1375,7 @@ GEM
nokogiri (~> 1.8)
yajl-ruby (1.4.1)
yard (0.9.26)
zeitwerk (2.5.3)
zeitwerk (2.5.4)
PLATFORMS
ruby
......@@ -1474,7 +1468,7 @@ DEPENDENCIES
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 2.8.0)
gitlab-experiment!
gitlab-experiment (~> 0.7.0)
gitlab-fog-azure-rm (~> 1.2.0)
gitlab-labkit (~> 0.21.3)
gitlab-license (~> 2.1.0)
......
......@@ -320,7 +320,7 @@ experiment(:pill_color, actor: current_user).track(:clicked)
When you run an experiment with any of the examples so far, an `:assigned` event
is tracked automatically by default. All events that are tracked from an
experiment have a special
[experiment context](https://gitlab.com/gitlab-org/iglu/-/blob/master/public/schemas/com.gitlab/gitlab_experiment/jsonschema/1-0-0)
[experiment context](https://gitlab.com/gitlab-org/iglu/-/blob/master/public/schemas/com.gitlab/gitlab_experiment/jsonschema/1-0-3)
added to the event. This can be used - typically by the data team - to create a connection
between the events on a given experiment.
......@@ -438,26 +438,34 @@ experiment(:example, :variant_name, foo: :bar).track(:my_event, value: 1, proper
## Experiments in the client layer
Any experiment that's been run in the request lifecycle surfaces in and `window.gl.experiments`,
Any experiment that's been run in the request lifecycle surfaces in `window.gl.experiments`,
and matches [this schema](https://gitlab.com/gitlab-org/iglu/-/blob/master/public/schemas/com.gitlab/gitlab_experiment/jsonschema/1-0-3)
so it can be used when resolving experimentation in the client layer.
### Use experiments in Vue
Given that we've defined a class for our experiment, and have defined the variants for it, we can publish that experiment in a couple ways.
With the `gitlab-experiment` component, you can define slots that match the name of the
variants pushed to `window.gl.experiments`. For example, if we alter the `pill_color`
experiment to just use the default variants of `control` and `candidate` like so:
The first way is simply by running the experiment. Assuming the experiment has been run, it will surface in the client layer without having to do anything special.
The second way doesn't run the experiment and is intended to be used if the experiment only needs to surface in the client layer. To accomplish this we can simply `.publish` the experiment. This won't run any logic, but does surface the experiment details in the client layer so they can be utilized there.
An example might be to publish an experiment in a `before_action` in a controller. Assuming we've defined the `PillColorExperiment` class, like we have above, we can surface it to the client by publishing it instead of running it:
```ruby
def show
experiment(:pill_color) do |e|
e.use { } # control
e.try { } # candidate
end.run
end
before_action -> { experiment(:pill_color).publish }, only: [:show]
```
We can make use of the named slots `control` and `candidate` in the Vue component:
You can then see this surface in the JavaScript console:
```javascript
window.gl.experiments // => { pill_color: { excluded: false, experiment: "pill_color", key: "ca63ac02", variant: "candidate" } }
```
### Using experiments in Vue
With the `gitlab-experiment` component, you can define slots that match the name of the
variants pushed to `window.gl.experiments`.
We can make use of the named slots in the Vue component, that match the behaviors defined in :
```vue
<script>
......@@ -468,23 +476,6 @@ export default {
}
</script>
<template>
<gitlab-experiment name="pill_color">
<template #control>
<button class="bg-default">Click default button</button>
</template>
<template #candidate>
<button class="bg-red">Click red button</button>
</template>
</gitlab-experiment>
</template>
```
When you're coding for an experiment with multiple variants, you can use the variant names.
For example, the Vue component for the previously-defined `pill_color` experiment with `red` and `blue` variants would look like this:
```vue
<template>
<gitlab-experiment name="pill_color">
<template #control>
......
......@@ -20,7 +20,6 @@ RSpec.configure do |config|
deprecator.silenced = true
end
end
end
config.before(:each, :experiment) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment