Class: Gitlab::Tracking::EventDefinition
- Inherits:
-
Object
- Object
- Gitlab::Tracking::EventDefinition
- Extended by:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/tracking/event_definition.rb
Constant Summary collapse
- IDENTIFIERS =
[:user, :namespace, :project].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #action ⇒ Object
- #additional_properties ⇒ Object
- #category ⇒ Object
- #duo_event? ⇒ Boolean
- #event_selection_rules ⇒ Object
- #extra_trackers ⇒ Object
-
#initialize(path, opts = {}) ⇒ EventDefinition
constructor
A new instance of EventDefinition.
- #internal_events? ⇒ Boolean
- #raw_attributes ⇒ Object
- #yaml_path ⇒ Object
Constructor Details
#initialize(path, opts = {}) ⇒ EventDefinition
Returns a new instance of EventDefinition.
56 57 58 59 |
# File 'lib/gitlab/tracking/event_definition.rb', line 56 def initialize(path, opts = {}) @path = path @attributes = opts end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/gitlab/tracking/event_definition.rb', line 8 def path @path end |
Class Method Details
.definitions ⇒ Object
15 16 17 |
# File 'lib/gitlab/tracking/event_definition.rb', line 15 def definitions @definitions ||= paths.flat_map { |glob_path| load_all_from_path(glob_path) } end |
.find(event_name) ⇒ Object
23 24 25 26 27 |
# File 'lib/gitlab/tracking/event_definition.rb', line 23 def find(event_name) strong_memoize_with(:find, event_name) do definitions.find { |definition| definition.action == event_name } end end |
.internal_event_exists?(event_name) ⇒ Boolean
19 20 21 |
# File 'lib/gitlab/tracking/event_definition.rb', line 19 def internal_event_exists?(event_name) internal_event_actions.include?(event_name) end |
Instance Method Details
#action ⇒ Object
81 82 83 |
# File 'lib/gitlab/tracking/event_definition.rb', line 81 def action @attributes[:action] end |
#additional_properties ⇒ Object
61 62 63 |
# File 'lib/gitlab/tracking/event_definition.rb', line 61 def additional_properties @attributes.fetch(:additional_properties, {}).except(*IDENTIFIERS) end |
#category ⇒ Object
69 70 71 |
# File 'lib/gitlab/tracking/event_definition.rb', line 69 def category @attributes[:category] end |
#duo_event? ⇒ Boolean
94 95 96 |
# File 'lib/gitlab/tracking/event_definition.rb', line 94 def duo_event? @attributes[:classification] == 'duo' end |
#event_selection_rules ⇒ Object
77 78 79 |
# File 'lib/gitlab/tracking/event_definition.rb', line 77 def event_selection_rules @event_selection_rules ||= find_event_selection_rules end |
#extra_trackers ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/gitlab/tracking/event_definition.rb', line 85 def extra_trackers @attributes.fetch(:extra_trackers, []).to_h do |item| [ item[:tracking_class].constantize, { protected_properties: item[:protected_properties]&.keys || [] } ] end end |
#internal_events? ⇒ Boolean
65 66 67 |
# File 'lib/gitlab/tracking/event_definition.rb', line 65 def internal_events? @attributes[:internal_events] end |
#raw_attributes ⇒ Object
98 99 100 |
# File 'lib/gitlab/tracking/event_definition.rb', line 98 def raw_attributes @attributes end |
#yaml_path ⇒ Object
73 74 75 |
# File 'lib/gitlab/tracking/event_definition.rb', line 73 def yaml_path path.delete_prefix(Rails.root.to_s) end |