module Staccato::SessionTracking

Public Class Methods

included(controller) click to toggle source
# File lib/staccato/session_tracking.rb, line 3
def self.included(controller)
  controller.class_eval do
    alias_method :tracker, :staccato_tracker unless defined?(tracker)
  end
end

Public Instance Methods

append_info_to_payload(payload) click to toggle source

This is called in an `ensure` block by actionpack

errors raised here _may_ be particularly dangerous
Calls superclass method
# File lib/staccato/session_tracking.rb, line 33
def append_info_to_payload(payload)
  super

  payload["staccato.tracker"] = staccato_tracker
  payload["staccato.context"] = hit_context
end
global_context() click to toggle source
# File lib/staccato/session_tracking.rb, line 9
def global_context
  {}
end
hit_context() click to toggle source
# File lib/staccato/session_tracking.rb, line 13
def hit_context
  {}
end
staccato_client_id() click to toggle source

load or set new uuid in session

# File lib/staccato/session_tracking.rb, line 27
def staccato_client_id
  session['staccato.client_id'] ||= Staccato.build_client_id
end
staccato_tracker() click to toggle source
# File lib/staccato/session_tracking.rb, line 17
def staccato_tracker
  @staccato_tracker ||= Staccato.tracker(staccato_tracker_id, staccato_client_id, global_context)
end
staccato_tracker_id() click to toggle source

pull tracker id from config

# File lib/staccato/session_tracking.rb, line 22
def staccato_tracker_id
  Rails.configuration.staccato.tracker_id
end