Skip to content

Add event definitions at GIET generator

What does this MR do and why?

Based on !118738 (merged)

Add event definitions at GIET generator

Implements step towards #407865 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

You can use generator in your terminal like:

$ bin/rails g gitlab:analytics:internal_events --help                                                                                      Usage:
  rails generate gitlab:analytics:internal_events [options]

Options:
  [--time-frames=7d, 28d]            # Indicates the metrics time frames. Please select one or more from: 7d, 28d
                                     # Default: 7d, 28d
  [--tiers=free, premium, ultimate]  # Indicates the metric's GitLab subscription tiers. Please select one or more from: free, premium, ultimate
                                     # Default: free, premium, ultimate
  [--group=GROUP]                    # Name of group that added this metric
  [--stage=STAGE]                    # Name of stage that added this metric
  [--section=SECTION]                # Name of section that added this metric
  [--mr=MR]                          # Merge Request that adds this metric
  [--event=EVENT]                    # Name of the event that this metric counts
  [--unique-on=UNIQUE_ON]            # Name of the event property that this metric counts

Runtime options:
  -f, [--force]                    # Overwrite files that already exist
  -p, [--pretend], [--no-pretend]  # Run but do not make any changes
  -q, [--quiet], [--no-quiet]      # Suppress status output
  -s, [--skip], [--no-skip]        # Skip files that already exist

Generates metric definitions, event definition yml files and known events entries

Following command

bin/rails g gitlab:analytics:internal_events --event test_event --section test --group test --category test --stage test --mr https://gitlab.com/gitlab-org/gitlab/-/merge_requests/118738 --unique_on user_id 

should result in 3 files being created

      create  config/events/test_event.yml
      create  config/metrics/counts_7d/count_distinct_user_id_from_test_event_7d.yml
      create  config/metrics/counts_28d/count_distinct_user_id_from_test_event_28d.yml

And one entry being appended to lib/gitlab/usage_data_counters/known_events/common.yml

      append  lib/gitlab/usage_data_counters/known_events/common.yml

MR acceptance checklist

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

Edited by Mikołaj Wawrzyniak

Merge request reports