Sha256: 8894da23d4aa4758f82d0249417296305c941c276030c5bf8630fea0b7eb7906

Contents?: true

Size: 1.19 KB

Versions: 161

Compression:

Stored size: 1.19 KB

Contents

require 'openssl'

require_relative '../helper'

module FastlaneCore
  class AnalyticsIngesterClient
    def post_events(events)
      unless Helper.test?
        Thread.new 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

161 entries across 161 versions & 1 rubygems

Version Path
fastlane-2.86.0.beta.20180319050058 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180318050106 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180317050040 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180316050051 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180315050105 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180314050053 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180313050023 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180312050111 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180311050103 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180310050010 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.86.0.beta.20180309050025 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180308050114 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180307050101 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180306050019 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180305050037 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180304050031 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180303050048 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.85.0.beta.20180302050035 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane-2.84.0 fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb