Sha256: b887493deb0efa7ec03e5bcc521502b6b433d6840051e04e7dd2d7ae493e4eba

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

require 'mixpanel-ruby'

module MixpanelTracker

  def self.track_user(email, opts)
    tracker.people.set(email, opts)
  end

  def self.track_order(order)
   tracker.track(order.email, order.mixpanel_event_message, order.mixpanel_fields.merge(order.mixpanel_personal_fields))
  end

  private
  def self.tracker
    validate_connection_token
    @tracker ||= Mixpanel::Tracker.new(connection_token)
  end

  def self.connection_token
    Spree::Mixpanel::Config[:connection_token]
  end

  def self.validate_connection_token
    raise MixpanelApiError, "Mixpanel connection token is required" if !connection_token.present?
  end

  class MixpanelApiError < StandardError; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_mixpanel-2.1.8 lib/spree_mixpanel/tracker/mixpanel_tracker.rb