From d11b9e8aee5a66d2e5b22148f3b65fd7b549d8d8 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Wed, 8 Jan 2025 14:18:12 +0100 Subject: [PATCH] feat(SW-395): Added tracking to header and footer --- .../Footer/Details/SocialLink/index.tsx | 29 +++++++++++++++++++ components/Footer/Details/index.tsx | 24 ++------------- .../Footer/Navigation/MainNav/index.tsx | 5 +++- .../Footer/Navigation/SecondaryNav/index.tsx | 29 +++++++++++-------- components/LoginButton/index.tsx | 4 +-- types/components/footer/socialLink.ts | 6 ++++ utils/tracking.ts | 24 +++++++++++++-- 7 files changed, 83 insertions(+), 38 deletions(-) create mode 100644 components/Footer/Details/SocialLink/index.tsx create mode 100644 types/components/footer/socialLink.ts diff --git a/components/Footer/Details/SocialLink/index.tsx b/components/Footer/Details/SocialLink/index.tsx new file mode 100644 index 000000000..2303c7a24 --- /dev/null +++ b/components/Footer/Details/SocialLink/index.tsx @@ -0,0 +1,29 @@ +"use client" + +import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name" +import { trackSocialMediaClick } from "@/utils/tracking" + +import type { SocialIconsProps } from "@/types/components/footer/socialIcons" +import type { SocialLinkProps } from "@/types/components/footer/socialLink" +import type { IconName } from "@/types/components/icon" + +function SocialIcon({ iconName }: SocialIconsProps) { + const SocialIcon = getIconByIconName(iconName as IconName) + return SocialIcon ? : {iconName} +} + +export default function SocialLink({ link }: SocialLinkProps) { + const { href, title } = link + return ( + trackSocialMediaClick(title)} + > + + + ) +} diff --git a/components/Footer/Details/index.tsx b/components/Footer/Details/index.tsx index 7827f6043..2471fafca 100644 --- a/components/Footer/Details/index.tsx +++ b/components/Footer/Details/index.tsx @@ -1,6 +1,5 @@ import { getFooter, getLanguageSwitcher } from "@/lib/trpc/memoizedRequests" -import { getIconByIconName } from "@/components/Icons/get-icon-by-icon-name" import Image from "@/components/Image" import LanguageSwitcher from "@/components/LanguageSwitcher" import SkeletonShimmer from "@/components/SkeletonShimmer" @@ -9,16 +8,10 @@ import Footnote from "@/components/TempDesignSystem/Text/Footnote" import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" +import SocialLink from "./SocialLink" + import styles from "./details.module.css" -import type { SocialIconsProps } from "@/types/components/footer/socialIcons" -import type { IconName } from "@/types/components/icon" - -function SocialIcon({ iconName }: SocialIconsProps) { - const SocialIcon = getIconByIconName(iconName as IconName) - return SocialIcon ? : {iconName} -} - export default async function FooterDetails() { const lang = getLang() const intl = await getIntl() @@ -40,18 +33,7 @@ export default async function FooterDetails() { diff --git a/components/Footer/Navigation/MainNav/index.tsx b/components/Footer/Navigation/MainNav/index.tsx index d9b499603..6e7b4a861 100644 --- a/components/Footer/Navigation/MainNav/index.tsx +++ b/components/Footer/Navigation/MainNav/index.tsx @@ -1,7 +1,10 @@ +"use client" + import { ArrowRightIcon } from "@/components/Icons" import SkeletonShimmer from "@/components/SkeletonShimmer" import Link from "@/components/TempDesignSystem/Link" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" +import { trackFooterClick } from "@/utils/tracking" import styles from "./mainnav.module.css" @@ -19,9 +22,9 @@ export default function FooterMainNav({ mainLinks }: FooterMainNavProps) { href={link.url} className={styles.mainNavigationLink} target={link.openInNewTab ? "_blank" : undefined} + onClick={() => trackFooterClick("main", link.title)} > {link.title} - diff --git a/components/Footer/Navigation/SecondaryNav/index.tsx b/components/Footer/Navigation/SecondaryNav/index.tsx index 1af85c16c..e65a34c53 100644 --- a/components/Footer/Navigation/SecondaryNav/index.tsx +++ b/components/Footer/Navigation/SecondaryNav/index.tsx @@ -1,8 +1,11 @@ +"use client" + import Image from "@/components/Image" import SkeletonShimmer from "@/components/SkeletonShimmer" import Link from "@/components/TempDesignSystem/Link" import Caption from "@/components/TempDesignSystem/Text/Caption" -import { getLang } from "@/i18n/serverContext" +import useLang from "@/hooks/useLang" +import { trackFooterClick, trackSocialMediaClick } from "@/utils/tracking" import styles from "./secondarynav.module.css" @@ -13,7 +16,7 @@ export default function FooterSecondaryNav({ secondaryLinks, appDownloads, }: FooterSecondaryNavProps) { - const lang = getLang() + const lang = useLang() return (
@@ -28,18 +31,19 @@ export default function FooterSecondaryNav({