22
33import { Button } from '@mui/material' ;
44import DownloadIcon from '@mui/icons-material/Download' ;
5+ import { sendGAEvent } from '@next/third-parties/google' ;
56import { useTranslations } from 'next-intl' ;
67
78export default function ClientDownloadButton ( {
@@ -11,13 +12,10 @@ export default function ClientDownloadButton({
1112} ) : React . ReactElement {
1213 const t = useTranslations ( 'feeds' ) ;
1314
14- const handleDownloadLatestClick = async ( ) : Promise < void > => {
15- // Lazy load react-ga4 to avoid loading it unnecessarily
16- const ReactGA = ( await import ( 'react-ga4' ) ) . default ;
17- ReactGA . event ( {
18- category : 'engagement' ,
19- action : 'download_latest_dataset' ,
20- label : 'Download Latest Dataset' ,
15+ const handleDownloadLatestClick = ( ) : void => {
16+ sendGAEvent ( 'event' , 'download_latest_dataset' , {
17+ event_category : 'engagement' ,
18+ event_label : 'Download Latest Dataset' ,
2119 } ) ;
2220 } ;
2321
@@ -30,9 +28,7 @@ export default function ClientDownloadButton({
3028 rel = 'noreferrer nofollow'
3129 id = 'download-latest-button'
3230 endIcon = { < DownloadIcon /> }
33- onClick = { ( ) => {
34- void handleDownloadLatestClick ( ) ;
35- } }
31+ onClick = { handleDownloadLatestClick }
3632 >
3733 { t ( 'downloadLatest' ) }
3834 </ Button >
0 commit comments