Class: Ci::TrackPipelineTriggerEventsWorker

Inherits:
Object
  • Object
show all
Includes:
Gitlab::EventStore::Subscriber, Gitlab::InternalEventsTracking
Defined in:
app/workers/ci/track_pipeline_trigger_events_worker.rb

Instance Method Summary collapse

Methods included from Gitlab::InternalEventsTracking

#track_internal_event

Methods included from Gitlab::EventStore::Subscriber

#handle_event_in, #perform

Instance Method Details

#handle_event(event) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/workers/ci/track_pipeline_trigger_events_worker.rb', line 15

def handle_event(event)
  pipeline = Ci::Pipeline.in_partition(event.data[:partition_id]).find_by_id(event.data[:pipeline_id])
  return unless pipeline

  user_type = pipeline.user&.bot? ? 'bot' : 'human'

  track_internal_event(
    'ci_pipeline_triggered',
    user: pipeline.user,
    project: pipeline.project,
    additional_properties: { user_type: user_type }
  )

  pipeline.builds.find_each do |build|
    track_internal_event(
      'ci_build_triggered',
      user: build.user,
      project: pipeline.project,
      additional_properties: { user_type: user_type }
    )
  end
end