lib/ahoy_email/tracker.rb in ahoy_email-1.0.0 vs lib/ahoy_email/tracker.rb in ahoy_email-1.0.1

- old
+ new

@@ -5,17 +5,15 @@ def initialize(message) @message = message end def perform - if message.perform_deliveries && (data_header = message["Ahoy-Message"]) - Safely.safely do - data = JSON.parse(data_header.to_s).symbolize_keys - data[:message] = message - AhoyEmail.track_method.call(data) + Safely.safely do + # perform_deliveries check still needed in observer + if message.perform_deliveries && message.ahoy_data + data = message.ahoy_data.merge(message: message) + message.ahoy_message = AhoyEmail.track_method.call(data) end end - ensure - message["Ahoy-Message"] = nil if message["Ahoy-Message"] end end end