Sha256: 86e373fe4ab6221e6c4224e3ee1c42a4d7003665d6c35ecb4c321a7bdc6b92af

Contents?: true

Size: 1.27 KB

Versions: 10

Compression:

Stored size: 1.27 KB

Contents

module Bugsnag::Middleware
  ##
  # Extracts and attaches rails and rack environment data to an error report
  class Rails3Request
    SPOOF = "[SPOOF]".freeze

    def initialize(bugsnag)
      @bugsnag = bugsnag
    end

    def call(report)
      if report.request_data[:rack_env]
        env = report.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
          report.context = "#{params[:controller]}##{params[:action]}"

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

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

        report.user["id"] = client_ip

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

      @bugsnag.call(report)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bugsnag-6.11.1 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.11.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.10.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.9.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.8.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.7.3 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.7.2 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.7.1 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.7.0 lib/bugsnag/middleware/rails3_request.rb
bugsnag-6.6.4 lib/bugsnag/middleware/rails3_request.rb