Skip to content

Commit

Permalink
fix(matomo): add locale to event category name
Browse files Browse the repository at this point in the history
Break Homepage metrics into per-locale dashboards
  • Loading branch information
wackerow committed Sep 24, 2024
1 parent f758828 commit 0c8e7fc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/components/Homepage/BentoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type BentoCardProps = HTMLAttributes<HTMLDivElement> & {
imgHeight?: number
title: string
eventName: string
eventCategory: string
}

const BentoCard = ({
Expand All @@ -30,6 +31,7 @@ const BentoCard = ({
imgHeight,
title,
eventName,
eventCategory,
}: BentoCardProps) => (
<Card
className={cn(
Expand All @@ -50,7 +52,7 @@ const BentoCard = ({
variant="outline"
isSecondary
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "use cases",
eventName,
}}
Expand Down
8 changes: 6 additions & 2 deletions src/components/Homepage/ValuesMarquee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ItemProps = React.HTMLAttributes<HTMLButtonElement> & {
separatorClass: string
container?: HTMLElement | null
label: string
eventCategory: string
}

const Item = ({
Expand All @@ -34,13 +35,14 @@ const Item = ({
separatorClass,
container,
label,
eventCategory,
}: ItemProps) => (
<>
<Tooltip
container={container}
onBeforeOpen={() => {
trackCustomEvent({
eventCategory: "Homepage",
eventCategory,
eventAction: "internet_changing",
eventName: label,
})
Expand Down Expand Up @@ -138,7 +140,7 @@ const Row = forwardRef<HTMLDivElement, RowProps>(
Row.displayName = "Row"

const ValuesMarquee = () => {
const { t, pairings } = useValuesMarquee()
const { t, pairings, eventCategory } = useValuesMarquee()
const containerFirstRef = useRef<HTMLDivElement>(null)
const containerSecondRef = useRef<HTMLDivElement>(null)

Expand Down Expand Up @@ -182,6 +184,7 @@ const ValuesMarquee = () => {
pairing={pairing}
separatorClass="bg-accent-a"
className="group/item bg-blue-100 text-blue-600 hover:bg-blue-600 hover:text-white dark:hover:bg-blue-700"
eventCategory={eventCategory}
>
<FaCheck className="me-1 text-success group-hover/item:text-white" />
{pairing.ethereum.label}
Expand All @@ -202,6 +205,7 @@ const ValuesMarquee = () => {
pairing={pairing}
className="bg-gray-200/20 text-body-medium hover:bg-gray-600 hover:text-white dark:bg-gray-950 dark:text-body"
separatorClass="bg-gray-200 dark:bg-gray-950"
eventCategory={eventCategory}
>
{pairing.legacy.label}
</Item>
Expand Down
3 changes: 3 additions & 0 deletions src/components/Homepage/useHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const useHome = () => {

const { direction, isRtl } = useRtlFlip()

const eventCategory = `Homepage - ${locale}`

const toggleCodeExample = (id: number): void => {
setActiveCode(id)
setModalOpen(true)
Expand Down Expand Up @@ -222,5 +224,6 @@ export const useHome = () => {
upcomingEvents,
joinActions,
bentoItems,
eventCategory,
}
}
6 changes: 5 additions & 1 deletion src/components/Homepage/useValuesMarquee.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRouter } from "next/router"
import { useTranslation } from "next-i18next"

type Item = {
Expand All @@ -12,6 +13,7 @@ export type Pairing = {

export const useValuesMarquee = () => {
const { t } = useTranslation("page-index")
const { locale } = useRouter()
const pairings: Pairing[] = [
{
legacy: {
Expand Down Expand Up @@ -94,5 +96,7 @@ export const useValuesMarquee = () => {
},
]

return { t, pairings }
const eventCategory = `Homepage - ${locale}`

return { t, pairings, eventCategory }
}
35 changes: 19 additions & 16 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const HomePage = ({
upcomingEvents,
joinActions,
bentoItems,
eventCategory,
} = useHome()

const { onCopy, hasCopied } = useClipboard()
Expand Down Expand Up @@ -225,7 +226,7 @@ const HomePage = ({
href={href}
label={label}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "Top 4 CTAs",
eventName: subHeroCTAs[idx].eventName,
}}
Expand Down Expand Up @@ -282,7 +283,7 @@ const HomePage = ({
effect="cards"
onSlideChange={({ activeIndex }) => {
trackCustomEvent({
eventCategory: "Homepage",
eventCategory,
eventAction: "mobile use cases",
eventName: `swipe to card ${activeIndex + 1}`,
})
Expand All @@ -295,6 +296,7 @@ const HomePage = ({
{...item}
className={cn(className, "bg-background text-body")}
imgWidth={undefined} // Intentionally last to override box
eventCategory={eventCategory}
/>
</SwiperSlide>
))}
Expand All @@ -307,6 +309,7 @@ const HomePage = ({
key={item.title}
{...item}
className={cn(className, "max-lg:hidden")} // Desktop only
eventCategory={eventCategory}
/>
))}
</Section>
Expand Down Expand Up @@ -368,7 +371,7 @@ const HomePage = ({
className
)}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "popular topics",
eventName,
}}
Expand All @@ -388,7 +391,7 @@ const HomePage = ({
isSecondary
className="max-sm:self-start"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "learn",
eventName: "learn",
}}
Expand Down Expand Up @@ -425,7 +428,7 @@ const HomePage = ({
size="lg"
className="w-fit"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "builders",
eventName: "developers",
}}
Expand All @@ -440,7 +443,7 @@ const HomePage = ({
isSecondary
className="w-fit"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "builders",
eventName: "dev docs",
}}
Expand All @@ -466,7 +469,7 @@ const HomePage = ({
onClick={() => {
toggleCodeExample(idx)
trackCustomEvent({
eventCategory: "Homepage",
eventCategory,
eventAction: "Code Examples",
eventName,
})
Expand Down Expand Up @@ -570,7 +573,7 @@ const HomePage = ({
href="/community/"
size="lg"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "community",
eventName: "community",
}}
Expand All @@ -585,7 +588,7 @@ const HomePage = ({
isSecondary
hideArrow
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "community",
eventName: "discord",
}}
Expand All @@ -599,7 +602,7 @@ const HomePage = ({
isSecondary
hideArrow
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "community",
eventName: "github",
}}
Expand All @@ -616,7 +619,7 @@ const HomePage = ({
{calendar.length > 0 ? (
calendar.map(({ date, title, calendarLink }) => {
const customEventOptions = {
eventCategory: "Homepage",
eventCategory,
eventAction: "Community Events Widget",
eventName: "upcoming",
}
Expand Down Expand Up @@ -694,7 +697,7 @@ const HomePage = ({
<Card
href={link}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "blogs_posts",
eventName: source,
}}
Expand Down Expand Up @@ -731,7 +734,7 @@ const HomePage = ({
href={href}
key={name}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "blogs_read_more",
eventName: name!,
}}
Expand Down Expand Up @@ -771,7 +774,7 @@ const HomePage = ({
idx === 0 && "col-span-1 sm:col-span-2 md:col-span-1"
)}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "posts",
eventName: title,
}}
Expand Down Expand Up @@ -816,7 +819,7 @@ const HomePage = ({
href="/community/events/"
size="lg"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "events",
eventName: "community events",
}}
Expand Down Expand Up @@ -851,7 +854,7 @@ const HomePage = ({
className={cn("max-w-screen-sm", className)}
variant="row"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "join",
eventName,
}}
Expand Down

0 comments on commit 0c8e7fc

Please sign in to comment.