Class: Omnitrack::Jobs::TrackingJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/omnitrack/jobs/tracking_job.rb

Overview

ActiveJob wrapper for asynchronous event dispatch. Enqueued automatically when Omnitrack.config.async == true.

The job serializes the operation + arguments to JSON so they survive the queue boundary. All arguments must be plain Ruby primitives.

Instance Method Summary collapse

Instance Method Details

#perform(operation, *args) ⇒ Object

Parameters:

  • operation (String)

    stringified symbol, e.g. “track_event”

  • args (Array)

    JSON-serialisable positional arguments



16
17
18
19
20
21
22
23
24
# File 'lib/omnitrack/jobs/tracking_job.rb', line 16

def perform(operation, *args)
  Omnitrack::Pipeline::Dispatcher.dispatch(operation.to_sym, *args)
rescue StandardError => e
  Omnitrack.logger.error("tracking_job.error",
                         operation: operation,
                         error:     e.class.name,
                         message:   e.message)
  raise # Re-raise so ActiveJob retry logic still works
end