Sha256: c44eb3bb8b7a89b2dfc0895d16591e0e583a1119300eb6977be87123aa66ff9b

Contents?: true

Size: 735 Bytes

Versions: 7

Compression:

Stored size: 735 Bytes

Contents

module Airbrake
  class UserInformer
    def initialize(app)
      @app = app
    end

    def replacement(with)
      Airbrake.configuration.user_information.gsub(/\{\{\s*error_id\s*\}\}/, with.to_s)
    end

    def call(env)
      status, headers, body = @app.call(env)
      if env['airbrake.error_id'] && Airbrake.configuration.user_information
        new_body = []
        replace  = replacement(env['airbrake.error_id'])
        body.each do |chunk|
          new_body << chunk.gsub("<!-- AIRBRAKE ERROR -->", replace)
        end
        body.close if body.respond_to?(:close)
        headers['Content-Length'] = new_body.sum(&:bytesize).to_s
        body = new_body
      end
      [status, headers, body]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
airbrake-3.1.6 lib/airbrake/user_informer.rb
airbrake-3.1.5 lib/airbrake/user_informer.rb
airbrake-3.1.4 lib/airbrake/user_informer.rb
airbrake-3.1.3 lib/airbrake/user_informer.rb
airbrake-3.1.2 lib/airbrake/user_informer.rb
airbrake-3.1.1 lib/airbrake/user_informer.rb
airbrake-3.1.0 lib/airbrake/user_informer.rb