Sha256: 330a3c3f0b942c2f737e2914fadeb806436b3f63f1dbd10287e17a31c44e6c17

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true
require_relative 'notification'

module Noise
  # Configures Bugsnag notification with our request-specific information.
  #
  class BugsnagMiddleware
    def initialize(bugsnag)
      @bugsnag = bugsnag
    end

    # @param report [Bugsnag::Report]
    #
    def call(report)
      env = report.request_data.fetch(:rack_env, {})
      # Bugsnag::Notification unwraps stacked exceptions,
      # top-level exception (which we need) is the first.
      error = report.exceptions.first
      notification = Notification.new(error, env)

      report.severity = notification.severity
      report.user = notification.user_info

      notification.to_hash.each_pair do |tab_name, value|
        report.add_tab(tab_name, value)
      end

      @bugsnag.call(report)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
white_noise-1.1.2 lib/noise/bugsnag_middleware.rb
white_noise-1.1.1 lib/noise/bugsnag_middleware.rb
white_noise-1.1.0 lib/noise/bugsnag_middleware.rb
white_noise-1.0.1 lib/noise/bugsnag_middleware.rb
white_noise-1.0.0 lib/noise/bugsnag_middleware.rb