Sha256: e2125aef697a9d29473fe5e7411e117b23fab62f4632564a397366c83bf9d1a8

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

Rollbar.plugins.define('active_job') do
  dependency { !configuration.disable_monkey_patch }
  dependency { !configuration.disable_action_mailer_monkey_patch }

  execute do
    module Rollbar
      # Report any uncaught errors in a job to Rollbar and reraise
      module ActiveJob
        def self.included(base)
          base.send :rescue_from, Exception do |exception|
            args = if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments?
                     arguments.map(&Rollbar::Scrubbers.method(:scrub_value))
                   else
                     arguments
                   end

            job_data = {
              :job => self.class.name,
              :use_exception_level_filters => true,
              :arguments => args
            }

            # job_id isn't present when this is a mailer class.
            job_data[:job_id] = job_id if defined?(job_id)

            Rollbar.error(exception, job_data)
            raise exception
          end
        end
      end
    end

    if defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
      ActiveSupport.on_load(:action_mailer) do
        if defined?(ActionMailer::MailDeliveryJob) # Rails >= 6.0
          ActionMailer::Base.send(:include, Rollbar::ActiveJob)
        elsif defined?(ActionMailer::DeliveryJob) # Rails < 6.0
          ActionMailer::DeliveryJob.send(:include,
                                         Rollbar::ActiveJob)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rollbar-3.5.0 lib/rollbar/plugins/active_job.rb