Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(matomo): Add missing homepage events; parse events by locale #13954

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 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 @@ -127,28 +129,33 @@ export const useHome = () => {
label: t("page-index:page-index-popular-topics-ethereum"),
Svg: EthTokenIcon,
href: "/what-is-ethereum/",
eventName: "ethereum",
},
{
label: t("page-index:page-index-popular-topics-wallets"),
Svg: PickWalletIcon,
href: "/wallets/",
eventName: "wallets",
},
{
label: t("page-index:page-index-popular-topics-start"),
Svg: BlockHeap,
href: "/guides/",
eventName: "start guides",
},
{
label: t("page-index:page-index-popular-topics-whitepaper"),
Svg: Whitepaper,
className: cn(isRtl && "[&_svg]:-scale-x-100"),
href: "/whitepaper/",
eventName: "whitepaper",
},
{
label: t("page-index:page-index-popular-topics-roadmap"),
Svg: RoadmapSign,
className: cn(isRtl && "[&_svg]:-scale-x-100"),
href: "/roadmap/",
eventName: "roadmap",
},
]

Expand Down Expand Up @@ -217,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 }
}
70 changes: 40 additions & 30 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 @@ -357,21 +360,28 @@ const HomePage = ({
{t("page-index:page-index-popular-topics-header")}
</h3>
<div className="grid grid-cols-1 gap-8 sm:grid-cols-2 md:grid-cols-1 lg:grid-cols-2">
{popularTopics.map(({ label, Svg, href, className }) => (
<SvgButtonLink
key={label}
Svg={Svg}
href={href}
className={cn(
"text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row",
className
)}
>
<p className="text-start text-xl font-bold text-body group-hover:underline">
{label}
</p>
</SvgButtonLink>
))}
{popularTopics.map(
({ label, Svg, href, eventName, className }) => (
<SvgButtonLink
key={label}
Svg={Svg}
href={href}
className={cn(
"text-accent-b hover:text-accent-b-hover [&>:first-child]:flex-row",
className
)}
customEventOptions={{
eventCategory,
eventAction: "popular topics",
eventName,
}}
>
<p className="text-start text-xl font-bold text-body group-hover:underline">
{label}
</p>
</SvgButtonLink>
)
)}
</div>
<div className="flex py-8 sm:justify-center">
<ButtonLink
Expand All @@ -381,7 +391,7 @@ const HomePage = ({
isSecondary
className="max-sm:self-start"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "learn",
eventName: "learn",
}}
Expand Down Expand Up @@ -418,7 +428,7 @@ const HomePage = ({
size="lg"
className="w-fit"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "builders",
eventName: "developers",
}}
Expand All @@ -433,7 +443,7 @@ const HomePage = ({
isSecondary
className="w-fit"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "builders",
eventName: "dev docs",
}}
Expand All @@ -459,7 +469,7 @@ const HomePage = ({
onClick={() => {
toggleCodeExample(idx)
trackCustomEvent({
eventCategory: "Homepage",
eventCategory,
eventAction: "Code Examples",
eventName,
})
Expand Down Expand Up @@ -563,7 +573,7 @@ const HomePage = ({
href="/community/"
size="lg"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "community",
eventName: "community",
}}
Expand All @@ -578,7 +588,7 @@ const HomePage = ({
isSecondary
hideArrow
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "community",
eventName: "discord",
}}
Expand All @@ -592,7 +602,7 @@ const HomePage = ({
isSecondary
hideArrow
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "community",
eventName: "github",
}}
Expand All @@ -609,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 @@ -687,7 +697,7 @@ const HomePage = ({
<Card
href={link}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "blogs_posts",
eventName: source,
}}
Expand Down Expand Up @@ -724,7 +734,7 @@ const HomePage = ({
href={href}
key={name}
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "blogs_read_more",
eventName: name!,
}}
Expand Down Expand Up @@ -764,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 @@ -809,7 +819,7 @@ const HomePage = ({
href="/community/events/"
size="lg"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "events",
eventName: "community events",
}}
Expand Down Expand Up @@ -844,7 +854,7 @@ const HomePage = ({
className={cn("max-w-screen-sm", className)}
variant="row"
customEventOptions={{
eventCategory: "Homepage",
eventCategory,
eventAction: "join",
eventName,
}}
Expand Down
Loading