Sha256: 764aa7e3a129cf573f540f5370462a8437ecc8b8a65d6aeb6aedaee6b23ca99a

Contents?: true

Size: 1.81 KB

Versions: 21

Compression:

Stored size: 1.81 KB

Contents

module Fastlane
  class ActionCollector
    HOST_URL = "https://fastlane-enhancer.herokuapp.com/"

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

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

    # Sends the used actions
    # Example data => [:xcode_select, :deliver, :notify, :slack]
    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

    def launches
      @launches ||= {}
    end

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

    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
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
fastlane-1.83.0 lib/fastlane/action_collector.rb
fastlane-1.82.0 lib/fastlane/action_collector.rb
fastlane-1.81.0 lib/fastlane/action_collector.rb
fastlane-1.80.0 lib/fastlane/action_collector.rb
fastlane-1.70.0 lib/fastlane/action_collector.rb
fastlane-1.69.0 lib/fastlane/action_collector.rb
fastlane-1.68.0 lib/fastlane/action_collector.rb
fastlane-1.67.0 lib/fastlane/action_collector.rb
fastlane-1.66.0 lib/fastlane/action_collector.rb
fastlane-1.65.0 lib/fastlane/action_collector.rb
fastlane-1.64.0 lib/fastlane/action_collector.rb
fastlane-1.63.1 lib/fastlane/action_collector.rb
fastlane-1.63.0 lib/fastlane/action_collector.rb
fastlane-1.62.0 lib/fastlane/action_collector.rb
fastlane-1.61.0 lib/fastlane/action_collector.rb
fastlane-1.60.0 lib/fastlane/action_collector.rb
fastlane-1.59.0 lib/fastlane/action_collector.rb
fastlane-1.58.0 lib/fastlane/action_collector.rb
fastlane-1.57.0 lib/fastlane/action_collector.rb
fastlane-1.56.0 lib/fastlane/action_collector.rb