Skip to content

Commit

Permalink
fix(events): refactor pushAgreements (#5302)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgfr authored Aug 7, 2023
1 parent 61f06b3 commit 7119a85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions packages/code-du-travail-frontend/src/lib/matomo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export enum MatomoSearchAgreementCategory {
ENTERPRISE_SELECT = "enterprise_select",
AGREEMENT_SELECT_P1 = "cc_select_p1",
AGREEMENT_SELECT_P2 = "cc_select_p2",
PARCOURS_1 = "click_p1",
PARCOURS_2 = "click_p2",
PARCOURS_3 = "click_p3",
ENTERPRISE_SEARCH = "enterprise_search",
AGREEMENT_SEARCH = "cc_search",
AGREEMENT_SEARCH_TYPE_OF_USERS = "cc_search_type_of_users",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ const pushAgreementEvents = (
// no agreement section, no event to send. Should never happen.
return;
}
let eventName = "";
let parcours: MatomoSearchAgreementCategory | undefined = undefined;
let agreementSelect: MatomoSearchAgreementCategory | undefined = undefined;
switch (values.route) {
case "not-selected":
eventName = "click_p3";
break;
case "agreement":
eventName = "click_p1";
parcours = MatomoSearchAgreementCategory.PARCOURS_1;
agreementSelect = MatomoSearchAgreementCategory.AGREEMENT_SELECT_P1;
break;
case "enterprise":
eventName = "click_p2";
parcours = MatomoSearchAgreementCategory.PARCOURS_2;
agreementSelect = MatomoSearchAgreementCategory.AGREEMENT_SELECT_P2;
break;
case "not-selected":
parcours = MatomoSearchAgreementCategory.PARCOURS_3;
break;
}
matopush([
MatomoBaseEvent.TRACK_EVENT,
MatomoSearchAgreementCategory.AGREEMENT_SEARCH_TYPE_OF_USERS,
eventName,
parcours,
simulatorTitle,
]);
if (values.enterprise) {
Expand All @@ -46,12 +49,10 @@ const pushAgreementEvents = (
}),
]);
}
if (values.selected) {
if (values.selected && agreementSelect) {
matopush([
MatomoBaseEvent.TRACK_EVENT,
values.route === "agreement"
? MatomoSearchAgreementCategory.AGREEMENT_SELECT_P1
: MatomoSearchAgreementCategory.AGREEMENT_SELECT_P2,
agreementSelect,
simulatorTitle,
`idcc${values.selected.num?.toString()}`,
]);
Expand Down

0 comments on commit 7119a85

Please sign in to comment.