Bettor logging

This commit is contained in:
Seth Call 2026-01-15 07:59:27 -06:00
parent ed561be4b5
commit 253a6c566b
3 changed files with 17 additions and 1 deletions

View File

@ -6,11 +6,13 @@ class CapiTransmitter
def self.send_event(event_name, user, custom_data = {}, event_source_url = nil) def self.send_event(event_name, user, custom_data = {}, event_source_url = nil)
begin begin
@@log.info("CapiTransmitter: Sending event #{event_name} for User #{user.id}")
pixel_id = APP_CONFIG.facebook_pixel_id pixel_id = APP_CONFIG.facebook_pixel_id
access_token = APP_CONFIG.facebook_access_token access_token = APP_CONFIG.facebook_access_token
if pixel_id.blank? || access_token.blank? if pixel_id.blank? || access_token.blank?
Rails.logger.warn("CapiTransmitter: Missing Facebook Pixel ID or Access Token. Skipping event #{event_name}.") Rails.logger.warn("CapiTransmitter: Missing Facebook Pixel ID or Access Token. Skipping event #{event_name}.")
puts("CapiTransmitter: Missing Facebook Pixel ID or Access Token. Skipping event #{event_name}.")
return return
end end
@ -63,13 +65,17 @@ class CapiTransmitter
if response.code.to_i >= 400 if response.code.to_i >= 400
Rails.logger.error("CapiTransmitter Error: #{response.code} - #{response.body}") Rails.logger.error("CapiTransmitter Error: #{response.code} - #{response.body}")
puts("CapiTransmitter Error: #{response.code} - #{response.body}")
else else
Rails.logger.info("CapiTransmitter Success: #{event_name} sent for User #{user.id}") Rails.logger.info("CapiTransmitter Success: #{event_name} sent for User #{user.id}")
puts("CapiTransmitter Success: #{event_name} sent for User #{user.id}")
end end
rescue => e rescue => e
Rails.logger.error("CapiTransmitter Exception: #{e.message}") Rails.logger.error("CapiTransmitter Exception: #{e.message}")
puts("CapiTransmitter Exception: #{e.message}")
Rails.logger.error(e.backtrace.join("\n")) Rails.logger.error(e.backtrace.join("\n"))
puts(e.backtrace.join("\n"))
end end
end end
end end

View File

@ -555,6 +555,7 @@ module JamRuby
end end
rescue => e rescue => e
Rails.logger.error("Error sending CAPI event: #{e.message}") Rails.logger.error("Error sending CAPI event: #{e.message}")
puts("Error sending CAPI event: #{e.message}")
end end
self.save self.save
@ -1886,7 +1887,11 @@ module JamRuby
else else
# CAPI Hook: CompleteRegistration # CAPI Hook: CompleteRegistration
if user.facebook_click_id.present? if user.facebook_click_id.present?
begin
CapiTransmitter.send_event('CompleteRegistration', user) CapiTransmitter.send_event('CompleteRegistration', user)
rescue => e
puts("Error sending CompleteRegistration CAPI event: #{e.message}")
end
end end
# if the partner ID was present and the partner doesn't already have a user associated, associate this new user with the affiliate partner # if the partner ID was present and the partner doesn't already have a user associated, associate this new user with the affiliate partner

View File

@ -183,7 +183,12 @@ class ApiRecurlyController < ApiController
if monthly_cost > 0 if monthly_cost > 0
ltv = monthly_cost * 12 ltv = monthly_cost * 12
CapiTransmitter.send_event('Subscribe', current_user, { value: monthly_cost.to_s, currency: 'USD', predicted_ltv: ltv.to_s }) begin
puts "Sending CAPI Subscribe event #{current_user.email}, #{monthly_cost}, #{ltv}"
CapiTransmitter.send_event('Subscribe', current_user, { value: monthly_cost.to_s, currency: 'USD', predicted_ltv: ltv.to_s })
rescue => e
puts "Error sending CAPI Subscribe event #{current_user.email}, #{e.message}"
end
end end
rescue => e rescue => e
puts "Error sending CAPI Subscribe event #{current_user.email}, #{e.message}" puts "Error sending CAPI Subscribe event #{current_user.email}, #{e.message}"