Commit 784e8e0d authored by Dallas Reedy's avatar Dallas Reedy

Make changes suggested by initial code review

parent 36e41dc4
...@@ -8,7 +8,7 @@ require 'zlib' ...@@ -8,7 +8,7 @@ require 'zlib'
# Experiment options: # Experiment options:
# - environment (optional, defaults to enabled for development and GitLab.com) # - environment (optional, defaults to enabled for development and GitLab.com)
# - tracking_category (optional, used to set the category when tracking an experiment event) # - tracking_category (optional, used to set the category when tracking an experiment event)
# - calculate_subject_index_from_uuid_only (optional, set this to true if you need backwards compatibility) # - use_backwards_compatible_subject_index (optional, set this to true if you need backwards compatibility)
# #
# The experiment is controlled by a Feature Flag (https://docs.gitlab.com/ee/development/feature_flags/controls.html), # The experiment is controlled by a Feature Flag (https://docs.gitlab.com/ee/development/feature_flags/controls.html),
# which is named "#{experiment_key}_experiment_percentage" and *must* be set with a percentage and not be used for other purposes. # which is named "#{experiment_key}_experiment_percentage" and *must* be set with a percentage and not be used for other purposes.
...@@ -35,58 +35,58 @@ module Gitlab ...@@ -35,58 +35,58 @@ module Gitlab
EXPERIMENTS = { EXPERIMENTS = {
signup_flow: { signup_flow: {
tracking_category: 'Growth::Acquisition::Experiment::SignUpFlow', tracking_category: 'Growth::Acquisition::Experiment::SignUpFlow',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
onboarding_issues: { onboarding_issues: {
tracking_category: 'Growth::Conversion::Experiment::OnboardingIssues', tracking_category: 'Growth::Conversion::Experiment::OnboardingIssues',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
ci_notification_dot: { ci_notification_dot: {
tracking_category: 'Growth::Expansion::Experiment::CiNotificationDot', tracking_category: 'Growth::Expansion::Experiment::CiNotificationDot',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
upgrade_link_in_user_menu_a: { upgrade_link_in_user_menu_a: {
tracking_category: 'Growth::Expansion::Experiment::UpgradeLinkInUserMenuA', tracking_category: 'Growth::Expansion::Experiment::UpgradeLinkInUserMenuA',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
invite_members_version_a: { invite_members_version_a: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionA', tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionA',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
invite_members_version_b: { invite_members_version_b: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionB', tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionB',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
invite_members_empty_group_version_a: { invite_members_empty_group_version_a: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersEmptyGroupVersionA' tracking_category: 'Growth::Expansion::Experiment::InviteMembersEmptyGroupVersionA'
}, },
new_create_project_ui: { new_create_project_ui: {
tracking_category: 'Manage::Import::Experiment::NewCreateProjectUi', tracking_category: 'Manage::Import::Experiment::NewCreateProjectUi',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
contact_sales_btn_in_app: { contact_sales_btn_in_app: {
tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp', tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
customize_homepage: { customize_homepage: {
tracking_category: 'Growth::Expansion::Experiment::CustomizeHomepage', tracking_category: 'Growth::Expansion::Experiment::CustomizeHomepage',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
invite_email: { invite_email: {
tracking_category: 'Growth::Acquisition::Experiment::InviteEmail', tracking_category: 'Growth::Acquisition::Experiment::InviteEmail',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
invitation_reminders: { invitation_reminders: {
tracking_category: 'Growth::Acquisition::Experiment::InvitationReminders', tracking_category: 'Growth::Acquisition::Experiment::InvitationReminders',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
group_only_trials: { group_only_trials: {
tracking_category: 'Growth::Conversion::Experiment::GroupOnlyTrials', tracking_category: 'Growth::Conversion::Experiment::GroupOnlyTrials',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
default_to_issues_board: { default_to_issues_board: {
tracking_category: 'Growth::Conversion::Experiment::DefaultToIssuesBoard', tracking_category: 'Growth::Conversion::Experiment::DefaultToIssuesBoard',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
} }
}.freeze }.freeze
...@@ -126,8 +126,7 @@ module Gitlab ...@@ -126,8 +126,7 @@ module Gitlab
def experiment_enabled?(experiment_key) def experiment_enabled?(experiment_key)
return false if dnt_enabled? return false if dnt_enabled?
return true if Experimentation.enabled_for_value?(experiment_key, return true if Experimentation.enabled_for_value?(experiment_key, experimentation_subject_index(experiment_key))
experimentation_subject_index(experiment_key))
return true if forced_enabled?(experiment_key) return true if forced_enabled?(experiment_key)
false false
...@@ -173,7 +172,7 @@ module Gitlab ...@@ -173,7 +172,7 @@ module Gitlab
def experimentation_subject_index(experiment_key) def experimentation_subject_index(experiment_key)
return if experimentation_subject_id.blank? return if experimentation_subject_id.blank?
if Experimentation.experiment(experiment_key).calculate_subject_index_from_uuid_only if Experimentation.experiment(experiment_key).use_backwards_compatible_subject_index
experimentation_subject_id.delete('-').hex % 100 experimentation_subject_id.delete('-').hex % 100
else else
Zlib.crc32("#{experiment_key}#{experimentation_subject_id}") % 100 Zlib.crc32("#{experiment_key}#{experimentation_subject_id}") % 100
...@@ -239,7 +238,7 @@ module Gitlab ...@@ -239,7 +238,7 @@ module Gitlab
:key, :key,
:environment, :environment,
:tracking_category, :tracking_category,
:calculate_subject_index_from_uuid_only, :use_backwards_compatible_subject_index,
keyword_init: true keyword_init: true
) do ) do
def enabled? def enabled?
......
...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Experimentation, :snowplow do ...@@ -8,7 +8,7 @@ RSpec.describe Gitlab::Experimentation, :snowplow do
backwards_compatible_test_experiment: { backwards_compatible_test_experiment: {
environment: environment, environment: environment,
tracking_category: 'Team', tracking_category: 'Team',
calculate_subject_index_from_uuid_only: true use_backwards_compatible_subject_index: true
}, },
test_experiment: { test_experiment: {
environment: environment, environment: environment,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment