class AbPanel::Mixpanel::Tracker

Public Class Methods

new(options = {}) click to toggle source
# File lib/ab_panel/mixpanel.rb, line 6
def initialize(options = {})
  return if !should_track?

  @tracker = ::Mixpanel::Tracker.new Config.token, ab_panel_options.merge(options)
end

Public Instance Methods

ab_panel_options() click to toggle source
# File lib/ab_panel/mixpanel.rb, line 12
def ab_panel_options
  opts = {
    env:     AbPanel.env,
    persist: true
  }

  AbPanel.funnels.each do |funnel|
    opts["funnel_#{funnel}"] = true
  end

  opts
end
identify(distinct_id) click to toggle source
# File lib/ab_panel/mixpanel.rb, line 31
def identify(distinct_id)
  return if !should_track?

  @tracker.append_identify distinct_id
end
track(event_name, properties) click to toggle source
# File lib/ab_panel/mixpanel.rb, line 25
def track(event_name, properties)
  return if !should_track?

  @tracker.append_track event_name, properties
end

Private Instance Methods

should_track?() click to toggle source
# File lib/ab_panel/mixpanel.rb, line 39
def should_track?
  @should_track ||= Config.environments.include?(Rails.env)
end