Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-15 00:13:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-15 00:13:08 +0300
commit30f908f6b9689ecda34474e68c55ce4dba1a9974 (patch)
tree980f904604222360eefcee2e01a7068539488713 /app/experiments
parent0c6a209989efe28789e8580aedbac25677af9ca2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/experiments')
-rw-r--r--app/experiments/application_experiment.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb
index bf8d43de6aa..859716b4739 100644
--- a/app/experiments/application_experiment.rb
+++ b/app/experiments/application_experiment.rb
@@ -41,6 +41,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
# define a default nil control behavior so we can omit it when not needed
end
+ def track(action, **event_args)
+ super(action, **tracking_context.merge(event_args))
+ end
+
# TODO: remove
# This is deprecated logic as of v0.6.0 and should eventually be removed, but
# needs to stay intact for actively running experiments. The new strategy
@@ -60,6 +64,19 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
private
+ def tracking_context
+ {
+ namespace: context.try(:namespace) || context.try(:group),
+ project: context.try(:project),
+ user: user_or_actor
+ }.compact || {}
+ end
+
+ def user_or_actor
+ actor = context.try(:actor)
+ actor.respond_to?(:id) ? actor : context.try(:user)
+ end
+
def feature_flag_name
name.tr('/', '_')
end