Sha256: c0c91c21a7723c0232dc977019cb30094e6d715725c40a608e96aad922f8d398

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Bugsnag::Middleware
  class Rails3Request
    SPOOF = "[SPOOF]".freeze

    def initialize(bugsnag)
      @bugsnag = bugsnag
    end

    def call(notification)
      if notification.request_data[:rack_env]
        env = notification.request_data[:rack_env]
        params = env["action_dispatch.request.parameters"]
        client_ip = env["action_dispatch.remote_ip"].to_s rescue SPOOF

        if params
          # Set the context
          notification.context = "#{params[:controller]}##{params[:action]}"

          # Augment the request tab
          notification.add_tab(:request, {
            :railsAction => "#{params[:controller]}##{params[:action]}",
            :params => params
          })
        end

        # Use action_dispatch.remote_ip for IP address fields and send request id
        notification.add_tab(:request, {
          :clientIp => client_ip,
          :requestId => env["action_dispatch.request_id"]
        })

        notification.user_id = client_ip

        # Add the rails version
        if notification.configuration.send_environment
          notification.add_tab(:environment, {
            :railsVersion => Rails::VERSION::STRING
          })
        end
      end

      @bugsnag.call(notification)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bugsnag-5.5.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-5.4.1 lib/bugsnag/middleware/rails3_request.rb
bugsnag-5.4.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-5.3.3 lib/bugsnag/middleware/rails3_request.rb