Class: AnalyticsEventsSender::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_events_sender/dispatcher.rb

Constant Summary collapse

CANCELATION_EVENT =
'CANCEL'.freeze
BUY_EVENT =
'INITIAL_BUY'.freeze
RENEWAL_EVENT =
'RENEWAL'.freeze
INTERACTIVE_RENEWAL_EVENT =
'INTERACTIVE_RENEWAL'.freeze
CHANGE_PLAN_EVENT =
'DID_CHANGE_RENEWAL_PREF'.freeze
DEFAULT_PLATFORMS =
%w[amplitude appmetrica appsflyer mixpanel].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, user, analytics_platforms = DEFAULT_PLATFORMS) ⇒ Dispatcher

Returns a new instance of Dispatcher.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/analytics_events_sender/dispatcher.rb', line 14

def initialize(params, user, analytics_platforms = DEFAULT_PLATFORMS)
  @user = user
  @analytics_platforms = analytics_platforms
  @cancelation_date = params.dig(:cancellation_date)
  @event_name = params.dig(:notification_type)
  @trial = params.dig(:latest_receipt_info, :is_trial_period)
  @purchase_date = params.dig(:latest_receipt_info, :original_purchase_date).to_datetime
  @product_id = params.dig(:auto_renew_product_id)
  @period = user.receipt['latest_receipt_info'].count
  @new_product_id = params.dig(:latest_receipt_info)
end

Class Method Details

.call(user, params, analytics_platforms) ⇒ Object



10
11
12
# File 'lib/analytics_events_sender/dispatcher.rb', line 10

def self.call(user, params, analytics_platforms)
  new(user, params, analytics_platforms).call
end