Skip to content

Commit

Permalink
chore: tracking p1 et p2
Browse files Browse the repository at this point in the history
  • Loading branch information
victor committed Jan 9, 2025
1 parent 3175ea5 commit 7ab21d0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export function ContributionLayout({ relatedItems, contribution }: Props) {
emitAgreementUntreatedEvent,
emitDisplayAgreementContent,
emitDisplayGeneralContent,
emitClickP1,
emitClickP2,
emitClickP3,
} = useContributionTracking();
useEffect(() => {
Expand Down Expand Up @@ -126,13 +128,22 @@ export function ContributionLayout({ relatedItems, contribution }: Props) {
</div>
<div>
<AgreementSearchForm
onAgreementSelect={(agreement) => {
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);
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down Expand Up @@ -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,
Expand All @@ -62,6 +80,8 @@ export const useContributionTracking = () => {
emitAgreementUntreatedEvent,
emitDisplayAgreementContent,
emitDisplayGeneralContent,
emitClickP1,
emitClickP2,
emitClickP3,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../../enterprise";

type Props = {
onAgreementSelect?: (agreement?: EnterpriseAgreement) => void;
onAgreementSelect?: (agreement?: EnterpriseAgreement, mode?: string) => void;
selectedAgreementAlert?: (
agreement?: EnterpriseAgreement
) => NonNullable<ReactNode> | undefined;
Expand Down Expand Up @@ -54,15 +54,15 @@ export const AgreementSearchForm = ({
{mode === "agreementSearch" && (
<AgreementSearchInput
onAgreementSelect={(agreement) => {
if (onAgreementSelect) onAgreementSelect(agreement);
if (onAgreementSelect) onAgreementSelect(agreement, "p1");
}}
selectedAgreementAlert={selectedAgreementAlert}
/>
)}
{mode === "enterpriseSearch" && (
<EnterpriseAgreementSearchInput
onAgreementSelect={(agreement) => {
if (onAgreementSelect) onAgreementSelect(agreement);
if (onAgreementSelect) onAgreementSelect(agreement, "p2");
}}
selectedAgreementAlert={selectedAgreementAlert}
/>
Expand Down

0 comments on commit 7ab21d0

Please sign in to comment.