Sha256: 38a5445f0994bef98fdc6924328b1e4f3499116c96edd55b2360ee3cb1997b53

Contents?: true

Size: 1.14 KB

Versions: 106

Compression:

Stored size: 1.14 KB

Contents

module FastlaneCore
  class AnalyticsIngesterClient
    def post_events(events)
      unless Helper.test?
        fork do
          send_request(json: { analytics: events }.to_json)
        end
      end
      return true
    end

    def send_request(json: nil, retries: 2)
      post_request(body: json)
    rescue
      retries -= 1
      retry if retries >= 0
    end

    def post_request(body: nil)
      if ENV['METRICS_DEBUG']
        write_json(body)
      end
      url = ENV["FASTLANE_METRICS_URL"] || "https://fastlane-metrics.fabric.io"

      require 'faraday'
      connection = Faraday.new(url) do |conn|
        conn.adapter Faraday.default_adapter
        if ENV['METRICS_DEBUG']
          conn.proxy = "https://127.0.0.1:8888"
          conn.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
        end
      end
      connection.post do |req|
        req.url '/public'
        req.headers['Content-Type'] = 'application/json'
        req.body = body
      end
    end

    # This method is only for debugging purposes
    def write_json(body)
      File.write("#{ENV['HOME']}/Desktop/mock_analytics-#{Time.now.to_i}.json", body)
    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
fastlane-2.74.0.beta.20180106010004 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.73.0 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.73.0.beta.20180105010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.73.0.beta.20180104010004 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.73.0.beta.20180103010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0.beta.20180102010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0.beta.20180101010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0.beta.20171231010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.1 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0.beta.20171230010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0.beta.20171229010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.72.0.beta.20171228010004 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0.beta.20171227010004 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0.beta.20171226010004 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0.beta.20171225010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0.beta.20171224010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0.beta.20171223010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.71.0.beta.20171222010003 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb