@@ -4,6 +4,8 @@ import { Translate } from 'i18n';
44import { PageTemplate } from 'components/template' ;
55import styled from 'styled-components' ;
66
7+ import * as gtag from 'lib/gtag' ;
8+
79const Image = styled ( NextImage ) `
810 border-radius: 50%;
911 box-shadow: 4px 4px 5px 0px rgba(0, 0, 0, 0.5);
@@ -43,6 +45,20 @@ const socialMedias = {
4345 link : 'https://linkedin.com/in/luis-takahashi' ,
4446 } ,
4547} ;
48+ type SocialMedia = {
49+ alt : string ;
50+ src : string ;
51+ link : string ;
52+ } ;
53+ type SocialMediaKey = keyof typeof socialMedias ;
54+
55+ const handleSocialMediaClick = ( socialMedia : SocialMediaKey ) => ( ) => {
56+ gtag . event ( {
57+ action : 'social_click' ,
58+ category : 'Social media' ,
59+ label : socialMedia ,
60+ } ) ;
61+ } ;
4662
4763type HomeProps = {
4864 t : Translate ;
@@ -59,16 +75,19 @@ const Home: NextPage<HomeProps> = ({ t }) => (
5975 style = { { margin : 'auto' } }
6076 />
6177 < ImageContainer >
62- { Object . entries ( socialMedias ) . map ( ( [ socialMedia , { alt, src, link } ] ) => (
63- < a
64- key = { socialMedia }
65- href = { link }
66- target = "_blank"
67- rel = "noreferrer noreferrer"
68- >
69- < img src = { src } alt = { alt } width = { 20 } height = { 20 } />
70- </ a >
71- ) ) }
78+ { Object . entries ( socialMedias ) . map (
79+ ( [ socialMedia , { alt, src, link } ] : [ SocialMediaKey , SocialMedia ] ) => (
80+ < a
81+ key = { socialMedia }
82+ href = { link }
83+ target = "_blank"
84+ rel = "noreferrer noreferrer"
85+ onClick = { handleSocialMediaClick ( socialMedia ) }
86+ >
87+ < img src = { src } alt = { alt } width = { 20 } height = { 20 } />
88+ </ a >
89+ )
90+ ) }
7291 </ ImageContainer >
7392 </ PageTemplate >
7493) ;
0 commit comments