Sha256: 1755d6bc9e0ad91e4cb300a6f5cc4af8a126a5ca121c0f40e86ca58be1378aba

Contents?: true

Size: 878 Bytes

Versions: 21

Compression:

Stored size: 878 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)
      dup._call(env)
    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.inject(0){|sum, x| sum + x.bytesize}.to_s
        body = new_body
      end

      [status, headers, body]

    ensure
      body.close if body && body.respond_to?(:close) && $!
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
airbrakeV4rails5-4.3.8 lib/airbrake/user_informer.rb
airbrake-4.3.8 lib/airbrake/user_informer.rb
airbrake-4.3.7 lib/airbrake/user_informer.rb
airbrake-4.3.6 lib/airbrake/user_informer.rb
airbrake-4.3.5 lib/airbrake/user_informer.rb
airbrake-4.3.4 lib/airbrake/user_informer.rb
airbrake-4.3.3 lib/airbrake/user_informer.rb
airbrake-4.3.2 lib/airbrake/user_informer.rb
airbrake-4.3.1 lib/airbrake/user_informer.rb
airbrake-4.3.0 lib/airbrake/user_informer.rb
airbrake-4.2.1 lib/airbrake/user_informer.rb
airbrake-4.2.0 lib/airbrake/user_informer.rb
airbrake-4.1.0 lib/airbrake/user_informer.rb
airbrake-4.0.0 lib/airbrake/user_informer.rb
airbrake-3.2.1 lib/airbrake/user_informer.rb
airbrake-3.2.0 lib/airbrake/user_informer.rb
airbrake-3.1.17 lib/airbrake/user_informer.rb
airbrake-3.1.16 lib/airbrake/user_informer.rb
airbrake-3.1.15 lib/airbrake/user_informer.rb
airbrake-3.1.14 lib/airbrake/user_informer.rb