Sha256: 8a95b508dfe50ecbc2ec10f6727ac13eccdfcb87a66a9e07f086098566df7ee7

Contents?: true

Size: 780 Bytes

Versions: 9

Compression:

Stored size: 780 Bytes

Contents

require 'json'
require 'faraday'
require 'getaround_utils/utils/async_queue'

class GetaroundUtils::Utils::CapturReporter < GetaroundUtils::Utils::AsyncQueue
  CAPTUR_URL = ENV['CAPTUR_URL']

  def perform(events)
    return unless CAPTUR_URL&.match('^https?://')

    Faraday.post(CAPTUR_URL) do |req|
      req.options[:open_timeout] = 1
      req.options[:timeout] = 1
      req.headers = { 'Content-Type': 'application/json' }
      req.body = JSON.generate(events: events, metas: metas)
    end
  end

  def metas
    {}
  end

  def push(uuid:, type:, anonymous_id:, timestamp: nil, attributes: {})
    super(
      uuid: uuid,
      type: type,
      timestamp: timestamp || Time.now.iso8601,
      anonymous_id: anonymous_id,
      attributes: attributes,
    )
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
getaround_utils-0.2.11 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.10 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.9 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.7 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.6 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.5 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.1 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.2.0 lib/getaround_utils/utils/captur_reporter.rb
getaround_utils-0.1.20 lib/getaround_utils/utils/captur_reporter.rb