Sha256: b729a92766eea2f9596af287469140ed999975e41c7207200026e5e901940301
Contents?: true
Size: 1.32 KB
Versions: 11
Compression:
Stored size: 1.32 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, :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
11 entries across 11 versions & 1 rubygems