diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /app/experiments | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/experiments')
-rw-r--r-- | app/experiments/application_experiment.rb | 28 | ||||
-rw-r--r-- | app/experiments/members/invite_email_experiment.rb | 2 |
2 files changed, 24 insertions, 6 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb index d7c4d2fcda3..53ea8ea2d3a 100644 --- a/app/experiments/application_experiment.rb +++ b/app/experiments/application_experiment.rb @@ -12,13 +12,18 @@ 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 - Gon.push({ experiment: { name => signature } }, true) # push the experiment data to the client - rescue NoMethodError - # means we're not in the request cycle, and can't add to Gon. Log a warning maybe? - end + push_to_client + end + + # push the experiment data to the client + def push_to_client + Gon.push({ experiment: { name => signature } }, true) + rescue NoMethodError + # means we're not in the request cycle, and can't add to Gon. Log a warning maybe? end def track(action, **event_args) @@ -32,6 +37,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp )) end + def record! + @record = true + end + def exclude! @excluded = true end @@ -49,4 +58,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 ExperimentSubject.valid_subject?(subject) + + variant = :experimental if @variant_name != :control + + Experiment.add_subject(name, variant: variant || :control, subject: subject) + end end diff --git a/app/experiments/members/invite_email_experiment.rb b/app/experiments/members/invite_email_experiment.rb index f780c6962df..893061e34f3 100644 --- a/app/experiments/members/invite_email_experiment.rb +++ b/app/experiments/members/invite_email_experiment.rb @@ -12,7 +12,7 @@ module Members end def resolve_variant_name - RoundRobin.new(feature_flag_name, %i[avatar permission_info control]).execute + RoundRobin.new(feature_flag_name, %i[activity control]).execute end end |