Class: OpportunityFollowedUpHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- OpportunityFollowedUpHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/opportunity_followed_up_handler.rb
Overview
Async handler for Events::OpportunityFollowedUp.
Reports an ad-platform conversion for every connected CAPI when an
opportunity moves to the follow_up state. The conversion_date_time
is captured at transition time and embedded in the event payload so
downstream reporters use the actual transition timestamp, not when
this job runs.
Order of operations:
- Google (synchronous) — preserves the original behavior; failures
bubble up so the job retries and ErrorReporting.error fires. - Pinterest (Sidekiq, async) — non-blocking; failures contained
inside the worker's retry policy. - OpenAI Ads (Sidekiq, async) — same pattern as Pinterest.
- Facebook/Meta (Sidekiq, async) — same pattern as Pinterest.
Instance Method Summary collapse
Instance Method Details
#perform(event) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/subscribers/opportunity_followed_up_handler.rb', line 24 def perform(event) opportunity = Opportunity.find_by(id: event.data[:opportunity_id]) return unless opportunity conversion_date_time = Time.zone.parse(event.data[:conversion_date_time]) Invoicing::GoogleConversionReporter.new.send_new_opportunity_conversion( opportunity, conversion_date_time: conversion_date_time ) PinterestConversionWorker.perform_async(opportunity.id, 'opportunity') OpenaiAdsConversionWorker.perform_async(opportunity.id, 'opportunity') FacebookConversionWorker.perform_async(opportunity.id, 'opportunity') rescue StandardError => e ErrorReporting.error(e) raise end |