Class: Rakwik::Tracker
- Inherits:
-
Object
- Object
- Rakwik::Tracker
- Includes:
- Rack::Response::Helpers
- Defined in:
- lib/rakwik/tracker.rb
Constant Summary collapse
- DEFAULT =
{ :track_404 => true }
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Tracker
constructor
A new instance of Tracker.
Constructor Details
#initialize(app, options = {}) ⇒ Tracker
Returns a new instance of Tracker.
15 16 17 18 19 |
# File 'lib/rakwik/tracker.rb', line 15 def initialize(app, = {}) @app, @options = app, DEFAULT.merge() missing = [:piwik_url, :site_id, :token_auth].detect{ |e| @options[e].nil? } raise "Missing config value: :#{missing}" if missing end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/rakwik/tracker.rb', line 9 def status @status end |
Class Method Details
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rakwik/tracker.rb', line 21 def call(env) start = Time.now @status, @headers, @body = @app.call(env) env['rakwik.duration'] = (Time.now - start)*1000 track Rack::Request.new(env) if track? [@status, @headers, @body] end |