From 556e78c1d16b35dc8582ca9ec92f2115956e8544 Mon Sep 17 00:00:00 2001 From: Rahul Keerthi Date: Tue, 14 Nov 2023 08:52:12 +0000 Subject: [PATCH] feat(sentry): add sentry breadcrumbs for slow redirects and a better expiration page --- pages/index.tsx | 22 +++++++++++++++++-- public/locales/en/common.json | 1 + public/locales/et/common.json | 1 + public/locales/fr/common.json | 1 + public/locales/nl/common.json | 1 + public/locales/ro/common.json | 1 + public/locales/ru/common.json | 1 + src/components/CancelPage/CancelPage.tsx | 10 +++++++-- .../ErrorReporter/addSentryBreadcrumb.ts | 6 +++-- 9 files changed, 38 insertions(+), 6 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 353452c4..4bd283d9 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -43,6 +43,22 @@ const Home: NextPageWithLayout = () => { removeAccessToken() router.push(url) }, 2000) + + // add sentry breadcrumb if redirect takes more than 10 seconds + setTimeout(() => { + addSentryBreadcrumb({ + category: BreadcrumbCategory.SLOW_REDIRECT, + data: { session, message: 'Redirect took at least 10 seconds' }, + }) + }, 10000) + + // add sentry breadcrumb if redirect takes more than 15 seconds + setTimeout(() => { + addSentryBreadcrumb({ + category: BreadcrumbCategory.SLOW_REDIRECT, + data: { session, message: 'Redirect took at least 15 seconds' }, + }) + }, 15001) } const onOpenCloseHostedSessionModal = () => { @@ -113,7 +129,7 @@ const Home: NextPageWithLayout = () => { if (session && session?.status !== HostedSessionStatus.Active) { return ( - + { {/* Show static cancel page if cancel URL is not available */} {shouldRedirect === false && - session.status === HostedSessionStatus.Expired && } + session.status === HostedSessionStatus.Expired && ( + + )} {/* Show 'redirecting' page if URL is available */} {shouldRedirect && ( diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c6024931..5aceec73 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -93,6 +93,7 @@ "redirecting_to_next_page": "Redirecting you in a moment...", "all_activities_completed": "You have completed all your activities. You can close this page now.", "session_canceled": "Your session has been cancelled.", + "session_expired": "Your session has expired after 1 hour of inactivity.", "try_again": "Try again", "close_modal": { "title": "Are you sure you want to cancel your session?", diff --git a/public/locales/et/common.json b/public/locales/et/common.json index 6b9860a5..728fb483 100644 --- a/public/locales/et/common.json +++ b/public/locales/et/common.json @@ -69,6 +69,7 @@ "redirecting_to_next_page": "Teid suunatakse hetke pärast ümber.", "all_activities_completed": "Oled lõpetanud oma tegevused. Võid selle akna nüüd sulgeda.", "session_canceled": "Teie sessioon on katkestatud.", + "session_expired": "Teie sessioon on aegunud pärast 1-tunnist tegevusetust.", "try_again": "Proovi uuesti", "close_modal": { "title": "Soovid pöördumise täitmise pooleli jätta?", diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index 7674be61..8032ec3f 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -93,6 +93,7 @@ "redirecting_to_next_page": "Redirection dans un instant.", "all_activities_completed": "Vous avez terminé toutes vos activités. Vous pouvez maintenant fermer cette page.", "session_canceled": "Votre session a été annulée.", + "session_expired": "Votre session a expiré après 1 heure d'inactivité.", "try_again": "Réessayer", "close_modal": { "title": "Êtes-vous sûr de vouloir annuler votre session ?", diff --git a/public/locales/nl/common.json b/public/locales/nl/common.json index 26abbf15..53164af1 100644 --- a/public/locales/nl/common.json +++ b/public/locales/nl/common.json @@ -64,6 +64,7 @@ "redirecting_to_next_page": "Je wordt meteen doorverwezen.", "all_activities_completed": "Je hebt alle activiteiten voltooid. Je kan deze pagina nu sluiten.", "session_canceled": "Je sessie werd geannuleerd.", + "session_expired": "Je sessie is verlopen na 1 uur inactiviteit.", "try_again": "Opnieuw proberen", "close_modal": { "title": "Ben je zeker dat je de sessie wil afsluiten?", diff --git a/public/locales/ro/common.json b/public/locales/ro/common.json index 897656fc..c93adf5c 100644 --- a/public/locales/ro/common.json +++ b/public/locales/ro/common.json @@ -68,6 +68,7 @@ "redirecting_to_next_page": "Te redirecționăm intr-un moment.", "all_activities_completed": "Ai finalizat toate activitățile. Poți închide această pagină.", "session_canceled": "Sesiunea ta a fost anulata.", + "session_expired": "Sesiunea ta a expirat după o oră de inactivitate.", "try_again": "Încercați din nou", "close_modal": { "title": "Ești sigur că vrei să anulezi sesiunea ta?", diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 9dcfd6c0..bb8487d1 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -80,6 +80,7 @@ "redirecting_to_next_page": "Через несколько секунд мы автоматически перенаправим Вас на новый адрес. ", "all_activities_completed": "Вы совершили все действия. Теперь Вы можете закрыть эту страницу.", "session_canceled": "Ваша сессия истекла.", + "session_expired": "Ваша сессия истекла.", "try_again": "Попробуйте снова", "close_modal": { "title": "Вы уверены, что хотите закрыть сессию?", diff --git a/src/components/CancelPage/CancelPage.tsx b/src/components/CancelPage/CancelPage.tsx index cb8759a1..e659535c 100644 --- a/src/components/CancelPage/CancelPage.tsx +++ b/src/components/CancelPage/CancelPage.tsx @@ -4,14 +4,20 @@ import { FC } from 'react' import Image from 'next/image' import cancelIcon from './../../assets/cancel.svg' -export const CancelPage: FC = (): JSX.Element => { +interface CancelPageProps { + message?: string +} + +export const CancelPage: FC = ({ + message = 'session.session_canceled', +}): JSX.Element => { const { t } = useTranslation() return (
-
{t('session.session_canceled')}
+
{t(message)}
) } diff --git a/src/services/ErrorReporter/addSentryBreadcrumb.ts b/src/services/ErrorReporter/addSentryBreadcrumb.ts index 1b24cc87..d0b831f9 100644 --- a/src/services/ErrorReporter/addSentryBreadcrumb.ts +++ b/src/services/ErrorReporter/addSentryBreadcrumb.ts @@ -9,8 +9,9 @@ export enum BreadcrumbCategory { SESSION_CANCEL = 'SESSION_CANCEL', READ_MESSAGE = 'READ_MESSAGE', SUBMIT_CHECKLIST = 'SUBMIT_CHECKLIST', - GENERIC = 'generic', - NAVIGATION = 'navigation', + GENERIC = 'GENERIC', + NAVIGATION = 'NAVIGATION', + SLOW_REDIRECT = 'SLOW_REDIRECT', } const SentryBreadcrumbMessageDictionary = { @@ -23,6 +24,7 @@ const SentryBreadcrumbMessageDictionary = { [BreadcrumbCategory.SUBMIT_CHECKLIST]: 'Submitting checklist', [BreadcrumbCategory.GENERIC]: 'Generic event', [BreadcrumbCategory.NAVIGATION]: 'Navigation', + [BreadcrumbCategory.SLOW_REDIRECT]: 'Slow redirect at session end', } export const addSentryBreadcrumb = ({