Skip to content

Instrumentation support #283

@kushniryb

Description

@kushniryb

Evening folks, hope you are well!

Would you be interested in adding instrumentation support to premailer-rails?

Recently I've been working on a small feature that relies on mail interception. I'm using premailer-rails to generate text parts for emails. I've had a hard time figuring out why emails intercepted by my custom interceptor had their text_part set to nil. I was using initializer file to register it and as it turned out, my interceptor was added before Premailer::Rails::Hook.

I thought it'd be cool if you could hook into premailer-rails initializaition process to ensure that your custom interceptors are registered after those defined by premailer-rails. Here's what I've in mind:

class Premailer
  module Rails
    class Railtie < ::Rails::Railtie
      ActiveSupport.on_load(:action_mailer) do
        ActiveSupport::Notifications.instrument("register_interceptors.premailer_rails") do
          ::Premailer::Rails.register_interceptors
        end
      end
    end
  end
end

# initializer
ActiveSupport::Notifications.subscribe "register_interceptors.premailer_rails" do
  ActionMailer::Base.register_interceptor(MyCustomInterceptor)
end

Is that something you'd be interested in?

Looking forward to you response,
Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions