lib/staccato/rack.rb in staccato-rack-0.1.0 vs lib/staccato/rack.rb in staccato-rack-0.1.1
- old
+ new
@@ -4,11 +4,10 @@
module Staccato
module Rack
# middleware
class Middleware
- attr_reader :tracker
attr_accessor :last_hit
def initialize(app, tracking_id)
@app = app
@tracker = Staccato.tracker(tracking_id)
@@ -19,21 +18,21 @@
load_staccato_into_env(env)
# @last_hit = nil
status, headers, body = @app.call(env)
- env['staccato.pageview'].track! if (200..299).include?(status.to_i)
+ env['staccato.tracker'].track(env['staccato.pageview'].params) if (200..299).include?(status.to_i)
# return result
[status, headers, body]
end
private
def load_staccato_into_env(env)
request = ::Rack::Request.new(env)
- env['staccato.tracker'] = tracker
- env['staccato.pageview'] = Staccato::Pageview.new(tracker,
+ env['staccato.tracker'] = @tracker
+ env['staccato.pageview'] = Staccato::Pageview.new(@tracker,
path: request.fullpath,
hostname: request.host,
user_agent: request.env['HTTP_USER_AGENT'],
user_ip: request.ip)
end