Sha256: 8f1d68da9b787f450dcbcd7fa3fb2ff5775bb922406468a385c3f94269af25ca

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

require 'rails'
require 'yaml'

require 'honeybadger/util/sanitizer'
require 'honeybadger/util/request_payload'
require 'honeybadger/rack/error_notifier'
require 'honeybadger/rack/user_informer'
require 'honeybadger/rack/user_feedback'

module Honeybadger
  module Init
    module Rails
      class Railtie < ::Rails::Railtie
        rake_tasks do
          load 'honeybadger/tasks.rb'
        end

        initializer 'honeybadger.install' do
          config = Config.new(local_config)
          if Honeybadger.start(config)
            if config.feature?(:notices) && config[:'exceptions.enabled']
              ::Rails.application.config.middleware.tap do |middleware|
                middleware.insert(0, Honeybadger::Rack::ErrorNotifier, config)
                middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer, config) if config[:'user_informer.enabled']
                middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback, config) if config[:'feedback.enabled']
              end
            end
          end
        end

        private

        def local_config
          {
            :root           => ::Rails.root.to_s,
            :env            => ::Rails.env,
            :'config.path'  => ::Rails.root.join('config', 'honeybadger.yml'),
            :logger         => Logging::FormattedLogger.new(::Rails.logger),
            :framework      => :rails
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
honeybadger-2.7.2 lib/honeybadger/init/rails.rb
honeybadger-2.7.1 lib/honeybadger/init/rails.rb
honeybadger-2.7.0 lib/honeybadger/init/rails.rb