Class: Gitlab::WorkItems::Instrumentation::TrackingService

Inherits:
Object
  • Object
show all
Includes:
InternalEventsTracking, EventActions
Defined in:
lib/gitlab/work_items/instrumentation/tracking_service.rb

Constant Summary

Constants included from EventActions

EventActions::ALL_EVENTS, EventActions::ASSIGNEES_UPDATE, EventActions::BLOCKED_BY_ITEM_ADD, EventActions::BLOCKED_BY_ITEM_REMOVE, EventActions::BLOCKING_ITEM_ADD, EventActions::BLOCKING_ITEM_REMOVE, EventActions::CLONE, EventActions::CLOSE, EventActions::CONFIDENTIALITY_DISABLE, EventActions::CONFIDENTIALITY_ENABLE, EventActions::CREATE, EventActions::CREATE_CHILD_ITEMS_WIDGET, EventActions::CREATE_GLOBAL_NAV, EventActions::CREATE_VULNERABILITY, EventActions::CREATE_WORK_ITEM_LIST, EventActions::DESCRIPTION_UPDATE, EventActions::DESIGN_CREATE, EventActions::DESIGN_DESTROY, EventActions::DESIGN_NOTE_CREATE, EventActions::DESIGN_NOTE_DESTROY, EventActions::DESIGN_UPDATE, EventActions::DUE_DATE_UPDATE, EventActions::HEALTH_STATUS_UPDATE, EventActions::ITERATION_UPDATE, EventActions::LABELS_UPDATE, EventActions::LOCK, EventActions::MARKED_AS_DUPLICATE, EventActions::MILESTONE_UPDATE, EventActions::MOVE, EventActions::NOTE_CREATE, EventActions::NOTE_DESTROY, EventActions::NOTE_UPDATE, EventActions::REFERENCE_ADD, EventActions::RELATED_ITEM_ADD, EventActions::RELATED_ITEM_REMOVE, EventActions::REOPEN, EventActions::START_DATE_UPDATE, EventActions::TIME_ESTIMATE_UPDATE, EventActions::TIME_SPENT_UPDATE, EventActions::TITLE_UPDATE, EventActions::UNLOCK, EventActions::WEIGHT_UPDATE

Instance Method Summary collapse

Methods included from EventActions

link_event, valid_event?

Methods included from InternalEventsTracking

#track_internal_event

Constructor Details

#initialize(work_item:, current_user:, event: nil, old_associations: nil) ⇒ TrackingService

Returns a new instance of TrackingService.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/gitlab/work_items/instrumentation/tracking_service.rb', line 10

def initialize(work_item:, current_user:, event: nil, old_associations: nil)
  raise ArgumentError unless valid_params?(work_item, current_user, event, old_associations)

  @work_item = work_item
  @current_user = current_user
  @event = event
  @old_associations = old_associations
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/work_items/instrumentation/tracking_service.rb', line 19

def execute
  if @event
    track_internal_event(@event, **event_properties)
  else
    EventMappings
      .events_for(work_item: @work_item, old_associations: @old_associations)
      .each { |event_name| track_internal_event(event_name, **event_properties) }
  end
end