lib/sentry/rails/railtie.rb in sentry-rails-4.3.2 vs lib/sentry/rails/railtie.rb in sentry-rails-4.3.3.pre.beta.0

- old
+ new

@@ -1,13 +1,8 @@ -require "rails" require "sentry/rails/capture_exceptions" require "sentry/rails/rescued_exception_interceptor" require "sentry/rails/backtrace_cleaner" -require "sentry/rails/controller_methods" -require "sentry/rails/controller_transaction" -require "sentry/rails/overrides/streaming_reporter" -require "sentry/rails/overrides/file_handler" module Sentry class Railtie < ::Rails::Railtie # middlewares can't be injected after initialize initializer "sentry.use_rack_middleware" do |app| @@ -21,15 +16,15 @@ next unless Sentry.initialized? configure_project_root configure_sentry_logger configure_trusted_proxies - extend_controller_methods + extend_controller_methods if defined?(ActionController) extend_active_job if defined?(ActiveJob) patch_background_worker if defined?(ActiveRecord) - override_streaming_reporter - override_file_handler if app.config.public_file_server.enabled + override_streaming_reporter if defined?(ActionView) + override_file_handler if defined?(ActionDispatch) && app.config.public_file_server.enabled setup_backtrace_cleanup_callback inject_breadcrumbs_logger activate_tracing end @@ -49,10 +44,14 @@ require "sentry/rails/active_job" ActiveJob::Base.send(:prepend, Sentry::Rails::ActiveJobExtensions) end def extend_controller_methods + require "sentry/rails/controller_methods" + require "sentry/rails/controller_transaction" + require "sentry/rails/overrides/streaming_reporter" + ActiveSupport.on_load :action_controller do include Sentry::Rails::ControllerMethods include Sentry::Rails::ControllerTransaction ActionController::Live.send(:prepend, Sentry::Rails::Overrides::StreamingReporter) end @@ -76,15 +75,19 @@ backtrace_cleaner.clean(backtrace) end end def override_streaming_reporter + require "sentry/rails/overrides/streaming_reporter" + ActiveSupport.on_load :action_view do ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter) end end def override_file_handler + require "sentry/rails/overrides/file_handler" + ActiveSupport.on_load :action_controller do ActionDispatch::FileHandler.send(:prepend, Sentry::Rails::Overrides::FileHandler) end end