summaryrefslogtreecommitdiff
path: root/app/experiments
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /app/experiments
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/experiments')
-rw-r--r--app/experiments/application_experiment.rb4
-rw-r--r--app/experiments/concerns/project_commit_count.rb21
-rw-r--r--app/experiments/empty_repo_upload_experiment.rb22
-rw-r--r--app/experiments/in_product_guidance_environments_webide_experiment.rb15
-rw-r--r--app/experiments/members/invite_email_experiment.rb4
-rw-r--r--app/experiments/new_project_readme_experiment.rb25
6 files changed, 75 insertions, 16 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb
index 01105f6cec4..d7c4d2fcda3 100644
--- a/app/experiments/application_experiment.rb
+++ b/app/experiments/application_experiment.rb
@@ -36,6 +36,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
@excluded = true
end
+ def control_behavior
+ # define a default nil control behavior so we can omit it when not needed
+ end
+
private
def feature_flag_name
diff --git a/app/experiments/concerns/project_commit_count.rb b/app/experiments/concerns/project_commit_count.rb
new file mode 100644
index 00000000000..706a1a24640
--- /dev/null
+++ b/app/experiments/concerns/project_commit_count.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+module ProjectCommitCount
+ include Gitlab::Git::WrapsGitalyErrors
+
+ def commit_count_for(project, default_count: 0, max_count: nil, **exception_details)
+ raw_repo = project.repository&.raw_repository
+ root_ref = raw_repo&.root_ref
+
+ return default_count unless root_ref
+
+ Gitlab::GitalyClient::CommitService.new(raw_repo).commit_count(root_ref, {
+ all: true, # include all branches
+ max_count: max_count # limit as an optimization
+ })
+ rescue StandardError => e
+ Gitlab::ErrorTracking.track_exception(e, exception_details)
+
+ default_count
+ end
+end
diff --git a/app/experiments/empty_repo_upload_experiment.rb b/app/experiments/empty_repo_upload_experiment.rb
new file mode 100644
index 00000000000..d0d79a5fb45
--- /dev/null
+++ b/app/experiments/empty_repo_upload_experiment.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class EmptyRepoUploadExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
+ include ProjectCommitCount
+
+ TRACKING_START_DATE = DateTime.parse('2021/4/20')
+ INITIAL_COMMIT_COUNT = 1
+
+ def track_initial_write
+ return unless should_track? # early return if we don't need to ask for commit counts
+ return unless context.project.created_at > TRACKING_START_DATE # early return for older projects
+ return unless commit_count == INITIAL_COMMIT_COUNT
+
+ track(:initial_write, project: context.project)
+ end
+
+ private
+
+ def commit_count
+ commit_count_for(context.project, max_count: INITIAL_COMMIT_COUNT, experiment: name)
+ end
+end
diff --git a/app/experiments/in_product_guidance_environments_webide_experiment.rb b/app/experiments/in_product_guidance_environments_webide_experiment.rb
new file mode 100644
index 00000000000..d77063a9834
--- /dev/null
+++ b/app/experiments/in_product_guidance_environments_webide_experiment.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class InProductGuidanceEnvironmentsWebideExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
+ exclude :has_environments?
+
+ def control_behavior
+ false
+ end
+
+ private
+
+ def has_environments?
+ !context.project.environments.empty?
+ end
+end
diff --git a/app/experiments/members/invite_email_experiment.rb b/app/experiments/members/invite_email_experiment.rb
index 6a7d2b110d3..f780c6962df 100644
--- a/app/experiments/members/invite_email_experiment.rb
+++ b/app/experiments/members/invite_email_experiment.rb
@@ -7,6 +7,10 @@ module Members
INVITE_TYPE = 'initial_email'
+ def self.initial_invite_email?(invite_type)
+ invite_type == INVITE_TYPE
+ end
+
def resolve_variant_name
RoundRobin.new(feature_flag_name, %i[avatar permission_info control]).execute
end
diff --git a/app/experiments/new_project_readme_experiment.rb b/app/experiments/new_project_readme_experiment.rb
index 8f88ad2adc1..c5c41330949 100644
--- a/app/experiments/new_project_readme_experiment.rb
+++ b/app/experiments/new_project_readme_experiment.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class NewProjectReadmeExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
- include Gitlab::Git::WrapsGitalyErrors
+ include ProjectCommitCount
INITIAL_WRITE_LIMIT = 3
EXPERIMENT_START_DATE = DateTime.parse('2021/1/20')
@@ -21,25 +21,18 @@ class NewProjectReadmeExperiment < ApplicationExperiment # rubocop:disable Gitla
def track_initial_writes(project)
return unless should_track? # early return if we don't need to ask for commit counts
return unless project.created_at > EXPERIMENT_START_DATE # early return for older projects
- return unless (commit_count = commit_count_for(project)) < INITIAL_WRITE_LIMIT
+ return unless (count = commit_count(project)) < INITIAL_WRITE_LIMIT
- track(:write, property: project.created_at.to_s, value: commit_count)
+ track(:write, property: project.created_at.to_s, value: count)
end
private
- def commit_count_for(project)
- raw_repo = project.repository&.raw_repository
- return INITIAL_WRITE_LIMIT unless raw_repo&.root_ref
-
- begin
- Gitlab::GitalyClient::CommitService.new(raw_repo).commit_count(raw_repo.root_ref, {
- all: true, # include all branches
- max_count: INITIAL_WRITE_LIMIT # limit as an optimization
- })
- rescue StandardError => e
- Gitlab::ErrorTracking.track_exception(e, experiment: name)
- INITIAL_WRITE_LIMIT
- end
+ def commit_count(project)
+ commit_count_for(project,
+ default_count: INITIAL_WRITE_LIMIT,
+ max_count: INITIAL_WRITE_LIMIT,
+ experiment: name
+ )
end
end