Skip to content

Commit

Permalink
fix: events matomo concatenates instead of multiple values
Browse files Browse the repository at this point in the history
  • Loading branch information
HoreKk committed Apr 30, 2024
1 parent 6d25788 commit a89c981
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 85 deletions.
13 changes: 12 additions & 1 deletion webapp/src/components/account/PassCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ import { useAuth } from "~/providers/Auth";
import NewPassComponent from "../NewPassComponent";
import Image from "next/image";
import LoadingLoader from "../LoadingLoader";
import { push } from "@socialgouv/matomo-next";
import { OfferIncluded } from "~/server/api/routers/offer";

type PropsPassCard = {
isPage: boolean;
offer?: OfferIncluded;
};

const PassCard = ({ isPage }: PropsPassCard) => {
const PassCard = ({ isPage, offer }: PropsPassCard) => {
const { user } = useAuth();

const {
Expand Down Expand Up @@ -94,6 +97,14 @@ const PassCard = ({ isPage }: PropsPassCard) => {
)}
<Link
href="/dashboard/account/card"
onClick={() => {
if (!isPage)
push([
"trackEvent",
"Offre",
`${offer?.partner.name} - ${offer?.title} - Active - Présenter ma carte CJE`,
]);
}}
pointerEvents={isPage ? "none" : "auto"}
tabIndex={isPage ? -1 : 0}
aria-disabled={!isPage}
Expand Down
21 changes: 7 additions & 14 deletions webapp/src/components/offer/StepsButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,14 @@ const StepsButtons = ({
push([
"trackEvent",
"Offre",
`${offer.partner.name}`,
`${offer.title}`,
"Inactive",
"J'active mon offre",
"J'ai compris",
`${offer.partner.name} - ${offer.title} - Inactive - J'active mon offre - J'ai compris`,
]);
setActiveStep(activeStep + 1);
} else if (handleValidate) {
push([
"trackEvent",
"Offre",
`${offer.partner.name}`,
`${offer.title}`,
"Inactive",
"J'active mon offre - Validation",
`${offer.partner.name} - ${offer.title} - Inactive - J'active mon offre - Validation`,
]);
setIsValidating(true);
handleValidate().then(() => setIsValidating(false));
Expand All @@ -80,11 +73,11 @@ const StepsButtons = ({
push([
"trackEvent",
"Offre",
`${offer.partner.name}`,
`${offer.title}`,
"Inactive",
"J'active mon offre",
`Cette offre ne m'intéresse pas ${activeStep === count ? "2" : ""}`,
`${offer.partner.name} - ${
offer.title
} - Inactive - J'active mon offre - Cette offre ne m'intéresse pas ${
activeStep === count ? "2" : ""
}`,
]);
handleOnClose();
}}
Expand Down
7 changes: 2 additions & 5 deletions webapp/src/components/wrappers/CouponWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ const CTAButton = ({
push([
"trackEvent",
"Offre",
offer.partner.name,
offer.title,
"Active",
"Aller sur le site",
`${offer.partner.name} - ${offer.title} - Active - Aller sur le site`,
]);
handleOpenExternalLink();
}}
Expand All @@ -79,7 +76,7 @@ const CTAButton = ({
Ma carte CJE
</Text>
</Flex>
<PassCard isPage={false} />
<PassCard isPage={false} offer={offer} />
</Flex>
// <Link
// href="/dashboard/account/card"
Expand Down
92 changes: 48 additions & 44 deletions webapp/src/pages/dashboard/categories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,55 @@ import { api } from "~/utils/api";
import { push } from "@socialgouv/matomo-next";

export default function CategoriesList() {
const { data: resultCategories, isLoading: isLoadingCategories } =
api.category.getList.useQuery({
page: 1,
perPage: 50,
sort: "createdAt",
});
const { data: resultCategories, isLoading: isLoadingCategories } =
api.category.getList.useQuery({
page: 1,
perPage: 50,
sort: "createdAt",
});

const { data: categories } = resultCategories || {};
const { data: categories } = resultCategories || {};

if (isLoadingCategories || !categories)
return (
<CategoriesWrapper isLoading>
<Center w="full" h="full">
<LoadingLoader />
</Center>
</CategoriesWrapper>
);
if (isLoadingCategories || !categories)
return (
<CategoriesWrapper isLoading>
<Center w="full" h="full">
<LoadingLoader />
</Center>
</CategoriesWrapper>
);

return (
<CategoriesWrapper>
{categories.map((category) => (
<Link key={category.id} href={`/dashboard/category/${category.slug}`} onClick={() => {
push(['trackEvent', 'Explorer', 'Catégories', category.label])
}}>
<Flex
flexDir="column"
borderRadius="xl"
justifyContent="center"
alignItems="center"
textAlign="center"
bgColor="white"
h="120px"
>
<Image
src={category.icon.url as string}
alt={category.icon.alt as string}
width={58}
height={58}
/>
<Text fontWeight="medium" fontSize="sm" mt={1.5}>
{category.label}
</Text>
</Flex>
</Link>
))}
</CategoriesWrapper>
);
return (
<CategoriesWrapper>
{categories.map((category) => (
<Link
key={category.id}
href={`/dashboard/category/${category.slug}`}
onClick={() => {
push(["trackEvent", "Explorer", "Catégories - " + category.label]);
}}
>
<Flex
flexDir="column"
borderRadius="xl"
justifyContent="center"
alignItems="center"
textAlign="center"
bgColor="white"
h="120px"
>
<Image
src={category.icon.url as string}
alt={category.icon.alt as string}
width={58}
height={58}
/>
<Text fontWeight="medium" fontSize="sm" mt={1.5}>
{category.label}
</Text>
</Flex>
</Link>
))}
</CategoriesWrapper>
);
}
6 changes: 1 addition & 5 deletions webapp/src/pages/dashboard/category/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ export default function CategoryOfferList() {
offer={offer}
matomoEvent={[
"Explorer",
"Catégories",
category.label,
"Offre",
offer.partner.name,
offer.title,
`Catégories - ${category.label} - Offre - ${offer.partner.name} - ${offer.title}`,
]}
/>
))}
Expand Down
15 changes: 7 additions & 8 deletions webapp/src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export default function Dashboard() {
key={category.id}
href={`/dashboard/category/${category.slug}`}
onClick={() => {
push(["trackEvent", "Accueil", "Catégories", category.label]);
push([
"trackEvent",
"Accueil",
"Catégories - " + category.label,
]);
}}
passHref
>
Expand Down Expand Up @@ -193,10 +197,7 @@ export default function Dashboard() {
push([
"trackEvent",
"Accueil",
"Accès rapide",
"Offre",
quickAccess.offer.partner.name,
quickAccess.offer.title,
`Accès rapide - Offre - ${quickAccess.offer.partner.name} - ${quickAccess.offer.title}`,
]);
}}
passHref
Expand Down Expand Up @@ -254,9 +255,7 @@ export default function Dashboard() {
matomoEvent={[
"Accueil",
"Pour vous",
"Offre",
offer.partner.name,
offer.title,
`Offre - ${offer.partner.name} - ${offer.title} `,
]}
/>
))}
Expand Down
14 changes: 6 additions & 8 deletions webapp/src/pages/dashboard/offer/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,9 @@ export default function OfferPage() {
push([
"trackEvent",
"Offre",
offer.partner.name,
offer.title,
!!coupon ? "Active" : "Inactive",
"Comment ça marche",
`${offer.partner.name} - ${offer.title} - ${
!!coupon ? "Active" : "Inactive"
} - Comment ça marche`,
]);
onOpenTermsOfUse();
}}
Expand Down Expand Up @@ -331,10 +330,9 @@ export default function OfferPage() {
push([
"trackEvent",
"Offre",
offer.partner.name,
offer.title,
!!coupon ? "Active" : "Inactive",
"Conditions",
`${offer.partner.name} - ${offer.title} - ${
!!coupon ? "Active" : "Inactive"
} - Conditions`,
]);
onOpenOtherConditions();
}}
Expand Down

0 comments on commit a89c981

Please sign in to comment.