module ExpressAnalytics::DefaultLogger::InstanceMethods
Public Instance Methods
action_for_log()
click to toggle source
# File lib/express_analytics/default_logger.rb, line 52 def action_for_log # ExpressAnalytics::LogEntriesController#show becomes # express_analytics/log_entries_controller#show # show log entry is_plural = %w(list index).include?(request.params[:action]) object_name = self.class.to_s.demodulize.underscore.titleize object_name.gsub!(/ Controller/, '') object_name = is_plural ? object_name : object_name.singularize verb = is_plural ? 'view' : request.params[:action] "#{verb} #{object_name}" end
create_log_entry!()
click to toggle source
# File lib/express_analytics/default_logger.rb, line 25 def create_log_entry! geo_data = begin ExpressGeoip.lookup(request.remote_ip) rescue => e {} end entity = entity_for_log entry_data = { action: action_for_log, username: current_user.try(:email), ip_address: request.ip, user_agent: request.user_agent, entity_type: entity.try(:class).try(:to_s), entity_id: entity.try(:id), notes: notes_for_log } if !!request.user_agent.match(/Pingdom/) # do nothing else ExpressAnalytics::LogEntry.create(entry_data.merge(geo_data)) end end
entity_for_log()
click to toggle source
# File lib/express_analytics/default_logger.rb, line 65 def entity_for_log self.respond_to?(:resource) ? resource : nil end
notes_for_log()
click to toggle source
# File lib/express_analytics/default_logger.rb, line 69 def notes_for_log request.path # override to add notes end