Skip to content

Commit

Permalink
Merge pull request #507 from audioverse-org/AV-715-Track-Actions-Left…
Browse files Browse the repository at this point in the history
…-side-menu-first-level

Av 715 track actions left side menu first level
  • Loading branch information
jlaverde77 authored Jan 3, 2024
2 parents 44ea08d + 4673977 commit 2811ccb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/components/atoms/activeLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import Link, { LinkProps } from 'next/link';
import { useRouter } from 'next/router';
import React, { ReactElement } from 'react';

import { analytics } from './analytics';

type ActiveLinkProps = LinkProps & {
children: ReactElement;
className?: string;
activeClassName: string;
linkLable?: string;
};

// SOURCE: https://zaiste.net/programming/reactjs/howtos/create-activelink-nextjs/
Expand All @@ -15,6 +18,7 @@ const ActiveLink = ({
children,
className,
activeClassName,
linkLable,
...props
}: ActiveLinkProps): JSX.Element => {
const { asPath } = useRouter();
Expand All @@ -29,6 +33,9 @@ const ActiveLink = ({
<a
className={clsx(className, isActive && activeClassName)}
aria-current={isActive ? 'page' : false}
onClick={() => {
analytics.track('menuClick', { lable: linkLable });
}}
>
{children}
</a>
Expand Down
10 changes: 9 additions & 1 deletion src/components/molecules/navItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import styles from '~components/organisms/navigation.module.scss';
import { INavigationItem } from '~lib/useNavigationItems';
import IconDisclosure from '~public/img/icons/icon-disclosure-light-small.svg';

import { analytics } from '../atoms/analytics';

export default function NavItem({
item,
setSubmenu,
Expand All @@ -29,11 +31,17 @@ export default function NavItem({
href={href}
className={styles.navLink}
activeClassName={styles.active}
linkLable={label}
>
{inner}
</ActiveLink>
) : (
<a className={styles.navLink} onClick={() => setSubmenu(key)}>
<a
className={styles.navLink}
onClick={() => {
analytics.track('menuClick', { link: label }), setSubmenu(key);
}}
>
{inner}
</a>
)}
Expand Down

1 comment on commit 2811ccb

@vercel
Copy link

@vercel vercel bot commented on 2811ccb Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.