Class: GetaroundUtils::Utils::CapturReporter

Inherits:
AsyncQueue
  • Object
show all
Defined in:
lib/getaround_utils/utils/captur_reporter.rb

Constant Summary collapse

CAPTUR_URL =
ENV['CAPTUR_URL']

Constants inherited from AsyncQueue

AsyncQueue::BUFFER_SIZE, AsyncQueue::MAX_QUEUE_SIZE

Instance Method Summary collapse

Methods inherited from AsyncQueue

#initialize, #terminate, #thread_run

Methods included from Mixins::Loggable

#base_append_infos_to_loggable, #base_loggable_logger, #class_name, #loggable, #loggable_log

Constructor Details

This class inherits a constructor from GetaroundUtils::Utils::AsyncQueue

Instance Method Details

#metasObject



19
20
21
# File 'lib/getaround_utils/utils/captur_reporter.rb', line 19

def metas
  {}
end

#perform(events) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/getaround_utils/utils/captur_reporter.rb', line 8

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

#push(uuid:, type:, anonymous_id:, timestamp: nil, attributes: {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/getaround_utils/utils/captur_reporter.rb', line 23

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