app/controllers/application_controller.rb
# Exports logger configuration and data. Note that you have to explicitly specify 'enable_js_logger' as before_filter
# for every action which should have logging enabled.
Exports logger configuration and data. Note that you have to explicitly specify 'enable_js_logger' as before_filter
for every action which should have logging enabled.
Exports logger configuration and data . Note that you have to explicitly specify ' enable_js_logger ' as before_filter for every action which should have logging enabled .
def enable_js_logger
    unless params[:logging].nil?
      session[:logging] = params[:logging] == "true"
    end
    unless session[:logging]
      gon.loggerConfig = nil
      return
    end
    data = {
        application: ENV['LOGGER_APPLICATION_NAME'],
        session:     session[:session_id],
        username:    current_user ? "#{session[:portal_user_id]}@#{session[:portal_domain]}" : 'anonymous',
        url:         request.original_url
    }
    if @run
      data[:run_key] = @run.key
      data[:run_remote_id] = @run.remote_id
      data[:run_remote_endpoint] = @run.remote_endpoint
    end
    if @sequence
      data[:activity]      = "sequence: #{@sequence.id}"
      data[:sequence_id]   = @sequence.id
      data[:sequence_name] = @sequence.name
    end
    if @activity
      data[:activity]    ||= "activity: #{@activity.id}"
      data[:activity_id]   = @activity.id
      data[:activity_name] = @activity.name
    end
    if @page
      data[:page_id] = @page.id
    end
    gon.loggerConfig = {
      server: ENV['LOGGER_URI'],
      action: "#{controller_name}##{action_name}",
      data:   data
    }
  end
def enable_js_logger unless params [ :logging ] . nil? session [ :logging ] = params [ :logging ] == "true" end unless session [ :logging ] gon . loggerConfig = nil return end data = { application : ENV [ 'LOGGER_APPLICATION_NAME' ] , session : session [ :session_id ] , username : current_user ? "#{session[:portal_user_id]}@#{session[:portal_domain]}" : 'anonymous' , url : request . original_url } if @run data [ :run_key ] = @run . key data [ :run_remote_id ] = @run . remote_id data [ :run_remote_endpoint ] = @run . remote_endpoint end if @sequence data [ :activity ] = "sequence: #{@sequence.id}" data [ :sequence_id ] = @sequence . id data [ :sequence_name ] = @sequence . name end if @activity data [ :activity ] ||= "activity: #{@activity.id}" data [ :activity_id ] = @activity . id data [ :activity_name ] = @activity . name end if @page data [ :page_id ] = @page . id end gon . loggerConfig = { server : ENV [ 'LOGGER_URI' ] , action : "#{controller_name}##{action_name}" , data : data } end
Exports logger configuration and data.
Exports logger configuration and data .
# Update session when logging param is provided (usually as GET param). # Activity field is a bit confusing name, but let's assume that it indicates which activity *or* sequence has # been started by user. # Set activity name only if it hasn't been already set. Note that when both @activity and @sequence are available, # "sequence: <ID>" will be used (as user has started sequence and activity is only part of it). # Export to gon namespace, available in JavaScript under window.gon (see: https://github.com/gazay/gon).