Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumentation support #283

Open
kushniryb opened this issue Mar 17, 2023 · 1 comment
Open

Instrumentation support #283

kushniryb opened this issue Mar 17, 2023 · 1 comment

Comments

@kushniryb
Copy link

kushniryb commented Mar 17, 2023

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!

@fphilipe
Copy link
Owner

@kushniryb, sounds like an interesting addition. Feel free to fire a PR 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants