Class: GetaroundUtils::Utils::CapturReporter
- Inherits:
-
AsyncQueue
- Object
- AsyncQueue
- GetaroundUtils::Utils::CapturReporter
- 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
- #metas ⇒ Object
- #perform(events) ⇒ Object
- #push(uuid:, type:, anonymous_id:, timestamp: nil, attributes: {}) ⇒ Object
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
#metas ⇒ Object
19 20 21 |
# File 'lib/getaround_utils/utils/captur_reporter.rb', line 19 def {} 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.[:open_timeout] = 1 req.[:timeout] = 1 req.headers = { 'Content-Type': 'application/json' } req.body = JSON.generate(events: events, 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: || Time.now.iso8601, anonymous_id: anonymous_id, attributes: attributes, ) end |