From d7e17cf55b3046bea007ed18993e18171f3cef29 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Tue, 22 Aug 2023 10:44:59 +0100 Subject: [PATCH] More tracking fixes - for the index page of the email subscriptions management, when returning from a successful action such as changing the frequency of an email or unsubscribing from all emails - we need the message (not the description of the message) to be in English for tracking purposes, so we add `message_en` to all of the `flash[:success]` objects, that are used to display the success element as well as track in GA4 that it has appeared - this was partly done before but not extensively enough (some success tracking was missing text or had the wrong text) --- app/controllers/subscriptions_management_controller.rb | 4 +++- app/controllers/unsubscriptions_controller.rb | 1 + app/views/subscriptions_management/index.html.erb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/subscriptions_management_controller.rb b/app/controllers/subscriptions_management_controller.rb index 475549aa..429aa347 100644 --- a/app/controllers/subscriptions_management_controller.rb +++ b/app/controllers/subscriptions_management_controller.rb @@ -38,6 +38,7 @@ def change_frequency flash[:success] = { message: t("subscriptions_management.change_frequency.success", subscription_title:, frequency: frequency_text), + message_en: t("subscriptions_management.change_frequency.success", subscription_title:, frequency: frequency_text, locale: :en), } redirect_to list_subscriptions_path @@ -67,6 +68,7 @@ def change_address ) flash[:success] = { message: t("subscriptions_management.update_address.success", address: new_address), + message_en: t("subscriptions_management.update_address.success", address: new_address, locale: :en), } redirect_to list_subscriptions_path @@ -83,8 +85,8 @@ def confirmed_unsubscribe_all GdsApi.email_alert_api.unsubscribe_subscriber(authenticated_subscriber_id) flash[:success] = { message: t("subscriptions_management.confirmed_unsubscribe_all.success_message"), + message_en: t("subscriptions_management.confirmed_unsubscribe_all.success_message", locale: :en), description: t("subscriptions_management.confirmed_unsubscribe_all.success_description"), - description_en: t("subscriptions_management.confirmed_unsubscribe_all.success_description", locale: :en), } rescue GdsApi::HTTPNotFound # The user has already unsubscribed. diff --git a/app/controllers/unsubscriptions_controller.rb b/app/controllers/unsubscriptions_controller.rb index 193e5689..d1fa6262 100644 --- a/app/controllers/unsubscriptions_controller.rb +++ b/app/controllers/unsubscriptions_controller.rb @@ -22,6 +22,7 @@ def confirmed if authenticated? flash[:success] = { message: t("subscriptions_management.index.unsubscribe.message", title: @title), + message_en: t("subscriptions_management.index.unsubscribe.message", title: @title, locale: :en), description: t("subscriptions_management.index.unsubscribe.description"), } diff --git a/app/views/subscriptions_management/index.html.erb b/app/views/subscriptions_management/index.html.erb index 7b40ef75..ee958ac2 100644 --- a/app/views/subscriptions_management/index.html.erb +++ b/app/views/subscriptions_management/index.html.erb @@ -5,7 +5,7 @@ ga4_data = { event_name: "form_complete", type: "email subscription", - text: flash[:success]["description_en"], + text: flash[:success]["message_en"], section: t("subscriptions_management.heading", locale: :en), action: "complete", tool_name: "Get emails from GOV.UK"