Sha256: 3643f8b25c23452f589595483732f24503c008d73064b243c8b434e9f8b9341e
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'logger' require 'rack/request' require 'staccato' require 'staccato/rack/version' require 'staccato/rack/faraday_http_adapter' require 'staccato/rack/page_view' module Staccato module Rack # middleware class Middleware # page view wrapper attr_accessor :last_hit def initialize(app, tracking_id, options = {}) @app = app @tracking_id = tracking_id @logger = options[:logger] @default_tracker = Staccato.tracker(tracking_id) do |c| c.adapter = FaradayHttpAdaper.new(@logger) unless tracking_id == nil end end def call(env) env['staccato.pageview'] = PageView.new.tap { |p| p.logger = @logger } @last_hit = nil status, headers, body = @app.call(env) if (200..299).include?(status.to_i) @last_hit = env['staccato.pageview'].track!(@default_tracker, @tracking_id, ::Rack::Request.new(env)) end # return result [status, headers, body] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
staccato-rack-0.4.2 | lib/staccato/rack.rb |