Class: Gitlab::Analytics::InternalEventsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/gitlab/analytics/internal_events_generator.rb

Constant Summary collapse

TIME_FRAME_DIRS =
{
  'all' => 'counts_all',
  '7d' => 'counts_7d',
  '28d' => 'counts_28d'
}.freeze
TIME_FRAMES_DEFAULT =
TIME_FRAME_DIRS.keys.tap do |time_frame_defaults|
  time_frame_defaults.class_eval do
    def to_s
      join(", ")
    end
  end
end.freeze
ALLOWED_TIERS =
%w[free premium ultimate].dup.tap do |tiers_default|
  tiers_default.class_eval do
    def to_s
      join(", ")
    end
  end
end.freeze
NEGATIVE_ANSWERS =
%w[no n No NO N].freeze
POSITIVE_ANSWERS =
%w[yes y Yes YES Y].freeze
TOP_LEVEL_DIR =
'config'
TOP_LEVEL_DIR_EE =
'ee'
DESCRIPTION_MIN_LENGTH =
50
DESCRIPTION_INQUIRY =
%(
  Please describe in at least #{DESCRIPTION_MIN_LENGTH} characters
  what %{entity} %{entity_type} represents,
  consider mentioning: %{considerations}.
  Your answer will be processed by a full-text search tool and help others find and reuse this %{entity_type}.
).freeze

Instance Method Summary collapse

Instance Method Details

#create_metric_fileObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/generators/gitlab/analytics/internal_events_generator.rb', line 88

def create_metric_file
  validate!

  unless event_exists?
    template "event_definition.yml",
      event_file_path(event),
      ask_description(event, "event", "what the event is supposed to track, where, and when")
  end

  time_frames.each do |time_frame|
    template "metric_definition.yml",
      metric_file_path(time_frame),
      key_path(time_frame),
      time_frame,
      ask_description(
        key_path(time_frame),
        "metric",
        "events, and event attributes in the description"
      )
  end
end