Sha256: b26799cf4fc617c6359fa2340a75116985ad75a4c186aabee965ecf7074d8451

Contents?: true

Size: 676 Bytes

Versions: 7

Compression:

Stored size: 676 Bytes

Contents

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

    def replacement(with)
      @replacement ||= 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 = []
        body.each do |chunk|
          new_body << chunk.gsub("<!-- AIRBRAKE ERROR -->", replacement(env['airbrake.error_id']))
        end
        headers['Content-Length'] = new_body.sum(&:length).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.0.4 lib/airbrake/user_informer.rb
airbrake-3.0.3 lib/airbrake/user_informer.rb
airbrake-3.0.2 lib/airbrake/user_informer.rb
airbrake-3.0.1 lib/airbrake/user_informer.rb
airbrake-3.0 lib/airbrake/user_informer.rb
airbrake-3.0.rc2 lib/airbrake/user_informer.rb
airbrake-3.0.rc1 lib/airbrake/user_informer.rb