diff options
Diffstat (limited to 'lib/gitlab/tracking.rb')
-rw-r--r-- | lib/gitlab/tracking.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitlab/tracking.rb b/lib/gitlab/tracking.rb index a58b4beb0df..0e7812d08b8 100644 --- a/lib/gitlab/tracking.rb +++ b/lib/gitlab/tracking.rb @@ -15,6 +15,21 @@ module Gitlab Gitlab::ErrorTracking.track_and_raise_for_dev_exception(error, snowplow_category: category, snowplow_action: action) end + def definition(basename, category: nil, action: nil, label: nil, property: nil, value: nil, context: [], project: nil, user: nil, namespace: nil, **extra) # rubocop:disable Metrics/ParameterLists + definition = YAML.load_file(Rails.root.join("config/events/#{basename}.yml")) + + dispatch_from_definition(definition, label: label, property: property, value: value, context: context, project: project, user: user, namespace: namespace, **extra) + end + + def dispatch_from_definition(definition, **event_data) + definition = definition.with_indifferent_access + + category ||= definition[:category] + action ||= definition[:action] + + event(category, action, **event_data) + end + def options(group) snowplow.options(group) end @@ -39,3 +54,5 @@ module Gitlab end end end + +Gitlab::Tracking.prepend_mod_with('Gitlab::Tracking') |