Sha256: 150438826cbe2268ac01e8598478cadcbd3e6e9d85968b6d766b0eea93931d67
Contents?: true
Size: 1.37 KB
Versions: 16
Compression:
Stored size: 1.37 KB
Contents
module Bugsnag::Middleware class RackRequest def initialize(bugsnag) @bugsnag = bugsnag end def call(notification) if notification.request_data[:rack_env] env = notification.request_data[:rack_env] request = ::Rack::Request.new(env) params = request.params session = env["rack.session"] # Set the context notification.context = "#{request.request_method} #{request.path}" # Set a sensible default for user_id notification.user_id = request.ip # Build the clean url (hide the port if it is obvious) url = "#{request.scheme}://#{request.host}" url << ":#{request.port}" unless [80, 443].include?(request.port) url << request.fullpath # Add a request tab notification.add_tab(:request, { :url => url, :httpMethod => request.request_method, :params => params.to_hash, :userAgent => request.user_agent, :clientIp => request.ip }) # Add an environment tab notification.add_tab(:environment, env) # Add a session tab notification.add_tab(:session, session) if session # Add a cookies tab cookies = request.cookies notification.add_tab(:cookies, cookies) if cookies end @bugsnag.call(notification) end end end
Version data entries
16 entries across 16 versions & 1 rubygems