Skip to content

Commit 341485c

Browse files
authored
Feat: Add more Matomo events (#952)
## What was done? Added new matomo events for: - Notification clicks - Important information clicks
1 parent 251b1f1 commit 341485c

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

src/components/notifications/MessageBox.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../Too
1010
import { GlobalModalsContext } from '@/context/GlobalModalsProvider';
1111
import { IconX } from '@tabler/icons-react';
1212
import { Button } from '../Button';
13+
import { useMatomo } from '@jonkoops/matomo-tracker-react';
1314

1415
interface MessageBoxProps {
1516
userNotification: Concrete_Notification;
@@ -24,13 +25,19 @@ const MessageBox = ({ userNotification, isStandalone, isRead, updateLastTimeChec
2425
const [notificationModalOpen, setNotificationModalOpen] = useState<boolean>(false);
2526
const navigate = useNavigate();
2627
const { openLeavePageModal, openAchievementModal } = useContext(GlobalModalsContext);
28+
const { trackEvent } = useMatomo();
2729

2830
if (!userNotification || !userNotification.message || !isMessageValid(userNotification.message)) return null;
2931

3032
const { sentAt } = userNotification || { sentAt: '' };
3133
const { headline, body, type, navigateTo, modalText } = userNotification.message;
3234

3335
const navigateToLink = () => {
36+
trackEvent({
37+
category: 'notification',
38+
action: `${userNotification.message?.type} notification clicked`,
39+
name: userNotification.message?.headline,
40+
});
3441
if (modalText) {
3542
setNotificationModalOpen(true);
3643
}

src/widgets/ImportantInformation.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import AchievementModal from '../components/achievements/modals/AchievementModal
1515
import NextStepModal from '../components/achievements/modals/NextStepModal';
1616
import { NextStepLabelType } from '../helper/important-information-helper';
1717
import { createPupilScreeningLink, createStudentScreeningLink } from '../helper/screening-helper';
18+
import { useMatomo } from '@jonkoops/matomo-tracker-react';
1819

1920
type Props = {
2021
variant?: 'normal' | 'dark';
@@ -28,6 +29,8 @@ type Information = {
2829
key?: string;
2930
};
3031

32+
type ConfigurableInfo = { title: string; desciption: string; language: string; btnfn: (() => void) | null };
33+
3134
export const IMPORTANT_INFORMATION_QUERY = gql(`
3235
query GetOnboardingInfos {
3336
important_informations {
@@ -123,6 +126,7 @@ query GetOnboardingInfos {
123126

124127
const ImportantInformation: React.FC<Props> = ({ variant }) => {
125128
const { t, i18n } = useTranslation();
129+
const { trackEvent } = useMatomo();
126130
const navigate = useNavigate();
127131

128132
const { show } = useModal();
@@ -317,7 +321,7 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
317321
}, [student, sendMail, email, pupil, roles, confirmInterest, refuseInterest, deleteMatchRequest, data, navigate]);
318322

319323
const configurableInfos = useMemo(() => {
320-
let configurableInfos: { title: string; desciption: string; btnfn: (() => void) | null }[] = [];
324+
let configurableInfos: ConfigurableInfo[] = [];
321325

322326
// -------- Configurable Important Information -----------
323327
importantInformations
@@ -335,13 +339,32 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
335339
window.location.href = info.navigateTo;
336340
}
337341
: null,
342+
language: info.language,
338343
});
339344
});
340345
return configurableInfos;
341346
}, [importantInformations, pupil, student]);
342347

343348
if (!infos.length && !configurableInfos.length) return null;
344349

350+
const handleOnConfigurableInfoClick = (info: ConfigurableInfo) => {
351+
trackEvent({
352+
category: 'dashboard',
353+
action: 'Click Important Information Card',
354+
name: `${pupil ? 'SuS' : 'HuH'} - ${info.title} - ${info.language}`,
355+
});
356+
info.btnfn && info.btnfn();
357+
};
358+
359+
const handleOnInfoClick = (info: Information) => {
360+
trackEvent({
361+
category: 'dashboard',
362+
action: 'Click Important Information Card',
363+
name: `${pupil ? 'SuS' : 'HuH'} - ${t(`helperwizard.${info.label}.title` as unknown as TemplateStringsArray, { lng: 'de' })}`,
364+
});
365+
setSelectedInformation(info);
366+
};
367+
345368
return (
346369
<Box>
347370
{selectedAchievement && (
@@ -400,7 +423,7 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
400423
actionDescription={t('moreInfoButton')}
401424
actionType={Achievement_Action_Type_Enum.Action}
402425
onClick={() => {
403-
info.btnfn && info.btnfn();
426+
handleOnConfigurableInfoClick(info);
404427
}}
405428
/>
406429
);
@@ -419,7 +442,7 @@ const ImportantInformation: React.FC<Props> = ({ variant }) => {
419442
description={t(`helperwizard.${config.label}.content` as unknown as TemplateStringsArray, config.lang)}
420443
actionDescription={actionDescription}
421444
actionType={Achievement_Action_Type_Enum.Action}
422-
onClick={() => setSelectedInformation({ ...config, btntxt: buttontexts })}
445+
onClick={() => handleOnInfoClick({ ...config, btntxt: buttontexts })}
423446
/>
424447
);
425448
})}

0 commit comments

Comments
 (0)