Sha256: fbb6437ca29afa0213c029243673d52cc9e452adfbb596e8f3b5f6f9ce6d3dce

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

class Rack::Tracker::GoSquared < Rack::Tracker::Handler
  class VisitorName < OpenStruct
    def write
      ['set', 'visitorName', self.name].to_json.gsub(/\[|\]/, '')
    end
  end

  class VisitorInfo < OpenStruct
    def write
      ['set', 'visitor', to_h].to_json.gsub(/\[|\]/, '')
    end
  end

  def tracker
    options[:tracker]
  end

  def trackers
    options[:trackers]
  end

  def visitor_name
    events.select{|e| e.kind_of?(VisitorName) }.first
  end

  def visitor_info
    events.select{|e| e.kind_of?(VisitorInfo) }.first
  end

  def self.track(name, *event)
    { name.to_s => [event.last.merge('class_name' => event.first.to_s.classify)] }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-tracker-1.4.0 lib/rack/tracker/go_squared/go_squared.rb