diff --git a/packages/code-du-travail-frontend/src/modules/contributions/ContributionLayout.tsx b/packages/code-du-travail-frontend/src/modules/contributions/ContributionLayout.tsx index 97ff6647bc..e9501b5ffb 100644 --- a/packages/code-du-travail-frontend/src/modules/contributions/ContributionLayout.tsx +++ b/packages/code-du-travail-frontend/src/modules/contributions/ContributionLayout.tsx @@ -53,6 +53,8 @@ export function ContributionLayout({ relatedItems, contribution }: Props) { emitAgreementUntreatedEvent, emitDisplayAgreementContent, emitDisplayGeneralContent, + emitClickP1, + emitClickP2, emitClickP3, } = useContributionTracking(); useEffect(() => { @@ -126,13 +128,22 @@ export function ContributionLayout({ relatedItems, contribution }: Props) {
{ + onAgreementSelect={(agreement, mode) => { setSelectedAgreement( isAgreementValid(agreement) ? agreement : undefined ); - if (agreement && isCCSupported(agreement)) { + if (!agreement) return; + switch (mode) { + case "p1": + emitClickP1(getTitle()); + break; + case "p2": + emitClickP2(getTitle()); + break; + } + if (isCCSupported(agreement)) { emitAgreementTreatedEvent(agreement?.id); - } else if (agreement) { + } else { emitAgreementUntreatedEvent(agreement?.id); } }} diff --git a/packages/code-du-travail-frontend/src/modules/contributions/tracking.ts b/packages/code-du-travail-frontend/src/modules/contributions/tracking.ts index 087d7ab574..a56f2f4263 100644 --- a/packages/code-du-travail-frontend/src/modules/contributions/tracking.ts +++ b/packages/code-du-travail-frontend/src/modules/contributions/tracking.ts @@ -13,6 +13,8 @@ export enum TrackingAgreementSearchAction { CLICK_DISPLAY_AGREEMENT_CONTENT = "click_afficher_les_informations_CC", CLICK_DISPLAY_GENERIC_CONTENT = "click_afficher_les_informations_sans_CC", CLICK_DISPLAY_GENERAL_CONTENT = "click_afficher_les_informations_générales", + CLICK_P1 = "click_p1", + CLICK_P2 = "click_p2", CLICK_P3 = "click_p3", } @@ -49,6 +51,22 @@ export const useContributionTracking = () => { }); }; + const emitClickP1 = (path: string) => { + sendEvent({ + category: TrackingContributionCategory.CC_SEARCH_TYPE_OF_USERS, + action: TrackingAgreementSearchAction.CLICK_P1, + name: path, + }); + }; + + const emitClickP2 = (path: string) => { + sendEvent({ + category: TrackingContributionCategory.CC_SEARCH_TYPE_OF_USERS, + action: TrackingAgreementSearchAction.CLICK_P2, + name: path, + }); + }; + const emitClickP3 = (path: string) => { sendEvent({ category: TrackingContributionCategory.CC_SEARCH_TYPE_OF_USERS, @@ -62,6 +80,8 @@ export const useContributionTracking = () => { emitAgreementUntreatedEvent, emitDisplayAgreementContent, emitDisplayGeneralContent, + emitClickP1, + emitClickP2, emitClickP3, }; }; diff --git a/packages/code-du-travail-frontend/src/modules/convention-collective/AgreementSearch/AgreementSearchForm.tsx b/packages/code-du-travail-frontend/src/modules/convention-collective/AgreementSearch/AgreementSearchForm.tsx index b6c5fcdd0c..f25562f573 100644 --- a/packages/code-du-travail-frontend/src/modules/convention-collective/AgreementSearch/AgreementSearchForm.tsx +++ b/packages/code-du-travail-frontend/src/modules/convention-collective/AgreementSearch/AgreementSearchForm.tsx @@ -9,7 +9,7 @@ import { } from "../../enterprise"; type Props = { - onAgreementSelect?: (agreement?: EnterpriseAgreement) => void; + onAgreementSelect?: (agreement?: EnterpriseAgreement, mode?: string) => void; selectedAgreementAlert?: ( agreement?: EnterpriseAgreement ) => NonNullable | undefined; @@ -54,7 +54,7 @@ export const AgreementSearchForm = ({ {mode === "agreementSearch" && ( { - if (onAgreementSelect) onAgreementSelect(agreement); + if (onAgreementSelect) onAgreementSelect(agreement, "p1"); }} selectedAgreementAlert={selectedAgreementAlert} /> @@ -62,7 +62,7 @@ export const AgreementSearchForm = ({ {mode === "enterpriseSearch" && ( { - if (onAgreementSelect) onAgreementSelect(agreement); + if (onAgreementSelect) onAgreementSelect(agreement, "p2"); }} selectedAgreementAlert={selectedAgreementAlert} />