module Mixpal::Integration

Public Class Methods

mixpanel_identity(object_method, attribute_method) click to toggle source
# File lib/mixpal/integration.rb, line 14
def self.mixpanel_identity(object_method, attribute_method)
  self.mixpanel_identity_data = {
    object_method: object_method,
    attribute_method: attribute_method
  }
end

Public Instance Methods

mixpanel() click to toggle source
# File lib/mixpal/integration.rb, line 22
def mixpanel
  @mixpanel ||= begin
    identity = if (data = self.class.mixpanel_identity_data)
                 send(data[:object_method]).try(data[:attribute_method])
               end

    Mixpal::Tracker.new(identity: identity).tap { |t| t.restore!(session) }
  end
end

Private Instance Methods

store_mixpanel_if_redirecting() click to toggle source
# File lib/mixpal/integration.rb, line 34
def store_mixpanel_if_redirecting
  mixpanel.store!(session) if (300..399).cover?(status)
end