From 7d9ce63e0584ea5e260c3bc278bbb688fe95f148 Mon Sep 17 00:00:00 2001 From: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com> Date: Wed, 7 Apr 2021 12:54:51 -0400 Subject: [PATCH] Add email type as utm_campaign column (#13297) --- app/mailers/notify_mailer.rb | 8 ++++++-- spec/mailers/notify_mailer_spec.rb | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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