Sha256: a04305e68e73d344b84d3895a843d80d8de9fb2b658353d6821bad956783e0fd

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 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 << request.fullpath

        # 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

15 entries across 15 versions & 1 rubygems

Version Path
bugsnag-1.3.6 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.3.5 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.3.4 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.3.3 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.3.2 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.3.1 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.3.0 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.18 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.17 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.16 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.15 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.14 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.13 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.12 lib/bugsnag/middleware/rails2_request.rb
bugsnag-1.2.11 lib/bugsnag/middleware/rails2_request.rb