Sha256: b23c4a92e61ce48c226b5ff33a28fd668b7ef672baaab49fa41ca602a84633e8

Contents?: true

Size: 877 Bytes

Versions: 5

Compression:

Stored size: 877 Bytes

Contents

require 'mixpanel'

module AbPanel
  module Mixpanel
    class Tracker < ::Mixpanel::Tracker
      def initialize(options={})
        @tracker = ::Mixpanel::Tracker.new Config.token, ab_panel_options.merge(options)
      end

      def ab_panel_options
        {
          api_key: Config.api_key,
          env:     AbPanel.env,
          persist: true
        }
      end

      def track(event_name, properties)
        @tracker.append_track event_name, properties
      end

      def identify(distinct_id)
        @tracker.append_identify distinct_id
      end
    end

    class Config
      def self.api_key
        config['api_key']
      end

      def self.token
        config['token']
      end

      def self.config
        @settings ||= YAML.load(
          ERB.new(File.read(File.join(Rails.root, 'config', 'mixpanel.yml'))).result)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ab_panel-0.0.7 lib/ab_panel/mixpanel.rb
ab_panel-0.0.6 lib/ab_panel/mixpanel.rb
ab_panel-0.0.5 lib/ab_panel/mixpanel.rb
ab_panel-0.0.4 lib/ab_panel/mixpanel.rb
ab_panel-0.0.3 lib/ab_panel/mixpanel.rb