diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-01 15:09:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-01 15:09:03 +0300 |
commit | 9ecdb93f4e7e85ffc1e7a768780bb1279827a6aa (patch) | |
tree | 72d2a0acf03c3f1ef0459e4e31d81d2127b02b54 /app/experiments/application_experiment.rb | |
parent | 6e495b4e91a964aba7a159f95a1b1f48fcf9668c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/experiments/application_experiment.rb')
-rw-r--r-- | app/experiments/application_experiment.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb index 7a8851d11ce..9a1a37a6b19 100644 --- a/app/experiments/application_experiment.rb +++ b/app/experiments/application_experiment.rb @@ -1,13 +1,20 @@ # frozen_string_literal: true class ApplicationExperiment < Gitlab::Experiment + def enabled? + return false if Feature::Definition.get(name).nil? # there has to be a feature flag yaml file + return false unless Gitlab.dev_env_or_com? # we're in an environment that allows experiments + + Feature.get(name).state != :off # rubocop:disable Gitlab/AvoidFeatureGet + end + def publish(_result) track(:assignment) # track that we've assigned a variant for this context Gon.global.push({ experiment: { name => signature } }, true) # push to client end def track(action, **event_args) - return if excluded? # no events for opted out actors or excluded subjects + return unless should_track? # no events for opted out actors or excluded subjects Gitlab::Tracking.event(name, action.to_s, **event_args.merge( context: (event_args[:context] || []) << SnowplowTracker::SelfDescribingJson.new( |