Class: FastlaneCore::AnalyticsEventBuilder

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oauth_app_name: nil, p_hash: nil, session_id: nil, action_name: nil, timestamp_millis: (Time.now.to_f * 1000).to_i) ⇒ AnalyticsEventBuilder

Returns a new instance of AnalyticsEventBuilder.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb', line 6

def initialize(oauth_app_name: nil, p_hash: nil, session_id: nil, action_name: nil, timestamp_millis: (Time.now.to_f * 1000).to_i)
  @action_name = action_name
  @base_hash = {
    event_source: {
      oauth_app_name: oauth_app_name,
      product: 'fastlane'
    },
    actor: {
      name: p_hash,
      detail: session_id
    },
    millis_since_epoch: timestamp_millis,
    version: 1
  }
end

Instance Attribute Details

#action_nameObject

Returns the value of attribute action_name.



4
5
6
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb', line 4

def action_name
  @action_name
end

#base_hashObject

Returns the value of attribute base_hash.



3
4
5
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb', line 3

def base_hash
  @base_hash
end

Instance Method Details

#completed_event(primary_target_hash: nil, secondary_target_hash: nil) ⇒ Object



30
31
32
33
34
35
36
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb', line 30

def completed_event(primary_target_hash: nil, secondary_target_hash: nil)
  return new_event(
    stage: 'completed',
    primary_target_hash: primary_target_hash,
    secondary_target_hash: secondary_target_hash
  )
end

#launched_event(primary_target_hash: nil, secondary_target_hash: nil) ⇒ Object



22
23
24
25
26
27
28
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb', line 22

def launched_event(primary_target_hash: nil, secondary_target_hash: nil)
  return new_event(
    stage: 'launched',
    primary_target_hash: primary_target_hash,
    secondary_target_hash: secondary_target_hash
  )
end

#new_event(stage: nil, primary_target_hash: nil, secondary_target_hash: nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb', line 38

def new_event(stage: nil, primary_target_hash: nil, secondary_target_hash: nil)
  raise 'Need at least a primary_target_hash' if primary_target_hash.nil?
  event = base_hash.dup
  event[:action] = {
      name: stage,
      detail: action_name
  }
  event[:primary_target] = primary_target_hash
  event[:secondary_target] = secondary_target_hash unless secondary_target_hash.nil?
  return event
end