diff --git a/CHANGELOG.MD b/CHANGELOG.MD index cd4ddef94..b72ef0022 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -13,6 +13,10 @@ - Reworked image upload component to match the design system - Added new form components that align with the design system +- **Bugfix** Add try catch block around snowplow call [🎟️ DESENG-621](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-621) + - Added a try catch block to all snowplow calls + +## May 22, 2024 - **Feature** Add languages side nav link [🎟️ DESENG-622](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-622) ## May 21, 2024 diff --git a/met-web/src/components/engagement/view/EmailModal.tsx b/met-web/src/components/engagement/view/EmailModal.tsx index b97ff9fbf..9da8eb6c3 100644 --- a/met-web/src/components/engagement/view/EmailModal.tsx +++ b/met-web/src/components/engagement/view/EmailModal.tsx @@ -48,10 +48,14 @@ const EmailModal = ({ defaultPanel, open, handleClose }: EmailModalProps) => { type: EmailVerificationType.Survey, language: language.id, }); - window.snowplow('trackSelfDescribingEvent', { - schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0', - data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id }, - }); + try { + window.snowplow('trackSelfDescribingEvent', { + schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0', + data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id }, + }); + } catch (error) { + console.log('Email verification snowplow error:', error); + } dispatch( openNotification({ severity: 'success', diff --git a/met-web/src/components/engagement/view/EngagementView.tsx b/met-web/src/components/engagement/view/EngagementView.tsx index 971fa7fc8..d51a09a01 100644 --- a/met-web/src/components/engagement/view/EngagementView.tsx +++ b/met-web/src/components/engagement/view/EngagementView.tsx @@ -56,7 +56,11 @@ export const EngagementView = () => { if (!isPreview) { setDefaultPanel('email'); setEmailModalOpen(true); - window.snowplow('trackPageView', 'Verify Email Modal'); + try { + window.snowplow('trackPageView', 'Verify Email Modal'); + } catch (error) { + console.log('Verify email modal snowplow error:', error); + } return; } diff --git a/met-web/src/components/engagement/view/widgets/Subscribe/EmailListModal.tsx b/met-web/src/components/engagement/view/widgets/Subscribe/EmailListModal.tsx index aa0e96b91..5a99000dc 100644 --- a/met-web/src/components/engagement/view/widgets/Subscribe/EmailListModal.tsx +++ b/met-web/src/components/engagement/view/widgets/Subscribe/EmailListModal.tsx @@ -41,10 +41,14 @@ const EmailListModal = ({ open, setOpen }: { open: boolean; setOpen: (open: bool type: defaultType, }); - window.snowplow('trackSelfDescribingEvent', { - schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0', - data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id }, - }); + try { + window.snowplow('trackSelfDescribingEvent', { + schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0', + data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id }, + }); + } catch (error) { + console.log('Create subscription snowplow error:', error); + } setOpen(false); dispatch( openNotificationModal({ diff --git a/met-web/src/components/survey/submit/ActionContext.tsx b/met-web/src/components/survey/submit/ActionContext.tsx index 4c3ac5295..b401bb460 100644 --- a/met-web/src/components/survey/submit/ActionContext.tsx +++ b/met-web/src/components/survey/submit/ActionContext.tsx @@ -174,10 +174,14 @@ export const ActionProvider = ({ children }: { children: JSX.Element }) => { verification_token: token ? token : '', }); - window.snowplow('trackSelfDescribingEvent', { - schema: 'iglu:ca.bc.gov.met/submit-survey/jsonschema/1-0-0', - data: { survey_id: savedSurvey.id, engagement_id: savedSurvey.engagement_id }, - }); + try { + window.snowplow('trackSelfDescribingEvent', { + schema: 'iglu:ca.bc.gov.met/submit-survey/jsonschema/1-0-0', + data: { survey_id: savedSurvey.id, engagement_id: savedSurvey.engagement_id }, + }); + } catch (error) { + console.log('Survey submit notification snowplow error:', error); + } dispatch( openNotification({ severity: 'success', diff --git a/met-web/src/routes/PageViewTracker.tsx b/met-web/src/routes/PageViewTracker.tsx index 1cabacc54..0054eea5f 100644 --- a/met-web/src/routes/PageViewTracker.tsx +++ b/met-web/src/routes/PageViewTracker.tsx @@ -4,7 +4,11 @@ import { useLocation } from 'react-router-dom'; const PageViewTracker = () => { const location = useLocation(); useEffect(() => { - window.snowplow('trackPageView'); + try { + window.snowplow('trackPageView'); + } catch (error) { + console.log('Track page view snowplow error:', error); + } }, [location]); return null;