Sha256: d24524e3836daa1d714ad22e5503b2319f4b192dd10ef37493b1d5b5036246ef

Contents?: true

Size: 1003 Bytes

Versions: 4

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

module PlainApm
  module Hooks
    class ActionMailer < ActiveSupportSubscriber
      NOTIFICATION_PATTERN = /\A[^!]\w+\.action_mailer\Z/.freeze

      private

      def notification_pattern
        NOTIFICATION_PATTERN
      end

      def payload(event)
        name, base = attributes_from_notification(event)
        payload = event.payload

        case name
        when "deliver"
          base.tap do |o|
            o[:message_id] = payload[:message_id]
            o[:mailer] = payload[:mailer]
            o[:perform_deliveries] = payload[:perform_deliveries]
            o[:subject] = payload[:subject]
            o[:from] = [*payload[:from]]
            o[:to] = [*payload[:to]].map { |t| Digest::SHA1.hexdigest(t.to_s) }
          end
        when "process"
          base.tap do |o|
            o[:mailer] = payload[:mailer]
            o[:mailer_action] = payload[:action]
          end
        else
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/hooks/action_mailer.rb
plain_apm-0.10.0 lib/plain_apm/hooks/action_mailer.rb
plain_apm-0.9.8 lib/plain_apm/hooks/action_mailer.rb
plain_apm-0.9.7 lib/plain_apm/hooks/action_mailer.rb