more changes for event rework
This commit is contained in:
parent
eb298d6859
commit
73d2a7a020
|
|
@ -547,13 +547,11 @@ module JamRuby
|
|||
begin
|
||||
case field_name.to_s
|
||||
when 'first_ran_client_at'
|
||||
CapiTransmitter.send_event('OpenClient', self)
|
||||
# StartTrial: When user opens the app
|
||||
CapiTransmitter.send_event('StartTrial', self, { value: '0.00', currency: 'USD', predicted_ltv: '0.00' })
|
||||
when 'first_certified_gear_at'
|
||||
CapiTransmitter.send_event('CompleteGearWizard', self)
|
||||
when 'first_music_session_at'
|
||||
CapiTransmitter.send_event('FirstMusicSession', self)
|
||||
when 'first_real_music_session_at'
|
||||
CapiTransmitter.send_event('RealMusicSession', self)
|
||||
# CustomizeProduct: When user finishes Gear Wizard
|
||||
CapiTransmitter.send_event('CustomizeProduct', self)
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error("Error sending CAPI event: #{e.message}")
|
||||
|
|
@ -1886,6 +1884,11 @@ module JamRuby
|
|||
if user.errors.any?
|
||||
raise ActiveRecord::Rollback
|
||||
else
|
||||
# CAPI Hook: CompleteRegistration
|
||||
if user.facebook_click_id.present?
|
||||
CapiTransmitter.send_event('CompleteRegistration', user)
|
||||
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 affiliate_partner && affiliate_partner.partner_user.nil?
|
||||
affiliate_partner.partner_user = user
|
||||
|
|
|
|||
|
|
@ -166,6 +166,29 @@ class ApiRecurlyController < ApiController
|
|||
def create_subscription
|
||||
begin
|
||||
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
|
||||
CapiTransmitter.send_event('Subscribe', current_user, { value: monthly_cost.to_s, currency: 'USD', predicted_ltv: ltv.to_s })
|
||||
end
|
||||
rescue => e
|
||||
puts "Error sending CAPI Subscribe event #{current_user.email}, #{e.message}"
|
||||
end
|
||||
|
||||
subscription = Recurly::Subscription.find(current_user.recurly_subscription_id)
|
||||
render :json => subscription.to_json
|
||||
rescue RecurlyClientError => x
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ namespace :capi do
|
|||
# Mock user
|
||||
user = User.last
|
||||
if user
|
||||
puts "Sending test event 'TestEvent' for User ID: #{user.id}"
|
||||
CapiTransmitter.send_event('TestEvent', user)
|
||||
puts "Sending test event 'StartTrial' for User ID: #{user.id}"
|
||||
CapiTransmitter.send_event('StartTrial', user, { value: '0.00', currency: 'USD', predicted_ltv: '0.00' })
|
||||
puts "Check Rails log for output."
|
||||
else
|
||||
puts "No user found in database."
|
||||
|
|
|
|||
Loading…
Reference in New Issue