Class: Fastlane::ActionCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/action_collector.rb

Constant Summary collapse

HOST_URL =
"https://fastlane-enhancer.herokuapp.com/"

Instance Method Summary collapse

Instance Method Details

#did_finishObject

Sends the used actions Example data => [:xcode_select, :deliver, :notify, :slack]



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fastlane/action_collector.rb', line 20

def did_finish
  return if ENV["FASTLANE_OPT_OUT_USAGE"]
  if !did_show_message? and !Helper.is_ci?
    UI.message("Sending Crash/Success information. More information on: https://github.com/fastlane/enhancer")
    UI.message("No personal/sensitive data is sent. Only sharing the following:")
    UI.message(launches)
    UI.message(@error) if @error
    UI.message("This information is used to fix failing actions and improve integrations that are often used.")
    UI.message("You can disable this by adding `opt_out_usage` to your Fastfile")
  end

  require 'excon'
  url = HOST_URL + '/did_launch?'
  url += URI.encode_www_form(
    steps: launches.to_json,
    error: @error
  )

  unless Helper.is_test? # don't send test data
    fork do
      begin
        Excon.post(url)
      rescue
        # we don't want to show a stack trace if something goes wrong
      end
    end
  end
rescue
  # We don't care about connection errors
end

#did_launch_action(name) ⇒ Object



5
6
7
8
9
10
# File 'lib/fastlane/action_collector.rb', line 5

def did_launch_action(name)
  if is_official?(name)
    launches[name] ||= 0
    launches[name] += 1
  end
end

#did_raise_error(name) ⇒ Object



12
13
14
15
16
# File 'lib/fastlane/action_collector.rb', line 12

def did_raise_error(name)
  if is_official?(name)
    @error = name
  end
end

#did_show_message?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
65
66
# File 'lib/fastlane/action_collector.rb', line 60

def did_show_message?
  path = File.join(File.expand_path('~'), '.did_show_opt_info')

  did_show = File.exist? path
  File.write(path, '1')
  did_show
end

#is_official?(name) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/fastlane/action_collector.rb', line 55

def is_official?(name)
  return true if name == :lane_switch
  Actions.get_all_official_actions.include? name
end

#launchesObject



51
52
53
# File 'lib/fastlane/action_collector.rb', line 51

def launches
  @launches ||= {}
end