Sha256: ecfd18184b98358bcc481ef806d005e93bbfab79a32eaddbd8ea9f76111713a7

Contents?: true

Size: 733 Bytes

Versions: 5

Compression:

Stored size: 733 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(&:length).to_s
        body = new_body
      end
      [status, headers, body]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
airbrake-3.0.9 lib/airbrake/user_informer.rb
airbrake-3.0.8 lib/airbrake/user_informer.rb
airbrake-3.0.7 lib/airbrake/user_informer.rb
airbrake-3.0.6 lib/airbrake/user_informer.rb
airbrake-3.0.5 lib/airbrake/user_informer.rb