diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-26 18:10:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-26 18:10:57 +0300 |
commit | ede9464fd957582e4e0232f70113942b08ddfe78 (patch) | |
tree | 186b5e12e612810dbf8d4209126737726dd23289 /app/experiments | |
parent | 04f9cef437b65b4a62624936a37a99cfbfb4d61c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/experiments')
-rw-r--r-- | app/experiments/application_experiment.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb index d7c4d2fcda3..a0e9ce07b92 100644 --- a/app/experiments/application_experiment.rb +++ b/app/experiments/application_experiment.rb @@ -12,6 +12,8 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp def publish(_result = nil) return unless should_track? # don't track events for excluded contexts + record_experiment if @record # record the subject in the database if the context contains a namespace, group, project, actor or user + track(:assignment) # track that we've assigned a variant for this context begin @@ -32,6 +34,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp )) end + def record! + @record = true + end + def exclude! @excluded = true end @@ -49,4 +55,13 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp def experiment_group? Feature.enabled?(feature_flag_name, self, type: :experiment, default_enabled: :yaml) end + + def record_experiment + subject = context.value[:namespace] || context.value[:group] || context.value[:project] || context.value[:user] || context.value[:actor] + return unless subject.is_a?(Group) || subject.is_a?(User) || subject.is_a?(Project) + + variant = :experimental if @variant_name != :control + + Experiment.add_subject(name, variant: variant || :control, subject: subject) + end end |