summaryrefslogtreecommitdiff
path: root/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/usage_data_counters/ci_template_unique_counter.rb')
-rw-r--r--lib/gitlab/usage_data_counters/ci_template_unique_counter.rb28
1 files changed, 11 insertions, 17 deletions
diff --git a/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb b/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
index e5a50c92329..b8de7de848d 100644
--- a/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
+++ b/lib/gitlab/usage_data_counters/ci_template_unique_counter.rb
@@ -5,23 +5,14 @@ module Gitlab::UsageDataCounters
REDIS_SLOT = 'ci_templates'
KNOWN_EVENTS_FILE_PATH = File.expand_path('known_events/ci_templates.yml', __dir__)
- # NOTE: Events originating from implicit Auto DevOps pipelines get prefixed with `implicit_`
- TEMPLATE_TO_EVENT = {
- '5-Minute-Production-App.gitlab-ci.yml' => '5_min_production_app',
- 'Auto-DevOps.gitlab-ci.yml' => 'auto_devops',
- 'AWS/CF-Provision-and-Deploy-EC2.gitlab-ci.yml' => 'aws_cf_deploy_ec2',
- 'AWS/Deploy-ECS.gitlab-ci.yml' => 'aws_deploy_ecs',
- 'Jobs/Build.gitlab-ci.yml' => 'auto_devops_build',
- 'Jobs/Deploy.gitlab-ci.yml' => 'auto_devops_deploy',
- 'Jobs/Deploy.latest.gitlab-ci.yml' => 'auto_devops_deploy_latest',
- 'Security/SAST.gitlab-ci.yml' => 'security_sast',
- 'Security/Secret-Detection.gitlab-ci.yml' => 'security_secret_detection',
- 'Terraform/Base.latest.gitlab-ci.yml' => 'terraform_base_latest'
- }.freeze
-
class << self
def track_unique_project_event(project_id:, template:, config_source:)
- Gitlab::UsageDataCounters::HLLRedisCounter.track_event(ci_template_event_name(template, config_source), values: project_id)
+ expanded_template_name = expand_template_name(template)
+ return unless expanded_template_name
+
+ Gitlab::UsageDataCounters::HLLRedisCounter.track_event(
+ ci_template_event_name(expanded_template_name, config_source), values: project_id
+ )
end
def ci_templates(relative_base = 'lib/gitlab/ci/templates')
@@ -30,9 +21,12 @@ module Gitlab::UsageDataCounters
def ci_template_event_name(template_name, config_source)
prefix = 'implicit_' if config_source.to_s == 'auto_devops_source'
- template_event_name = TEMPLATE_TO_EVENT[template_name] || template_to_event_name(template_name)
- "p_#{REDIS_SLOT}_#{prefix}#{template_event_name}"
+ "p_#{REDIS_SLOT}_#{prefix}#{template_to_event_name(template_name)}"
+ end
+
+ def expand_template_name(template_name)
+ Gitlab::Template::GitlabCiYmlTemplate.find(template_name.chomp('.gitlab-ci.yml'))&.full_name
end
private