class ExceptionNotifier::SquashNotifier::SquashRailsNotifier
Public Instance Methods
call(exception, data={})
click to toggle source
Calls superclass method
ExceptionNotifier::SquashNotifier::SquashRubyNotifier#call
# File lib/exception_notifier/squash_notifier/rails.rb, line 29 def call(exception, data={}) super(exception, munge_env(data)) end
Protected Instance Methods
environment_name()
click to toggle source
# File lib/exception_notifier/squash_notifier/rails.rb, line 95 def environment_name return ::Rails.env.to_s if defined?(::Rails) ENV['RAILS_ENV'] || ENV['RACK_ENV'] end
munge_env(data)
click to toggle source
# File lib/exception_notifier/squash_notifier/rails.rb, line 35 def munge_env(data) return data unless data.has_key?(:env) env = data.delete(:env) request = ActionDispatch::Request.new(env) whitelist_env = Squash::Ruby.configuration(:filter_env_vars) parameter_filter = ActionDispatch::Http::ParameterFilter.new(env["action_dispatch.parameter_filter"]) filtered_env = whitelist_env.call(request.try(:filtered_env) || parameter_filter.filter(env)) data.merge(occurence_data( request: request, session: parameter_filter.filter(request.session.to_hash), # cookies: env['rack.request.cookie_hash'], rack_env: filtered_env )) end
occurence_data(request: nil, session: nil, rack_env: {})
click to toggle source
# File lib/exception_notifier/squash_notifier/rails.rb, line 54 def occurence_data(request: nil, session: nil, rack_env: {}) fail "No 'request' supplied" unless request #TODO: Remove when done: # flash_key = defined?(ActionDispatch) ? ActionDispatch::Flash::KEY : 'flash' # raw_session_id = request.session['session_id'] || (request.env["rack.session.options"] and request.env["rack.session.options"][:id]) # session_id = request.ssl? ? "[FILTERED]" : raw_session_id.inspect PP.pp session, session_s="" #NB: If you update this hash, make sure to update TOP_LEVEL_USER_DATA in # squash_ruby/rails.rb { :environment => environment_name, :root => root_path, # Squash Server recreates the URL from these: :request_method => request.request_method.to_s, :schema => request.protocol.sub('://', ''), :host => request.host, :port => request.port, :path => request.path, :query => request.query_string, :headers => request_headers(rack_env), # :controller ## Rails Controller # :action ## Rails Action :params => request.filtered_parameters, :session => session, # :flash => session[flash_key], # :cookies => cookies, # User Data: :host_ip => request.remote_ip, :host_name => Socket.gethostname, :"rack.env" => rack_env.to_hash, :"session.to_s" => session_s } end
request_headers(env)
click to toggle source
Extract any rack key/value pairs where the key begins with HTTP_*
# File lib/exception_notifier/squash_notifier/rails.rb, line 101 def request_headers(env) env.select { |key, _| key[0, 5] == 'HTTP_' } end
root_path()
click to toggle source
# File lib/exception_notifier/squash_notifier/rails.rb, line 105 def root_path defined?(::Rails) ? ::Rails.root.to_s : ENV['RAILS_ROOT'] end