Skip to content

Create event definitions for Internal Events metrics

What does this MR do and why?

It add events definitions for the metrics events below and remove them from the allowlist in spec/lib/gitlab/tracking/event_definition_spec.rb

All values expect for the descriptions were automatically extracted from the metric definitions to create consistent data.

This means that some product_group, product_section and product_stage is already outdated. Bringing the ownership information up to date will be done in #431917.

I filled out the descriptions based on the descriptions in the metric definitions.

Code for generating events

Put the following script in a file e.g /tmp/create_event.rb and run create a new event definition for user_visited_dashboard like this: rails runner /tmp/create_event.rb user_visited_dashboard.

require 'irb'

def a_to_yaml(list)
	"\n- #{list.join("\n- ")}"
end

event_name = ARGV[0]

definitions = Gitlab::Usage::MetricDefinition.all.select { |definition| definition.attributes[:events]&.any? { |event| event[:name] == event_name } }
tiers = definitions.flat_map{|d| d.attributes[:tier]}.uniq
distributions = definitions.flat_map{|d| d.attributes[:distribution]}.uniq

product_section = definitions.map{|d| d.attributes[:product_section]}.uniq
product_stage = definitions.map{|d| d.attributes[:product_stage]}.uniq
product_group = definitions.map{|d| d.attributes[:product_group]}.uniq

path_prefix = distributions == ['ee'] ? 'ee/' : ''

event = event_name
event_identifiers = "\n- project\n- user\n- namespace"
options = { section: product_section.join(', '), stage: product_stage.join(', '), group: product_group.join(', '), mr: "TODO" }
milestone = "TODO"
distributions = a_to_yaml(distributions)
tiers = a_to_yaml(tiers)
args = []

template = ERB.new(File.read(Rails.root.join('generator_templates/gitlab_internal_events/event_definition.yml')))
event_configuration = template.result(binding)

event_definition_path = "#{path_prefix}config/events/#{event_name}.yml"
File.write(Rails.root.join(event_definition_path), event_configuration)
Event name Added Milestone introduced_by_url
g_compliance_dashboard 16.4 !131045 (merged)
g_project_management_users_epic_issue_added_from_epic 16.4 !131495 (merged)
i_analytics_dev_ops_adoption 16.4 !131045 (merged)
i_analytics_dev_ops_score 16.4 !131045 (merged)
user_edited_cluster_configuration 16.4 !131168 (merged)
user_viewed_cluster_configuration 16.4 !131168 (merged)
user_viewed_dashboard_list 16.4 !131168 (merged)
user_viewed_instrumentation_directions 16.4 !131168 (merged)
user_visited_dashboard 16.7 !134543 (merged)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #428014 (closed)

Edited by Jonas Larsen

Merge request reports