Class: Shrew::PageView

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/shrew/page_view.rb

Class Method Summary collapse

Class Method Details

.create_from_payload(payload) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/shrew/page_view.rb', line 6

def self.create_from_payload(payload)
  attributes = payload.slice(:user_id, :controller, :status, :view_runtime,
                             :db_runtime, :sent_time, :js_return_time,
                             :js_tracking_id, :action, :path, :start_time,
                             :duration)
                      .merge(sent_time: milliseconds_since_epoch)
  begin
    create(attributes)
  rescue Exception
    logger.error 'Shrew could not log the page view, please verify the database is ready'
  end
end