fix reporting
This commit is contained in:
parent
8c8024c12b
commit
bdeecc76c6
|
|
@ -21,6 +21,12 @@ class CapiTransmitter
|
||||||
# client_user_agent: user.user_agent # Note: User model might not have user_agent stored directly, might need to pass it or rely on what's available
|
# client_user_agent: user.user_agent # Note: User model might not have user_agent stored directly, might need to pass it or rely on what's available
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !user.facebook_click_id.present? ||
|
||||||
|
user.origin_utm_source != APP_CONFIG.facebook_ad_source
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Enhance user data with hashed PII if available
|
# Enhance user data with hashed PII if available
|
||||||
# Facebook requires SHA256 hashing for PII
|
# Facebook requires SHA256 hashing for PII
|
||||||
# For now, we rely on click_id and browser_id as primary keys if available
|
# For now, we rely on click_id and browser_id as primary keys if available
|
||||||
|
|
|
||||||
|
|
@ -336,6 +336,34 @@ module JamRuby
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def report_meta_capi(current_user, plan_code)
|
||||||
|
# CAPI Hook: Subscribe
|
||||||
|
begin
|
||||||
|
monthly_cost = case plan_code
|
||||||
|
when JamRuby::SubscriptionDefinitions::JAM_SILVER, JamRuby::SubscriptionDefinitions::JAM_SILVER_YEARLY
|
||||||
|
5.00
|
||||||
|
when JamRuby::SubscriptionDefinitions::JAM_GOLD, JamRuby::SubscriptionDefinitions::JAM_GOLD_YEARLY
|
||||||
|
10.00
|
||||||
|
when JamRuby::SubscriptionDefinitions::JAM_PLATINUM, JamRuby::SubscriptionDefinitions::JAM_PLATINUM_YEARLY
|
||||||
|
20.00
|
||||||
|
else
|
||||||
|
0.00
|
||||||
|
end
|
||||||
|
|
||||||
|
if monthly_cost > 0
|
||||||
|
ltv = monthly_cost * 12
|
||||||
|
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
|
||||||
|
rescue => e
|
||||||
|
puts "Error sending CAPI Subscribe event #{current_user.email}, #{e.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_highest_plan(subscription)
|
def get_highest_plan(subscription)
|
||||||
SubscriptionDefinitions.higher_plan(subscription.plan.plan_code, get_pending_plan_code(subscription))
|
SubscriptionDefinitions.higher_plan(subscription.plan.plan_code, get_pending_plan_code(subscription))
|
||||||
end
|
end
|
||||||
|
|
@ -364,6 +392,8 @@ module JamRuby
|
||||||
end
|
end
|
||||||
current_user.reset_playtime
|
current_user.reset_playtime
|
||||||
current_user.save(validate: false)
|
current_user.save(validate: false)
|
||||||
|
|
||||||
|
report_meta_capi(current_user, plan_code)
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "Could not create subscription for user #{current_user.email}. #{e}"
|
puts "Could not create subscription for user #{current_user.email}. #{e}"
|
||||||
return false, subscription, account
|
return false, subscription, account
|
||||||
|
|
|
||||||
|
|
@ -168,34 +168,6 @@ class ApiRecurlyController < ApiController
|
||||||
def create_subscription
|
def create_subscription
|
||||||
begin
|
begin
|
||||||
sale = Sale.purchase_subscription(current_user, params[:recurly_token], params[:plan_code])
|
sale = Sale.purchase_subscription(current_user, params[:recurly_token], params[:plan_code])
|
||||||
|
|
||||||
# CAPI Hook: Subscribe
|
|
||||||
begin
|
|
||||||
plan_code = params[:plan_code]
|
|
||||||
monthly_cost = case plan_code
|
|
||||||
when JamRuby::SubscriptionDefinitions::JAM_SILVER, JamRuby::SubscriptionDefinitions::JAM_SILVER_YEARLY
|
|
||||||
5.00
|
|
||||||
when JamRuby::SubscriptionDefinitions::JAM_GOLD, JamRuby::SubscriptionDefinitions::JAM_GOLD_YEARLY
|
|
||||||
10.00
|
|
||||||
when JamRuby::SubscriptionDefinitions::JAM_PLATINUM, JamRuby::SubscriptionDefinitions::JAM_PLATINUM_YEARLY
|
|
||||||
20.00
|
|
||||||
else
|
|
||||||
0.00
|
|
||||||
end
|
|
||||||
|
|
||||||
if monthly_cost > 0
|
|
||||||
ltv = monthly_cost * 12
|
|
||||||
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
|
|
||||||
rescue => e
|
|
||||||
puts "Error sending CAPI Subscribe event #{current_user.email}, #{e.message}"
|
|
||||||
end
|
|
||||||
|
|
||||||
subscription = Recurly::Subscription.find(current_user.recurly_subscription_id)
|
subscription = Recurly::Subscription.find(current_user.recurly_subscription_id)
|
||||||
render :json => subscription.to_json
|
render :json => subscription.to_json
|
||||||
rescue RecurlyClientError => x
|
rescue RecurlyClientError => x
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,7 @@ if defined?(Bundler)
|
||||||
config.google_public_server_key = "AIzaSyCPTPq5PEcl4XWcm7NZ2IGClZlbsiE8JNo"
|
config.google_public_server_key = "AIzaSyCPTPq5PEcl4XWcm7NZ2IGClZlbsiE8JNo"
|
||||||
|
|
||||||
# Facebook Conversions API
|
# Facebook Conversions API
|
||||||
|
config.facebook_ad_source = 'meta'
|
||||||
config.facebook_pixel_id = "25663975269956141" # ONLY ONE. NO MULTI ENV
|
config.facebook_pixel_id = "25663975269956141" # ONLY ONE. NO MULTI ENV
|
||||||
config.facebook_access_token = "EABAGQTtcGk4BQewKCztlfImT86ZAPsRAm3KDrYWsOFZAdLtJCa7bVOzdnZCnHZBFZBRMFVoSZCQdIpX01xXDM0ZCFmYrkPuAHdLsNBU61c7MZCZBLCFd3Q0qrxiJkeYr3F8FH3p98d0tGKljplhJ8vWBIKAiBXaUCCYk6urZB5qZAIEPsppWZCHOep91xZCtMVqtbGJQfFAZDZD" # ONLY ONE. NO MULTI ENV
|
config.facebook_access_token = "EABAGQTtcGk4BQewKCztlfImT86ZAPsRAm3KDrYWsOFZAdLtJCa7bVOzdnZCnHZBFZBRMFVoSZCQdIpX01xXDM0ZCFmYrkPuAHdLsNBU61c7MZCZBLCFd3Q0qrxiJkeYr3F8FH3p98d0tGKljplhJ8vWBIKAiBXaUCCYk6urZB5qZAIEPsppWZCHOep91xZCtMVqtbGJQfFAZDZD" # ONLY ONE. NO MULTI ENV
|
||||||
config.facebook_conversion_api_tls = true
|
config.facebook_conversion_api_tls = true
|
||||||
|
|
|
||||||
35911
web/dev_failures.txt
35911
web/dev_failures.txt
File diff suppressed because it is too large
Load Diff
|
|
@ -185,6 +185,10 @@ def web_config
|
||||||
'1234567890'
|
'1234567890'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def facebook_ad_source
|
||||||
|
'meta'
|
||||||
|
end
|
||||||
|
|
||||||
def facebook_access_token
|
def facebook_access_token
|
||||||
'dummy_token'
|
'dummy_token'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue