diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index 7dd8f8382..d91ee9da4 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -1,6 +1,10 @@ class NotifyMailer < ApplicationMailer - has_history extra: -> { { feedback_message_id: params[:feedback_message_id] } }, - only: :feedback_message_resolution_email + has_history extra: lambda { + { + feedback_message_id: params[:feedback_message_id], + utm_campaign: params[:email_type] + } + }, only: :feedback_message_resolution_email def new_reply_email @comment = params[:comment] diff --git a/spec/mailers/notify_mailer_spec.rb b/spec/mailers/notify_mailer_spec.rb index 1367f453b..eac31a57d 100644 --- a/spec/mailers/notify_mailer_spec.rb +++ b/spec/mailers/notify_mailer_spec.rb @@ -281,6 +281,14 @@ RSpec.describe NotifyMailer, type: :mailer do expect(user.email_messages.last.feedback_message_id).to eq(feedback_message.id) end + + it "tracks the email_type as the UTM campaign" do + assert_emails 1 do + email.deliver_now + end + + expect(user.email_messages.last.utm_campaign).to eq("Reporter") + end end describe "#feedback_response_email" do