Skip to content

Commit

Permalink
feat(sentry): add sentry breadcrumbs for slow redirects and a better …
Browse files Browse the repository at this point in the history
…expiration page
  • Loading branch information
rahulkeerthi committed Nov 14, 2023
1 parent 886e7a0 commit 556e78c
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 6 deletions.
22 changes: 20 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -113,7 +129,7 @@ const Home: NextPageWithLayout = () => {

if (session && session?.status !== HostedSessionStatus.Active) {
return (
<ThemeProvider accentColor={branding?.accent_color || undefined}>
<ThemeProvider accentColor={branding?.accent_color ?? undefined}>
<HostedPageLayout
logo={defaultTo(branding?.logo_url, awell_logo)}
onCloseHostedPage={onOpenCloseHostedSessionModal}
Expand All @@ -124,7 +140,9 @@ const Home: NextPageWithLayout = () => {

{/* Show static cancel page if cancel URL is not available */}
{shouldRedirect === false &&
session.status === HostedSessionStatus.Expired && <CancelPage />}
session.status === HostedSessionStatus.Expired && (
<CancelPage message="session.session_expired" />
)}

{/* Show 'redirecting' page if URL is available */}
{shouldRedirect && (
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
1 change: 1 addition & 0 deletions public/locales/et/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
1 change: 1 addition & 0 deletions public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?",
Expand Down
1 change: 1 addition & 0 deletions public/locales/nl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ro/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"redirecting_to_next_page": "Через несколько секунд мы автоматически перенаправим Вас на новый адрес. ",
"all_activities_completed": "Вы совершили все действия. Теперь Вы можете закрыть эту страницу.",
"session_canceled": "Ваша сессия истекла.",
"session_expired": "Ваша сессия истекла.",
"try_again": "Попробуйте снова",
"close_modal": {
"title": "Вы уверены, что хотите закрыть сессию?",
Expand Down
10 changes: 8 additions & 2 deletions src/components/CancelPage/CancelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<CancelPageProps> = ({
message = 'session.session_canceled',
}): JSX.Element => {
const { t } = useTranslation()
return (
<div className={classes.cancel_page}>
<div className={classes.cancel_icon}>
<Image src={cancelIcon} alt="" width={64} height={64} />
</div>
<div className={classes.cancel_text}>{t('session.session_canceled')}</div>
<div className={classes.cancel_text}>{t(message)}</div>
</div>
)
}
6 changes: 4 additions & 2 deletions src/services/ErrorReporter/addSentryBreadcrumb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = ({
Expand Down

0 comments on commit 556e78c

Please sign in to comment.