@@ -3,8 +3,9 @@ import * as React from 'react';
33import { RouterLink } from '../../../../../components' ;
44import { getMediaImage } from '../../../../../components/Media/Image/utils' ;
55import { LocationContext } from '../../../../../context/locationContext' ;
6+ import { useAnalytics } from '../../../../../hooks' ;
67import { NavigationArrow } from '../../../../../icons' ;
7- import { NavigationLinkItem } from '../../../../../models' ;
8+ import { DefaultEventNames , NavigationLinkItem } from '../../../../../models' ;
89import { block , getLinkProps } from '../../../../../utils' ;
910import { NavigationItemProps } from '../../../../models' ;
1011import { ContentWrapper } from '../ContentWrapper/ContentWrapper' ;
@@ -17,9 +18,26 @@ type NavigationLinkProps = NavigationItemProps & NavigationLinkItem;
1718
1819export const NavigationLink : React . FC < NavigationLinkProps > = ( props ) => {
1920 const { hostname, Link} = React . useContext ( LocationContext ) ;
20- const { url, text, icon, arrow, target, className, iconSize, urlTitle, ...rest } = props ;
21+ const {
22+ url,
23+ text,
24+ icon,
25+ arrow,
26+ target,
27+ className,
28+ iconSize,
29+ urlTitle,
30+ analyticsEvents,
31+ ...rest
32+ } = props ;
33+
2134 const linkExtraProps = getLinkProps ( url , hostname , target ) ;
2235 const iconData = icon && getMediaImage ( icon ) ;
36+ const handleAnalytics = useAnalytics ( DefaultEventNames . Link , url ) ;
37+
38+ const onClick = ( ) => {
39+ handleAnalytics ( analyticsEvents ) ;
40+ } ;
2341
2442 const classes = b ( null , className ) ;
2543 const content = (
@@ -35,6 +53,7 @@ export const NavigationLink: React.FC<NavigationLinkProps> = (props) => {
3553 href = { url }
3654 title = { urlTitle || text }
3755 className = { classes }
56+ onClick = { onClick }
3857 { ...rest }
3958 { ...linkExtraProps }
4059 >
@@ -44,7 +63,15 @@ export const NavigationLink: React.FC<NavigationLinkProps> = (props) => {
4463 } else {
4564 return (
4665 < RouterLink href = { url } passHref >
47- < a title = { urlTitle || text } { ...rest } className = { classes } >
66+ < a
67+ role = "link"
68+ title = { urlTitle || text }
69+ { ...rest }
70+ className = { classes }
71+ tabIndex = { 0 }
72+ onClick = { onClick }
73+ onKeyDown = { ( e ) => e . key === 'Enter' && onClick ( ) }
74+ >
4875 { content }
4976 </ a >
5077 </ RouterLink >
0 commit comments