Skip to content

Commit 295a87e

Browse files
authored
Merge pull request #45 from tolkamps1/snowplow-fix
Add in error handling for snowplow
2 parents ff66ab7 + e2f55f9 commit 295a87e

File tree

5 files changed

+34
-14
lines changed

5 files changed

+34
-14
lines changed

met-web/src/components/engagement/view/EmailModal.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ const EmailModal = ({ defaultPanel, open, handleClose }: EmailModalProps) => {
4545
survey_id: savedEngagement.surveys[0].id,
4646
type: EmailVerificationType.Survey,
4747
});
48-
window.snowplow('trackSelfDescribingEvent', {
49-
schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0',
50-
data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id },
51-
});
48+
try {
49+
window.snowplow('trackSelfDescribingEvent', {
50+
schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0',
51+
data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id },
52+
});
53+
} catch (error) {
54+
console.log(error);
55+
}
5256
dispatch(
5357
openNotification({
5458
severity: 'success',

met-web/src/components/engagement/view/EngagementView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export const EngagementView = () => {
3333
if (!isPreview) {
3434
setDefaultPanel('email');
3535
setEmailModalOpen(true);
36-
window.snowplow('trackPageView', 'Verify Email Modal');
36+
try {
37+
window.snowplow('trackPageView', 'Verify Email Modal');
38+
} catch (error) {
39+
console.log(error);
40+
}
3741
return;
3842
}
3943

met-web/src/components/engagement/view/widgets/Subscribe/EmailListModal.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ const EmailListModal = ({ open, setOpen }: { open: boolean; setOpen: (open: bool
4242
type: subscriptionType || defaultType,
4343
});
4444

45-
window.snowplow('trackSelfDescribingEvent', {
46-
schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0',
47-
data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id },
48-
});
45+
try {
46+
window.snowplow('trackSelfDescribingEvent', {
47+
schema: 'iglu:ca.bc.gov.met/verify-email/jsonschema/1-0-0',
48+
data: { survey_id: savedEngagement.surveys[0].id, engagement_id: savedEngagement.id },
49+
});
50+
} catch (error) {
51+
console.log(error);
52+
}
4953
setOpen(false);
5054
dispatch(
5155
openNotificationModal({

met-web/src/components/survey/submit/ActionContext.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,14 @@ export const ActionProvider = ({ children }: { children: JSX.Element }) => {
171171
verification_token: token ? token : '',
172172
});
173173

174-
window.snowplow('trackSelfDescribingEvent', {
175-
schema: 'iglu:ca.bc.gov.met/submit-survey/jsonschema/1-0-0',
176-
data: { survey_id: savedSurvey.id, engagement_id: savedSurvey.engagement_id },
177-
});
174+
try {
175+
window.snowplow('trackSelfDescribingEvent', {
176+
schema: 'iglu:ca.bc.gov.met/submit-survey/jsonschema/1-0-0',
177+
data: { survey_id: savedSurvey.id, engagement_id: savedSurvey.engagement_id },
178+
});
179+
} catch (error) {
180+
console.log(error);
181+
}
178182
dispatch(
179183
openNotification({
180184
severity: 'success',

met-web/src/routes/PageViewTracker.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { useLocation } from 'react-router-dom';
44
const PageViewTracker = () => {
55
const location = useLocation();
66
useEffect(() => {
7-
window.snowplow('trackPageView');
7+
try {
8+
window.snowplow('trackPageView');
9+
} catch (error) {
10+
console.log(error);
11+
}
812
}, [location]);
913

1014
return null;

0 commit comments

Comments
 (0)