diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /lib/gitlab/experimentation.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'lib/gitlab/experimentation.rb')
-rw-r--r-- | lib/gitlab/experimentation.rb | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/lib/gitlab/experimentation.rb b/lib/gitlab/experimentation.rb index dca60c93fb2..1ce3ffe4c86 100644 --- a/lib/gitlab/experimentation.rb +++ b/lib/gitlab/experimentation.rb @@ -48,12 +48,12 @@ module Gitlab invite_members_version_a: { tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionA' }, + invite_members_version_b: { + tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionB' + }, new_create_project_ui: { tracking_category: 'Manage::Import::Experiment::NewCreateProjectUi' }, - terms_opt_in: { - tracking_category: 'Growth::Acquisition::Experiment::TermsOptIn' - }, contact_sales_btn_in_app: { tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp' }, @@ -62,6 +62,15 @@ module Gitlab }, invite_email: { tracking_category: 'Growth::Acquisition::Experiment::InviteEmail' + }, + invitation_reminders: { + tracking_category: 'Growth::Acquisition::Experiment::InvitationReminders' + }, + group_only_trials: { + tracking_category: 'Growth::Conversion::Experiment::GroupOnlyTrials' + }, + default_to_issues_board: { + tracking_category: 'Growth::Conversion::Experiment::DefaultToIssuesBoard' } }.freeze @@ -91,28 +100,40 @@ module Gitlab } end + def push_frontend_experiment(experiment_key) + var_name = experiment_key.to_s.camelize(:lower) + enabled = experiment_enabled?(experiment_key) + + gon.push({ experiments: { var_name => enabled } }, true) + end + def experiment_enabled?(experiment_key) return false if dnt_enabled? - return true if Experimentation.enabled_for_user?(experiment_key, experimentation_subject_index) + return true if Experimentation.enabled_for_value?(experiment_key, experimentation_subject_index) return true if forced_enabled?(experiment_key) false end def track_experiment_event(experiment_key, action, value = nil) + return if dnt_enabled? + track_experiment_event_for(experiment_key, action, value) do |tracking_data| - ::Gitlab::Tracking.event(tracking_data.delete(:category), tracking_data.delete(:action), tracking_data) + ::Gitlab::Tracking.event(tracking_data.delete(:category), tracking_data.delete(:action), **tracking_data) end end def frontend_experimentation_tracking_data(experiment_key, action, value = nil) + return if dnt_enabled? + track_experiment_event_for(experiment_key, action, value) do |tracking_data| gon.push(tracking_data: tracking_data) end end def record_experiment_user(experiment_key) + return if dnt_enabled? return unless Experimentation.enabled?(experiment_key) && current_user ::Experiment.add_user(experiment_key, tracking_group(experiment_key), current_user) @@ -183,9 +204,14 @@ module Gitlab experiment.enabled? && experiment.enabled_for_environment? end - def enabled_for_user?(experiment_key, experimentation_subject_index) + def enabled_for_attribute?(experiment_key, attribute) + index = Digest::SHA1.hexdigest(attribute).hex % 100 + enabled_for_value?(experiment_key, index) + end + + def enabled_for_value?(experiment_key, experimentation_subject_index) enabled?(experiment_key) && - experiment(experiment_key).enabled_for_experimentation_subject?(experimentation_subject_index) + experiment(experiment_key).enabled_for_index?(experimentation_subject_index) end end @@ -200,10 +226,10 @@ module Gitlab environment end - def enabled_for_experimentation_subject?(experimentation_subject_index) - return false if experimentation_subject_index.blank? + def enabled_for_index?(index) + return false if index.blank? - experimentation_subject_index <= experiment_percentage + index <= experiment_percentage end private |