diff options
Diffstat (limited to 'app/experiments')
10 files changed, 20 insertions, 63 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb index 859716b4739..f6af7ca15bb 100644 --- a/app/experiments/application_experiment.rb +++ b/app/experiments/application_experiment.rb @@ -1,14 +1,6 @@ # frozen_string_literal: true -class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/NamespacedClass - def enabled? - return false if Feature::Definition.get(feature_flag_name).nil? # there has to be a feature flag yaml file - return false unless Gitlab.dev_env_or_com? # we have to be in an environment that allows experiments - - # the feature flag has to be rolled out - Feature.get(feature_flag_name).state != :off # rubocop:disable Gitlab/AvoidFeatureGet - end - +class ApplicationExperiment < Gitlab::Experiment def publish(_result = nil) super @@ -41,10 +33,6 @@ 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 @@ -64,24 +52,16 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp private - def tracking_context + def tracking_context(event_args) { namespace: context.try(:namespace) || context.try(:group), project: context.try(:project), user: user_or_actor - }.compact || {} + }.merge(event_args) 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 - - def experiment_group? - Feature.enabled?(feature_flag_name, self, type: :experiment, default_enabled: :yaml) - end end diff --git a/app/experiments/combined_registration_experiment.rb b/app/experiments/combined_registration_experiment.rb index 08c015838db..576e10815aa 100644 --- a/app/experiments/combined_registration_experiment.rb +++ b/app/experiments/combined_registration_experiment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CombinedRegistrationExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class CombinedRegistrationExperiment < ApplicationExperiment include Rails.application.routes.url_helpers def key_for(source, _ = nil) diff --git a/app/experiments/empty_repo_upload_experiment.rb b/app/experiments/empty_repo_upload_experiment.rb index d0d79a5fb45..c8c75f32d69 100644 --- a/app/experiments/empty_repo_upload_experiment.rb +++ b/app/experiments/empty_repo_upload_experiment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class EmptyRepoUploadExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class EmptyRepoUploadExperiment < ApplicationExperiment include ProjectCommitCount TRACKING_START_DATE = DateTime.parse('2021/4/20') diff --git a/app/experiments/force_company_trial_experiment.rb b/app/experiments/force_company_trial_experiment.rb index 00bdd5d693d..e7b98bb18ad 100644 --- a/app/experiments/force_company_trial_experiment.rb +++ b/app/experiments/force_company_trial_experiment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ForceCompanyTrialExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class ForceCompanyTrialExperiment < ApplicationExperiment exclude :setup_for_personal private diff --git a/app/experiments/in_product_guidance_environments_webide_experiment.rb b/app/experiments/in_product_guidance_environments_webide_experiment.rb index d77063a9834..6567ec0b3f1 100644 --- a/app/experiments/in_product_guidance_environments_webide_experiment.rb +++ b/app/experiments/in_product_guidance_environments_webide_experiment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class InProductGuidanceEnvironmentsWebideExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class InProductGuidanceEnvironmentsWebideExperiment < ApplicationExperiment exclude :has_environments? def control_behavior diff --git a/app/experiments/new_project_readme_content_experiment.rb b/app/experiments/new_project_readme_content_experiment.rb deleted file mode 100644 index 1de7632268d..00000000000 --- a/app/experiments/new_project_readme_content_experiment.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class NewProjectReadmeContentExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass - TEMPLATE_PATH = Rails.root.join('app', 'experiments', 'templates', 'new_project_readme_content') - include Rails.application.routes.url_helpers - - def run_with(project, variant: nil) - @project = project - publish_to_database - run(variant) - end - - def control_behavior - template('readme_basic.md') - end - - def advanced_behavior - template('readme_advanced.md') - end - - def redirect(to_url) - experiment_redirect_url(self, url: to_url) - end - - private - - def template(name) - ERB.new(File.read(TEMPLATE_PATH.join("#{name}.tt")), trim_mode: '<>').result(binding) - end -end diff --git a/app/experiments/new_project_sast_enabled_experiment.rb b/app/experiments/new_project_sast_enabled_experiment.rb index a779b8ec633..ee9d0dc1700 100644 --- a/app/experiments/new_project_sast_enabled_experiment.rb +++ b/app/experiments/new_project_sast_enabled_experiment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class NewProjectSastEnabledExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class NewProjectSastEnabledExperiment < ApplicationExperiment def publish(_result = nil) super diff --git a/app/experiments/require_verification_for_namespace_creation_experiment.rb b/app/experiments/require_verification_for_namespace_creation_experiment.rb index 1cadac7e7d4..0c47f5d183c 100644 --- a/app/experiments/require_verification_for_namespace_creation_experiment.rb +++ b/app/experiments/require_verification_for_namespace_creation_experiment.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true -class RequireVerificationForNamespaceCreationExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class RequireVerificationForNamespaceCreationExperiment < ApplicationExperiment + exclude :existing_user + + EXPERIMENT_START_DATE = Date.new(2022, 1, 31) + def control_behavior false end @@ -24,4 +28,10 @@ class RequireVerificationForNamespaceCreationExperiment < ApplicationExperiment def subject context.value[:user] end + + def existing_user + return false unless user_or_actor + + user_or_actor.created_at < EXPERIMENT_START_DATE + end end diff --git a/app/experiments/security_reports_mr_widget_prompt_experiment.rb b/app/experiments/security_reports_mr_widget_prompt_experiment.rb index fa0ba8e24d4..bcb9d64fcb7 100644 --- a/app/experiments/security_reports_mr_widget_prompt_experiment.rb +++ b/app/experiments/security_reports_mr_widget_prompt_experiment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SecurityReportsMrWidgetPromptExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass +class SecurityReportsMrWidgetPromptExperiment < ApplicationExperiment def publish(_result = nil) super diff --git a/app/experiments/templates/new_project_readme_content/readme_basic.md.tt b/app/experiments/templates/new_project_readme_content/readme_basic.md.tt deleted file mode 100644 index 1e68eaf2f05..00000000000 --- a/app/experiments/templates/new_project_readme_content/readme_basic.md.tt +++ /dev/null @@ -1,3 +0,0 @@ -# <%= @project.name %> - -<%= @project.description %> |