Class: WhenAUser::Pageviews
- Inherits:
-
Object
- Object
- WhenAUser::Pageviews
- Includes:
- Helpers
- Defined in:
- lib/whenauser/pageviews.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Pageviews
constructor
A new instance of Pageviews.
Methods included from Helpers
#actor_for_exception, #clean_backtrace, #from_crawler
Constructor Details
#initialize(app, options = {}) ⇒ Pageviews
Returns a new instance of Pageviews.
11 12 13 14 15 16 17 |
# File 'lib/whenauser/pageviews.rb', line 11 def initialize(app, ={}) @app, @options = app, @options[:ignore_crawlers] ||= WhenAUser.default_ignored_crawlers @options[:ignore_if] ||= lambda { |env| false } @options[:ignore_if_controller] ||= 'false' @options[:custom_data] ||= lambda { |env| {} } end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/whenauser/pageviews.rb', line 19 def call(env) before = Time.now status, headers, response = @app.call(env) [status, headers, response] rescue Exception => e status = 500 raise e ensure after = Time.now WhenAUser.send_event event(env, status, after - before) unless should_be_ignored(env) end |