Sha256: 5797a68b59b74d9741ffa335442bcdd4ec86a8c2606f20794de0446d73430e3b

Contents?: true

Size: 1.84 KB

Versions: 44

Compression:

Stored size: 1.84 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?
        Helper.log.debug("Sending Crash/Success information. More information on: https://github.com/fastlane/enhancer")
        Helper.log.debug("No personal/sensitive data is sent. Only sharing the following:")
        Helper.log.debug(launches)
        Helper.log.debug(@error) if @error
        Helper.log.debug("This information is used to fix failing actions and improve integrations that are often used.")
        Helper.log.debug("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

44 entries across 44 versions & 1 rubygems

Version Path
fastlane-1.54.0 lib/fastlane/action_collector.rb
fastlane-1.53.0 lib/fastlane/action_collector.rb
fastlane-1.52.0 lib/fastlane/action_collector.rb
fastlane-1.51.0 lib/fastlane/action_collector.rb
fastlane-1.50.0 lib/fastlane/action_collector.rb
fastlane-1.49.0 lib/fastlane/action_collector.rb
fastlane-1.48.0 lib/fastlane/action_collector.rb
fastlane-1.47.0 lib/fastlane/action_collector.rb
fastlane-1.46.1 lib/fastlane/action_collector.rb
fastlane-1.46.0 lib/fastlane/action_collector.rb
fastlane-1.45.0 lib/fastlane/action_collector.rb
fastlane-1.44.0 lib/fastlane/action_collector.rb
fastlane-1.43.0 lib/fastlane/action_collector.rb
fastlane-1.42.0 lib/fastlane/action_collector.rb
fastlane-1.41.1 lib/fastlane/action_collector.rb
fastlane-1.41.0 lib/fastlane/action_collector.rb
fastlane-1.40.0 lib/fastlane/action_collector.rb
fastlane-1.39.0 lib/fastlane/action_collector.rb
fastlane-1.38.1 lib/fastlane/action_collector.rb
fastlane-1.38.0 lib/fastlane/action_collector.rb