Skip to content

Refactor InternalEvents CLI after adding array time_frames

Problem

InternalEvents CLI can be confusing when creating multiple metrics that belong to the same yml file.

Desired Outcome

Make the process easy to understand to the users.

Potential Solution

UX improvements:

  1. Show a message when prompted to save the file that the definition will create multiple metrics

    • along with this, we should display the key_path of each metric
    • this should ideally happen before the file is saved/created so users have accurate expectations ahead
  2. Default the metric options to include all of Total/Monthly/Weekly (except unique-by-identifier metrics)

    • if I want to creates all three metrics, I'll still end up with 2 files, because it's two separate flows in the CLI to add total, then monthly/weekly. And for the 2nd file, I'll have to define a new filename because the default name is already taken by the first definition

Maintenance improvements:↵

  1. Swap metric_definer.rb to operate on a single @metric instead of over @metrics
    • simplifies complexity of grouping logic in MetricOptions (to the point of !171972 (comment 2218951874), as I was confused the same way)
    • treating Metric as essentially a MetricFile better matches how we expect users to interact
    • this can remove the complexity from multiple description inputs, rename inputs, defaults, etc
  2. When creating metrics that could be defined in the same file as existing metrics, dedupe the files and relocate to the CLI-suggested filepath

Some of these ideas can be checked for implementation here: https://gitlab.com/gitlab-org/gitlab/-/compare/master...4e1c69a073e4ae39961fd17208975e0ac2469152

Documentation Update Needed

  • Yes
  • No

How to verify

Further actions needed

Edited by Nwanna Isong