Sha256: 4a29fc681cb87fca758fb0b935e092a0e894a04587b0a6b1fc37161fb8afe7f8

Contents?: true

Size: 789 Bytes

Versions: 10

Compression:

Stored size: 789 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 render
    Tilt.new( File.join( File.dirname(__FILE__), 'template', 'go_squared.erb') ).render(self)
  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

10 entries across 10 versions & 1 rubygems

Version Path
rack-tracker-1.3.1 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-1.3.0 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-1.2.0 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-1.1.0 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-1.0.2 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-1.0.1 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-1.0.0 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-0.4.2 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-0.4.1 lib/rack/tracker/go_squared/go_squared.rb
rack-tracker-0.4.0 lib/rack/tracker/go_squared/go_squared.rb