Sha256: 9e8cd90e14344d8eddc567d0e616b0072e81da658f7946fc151d228e84768228

Contents?: true

Size: 1.6 KB

Versions: 19

Compression:

Stored size: 1.6 KB

Contents

module Bugsnag::Middleware
  class Rails2Request
    def initialize(bugsnag)
      @bugsnag = bugsnag
    end
      
    def call(notification)
      if notification.request_data[:rails2_request]
        request = notification.request_data[:rails2_request]
        params = request.parameters || {}
        session_data = request.session.respond_to?(:to_hash) ? request.session.to_hash : request.session.data

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

        # Set a sensible default for user_id
        notification.user_id = request.remote_ip if request.respond_to?(:remote_ip)

        # Build the clean url
        url = "#{request.protocol}#{request.host}"
        url << ":#{request.port}" unless [80, 443].include?(request.port)
        url << Bugsnag::Helpers.cleanup_url(request.fullpath, notification.configuration.params_filters)

        # Add a request tab
        notification.add_tab(:request, {
          :url => url,
          :params => params.to_hash,
          :controller => params[:controller],
          :action => params[:action]
        })

        # Add an environment tab
        notification.add_tab(:environment, request.env) if request.env

        # Add a session tab
        notification.add_tab(:session, session_data) if session_data

        # Add a cookies tab
        notification.add_tab(:cookies, request.cookies) if request.cookies

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

      @bugsnag.call(notification)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bugsnag-2.4.1 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.4.0 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.3.0 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.2.2 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.2.1 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.2.0 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.1.0 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.0.3 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.0.2 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.0.1 lib/bugsnag/middleware/rails2_request.rb
bugsnag-2.0.0 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.8 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.7 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.6 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.5 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.4 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.3 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.2 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.8.1 lib/bugsnag/middleware/rails2_request.rb