@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
22import { Link } from "react-router-dom" ;
33import { cls } from "@/utils/cls" ;
44import Indicator from "@/components/Indicator" ;
5+ import { trackEvent } from "@/libs/analytics" ;
56
67interface BannerImage {
78 sm : string ;
@@ -28,12 +29,14 @@ const bannerImages: BannerImage[] = [
2829 md : "/image/home_banner3_md.png" ,
2930 lg : "/image/home_banner3_lg.png" ,
3031 description : "MBTI별 피해야 할 대화스타일 및 주제"
31- } ,
32+ }
3233] ;
3334
3435const Banner = ( ) => {
3536 const [ order , setOrder ] = useState < number > ( 0 ) ;
3637
38+ const bannerEventElements = [ "배너 1" , "배너 2" , "배너 3" ] ;
39+
3740 useEffect ( ( ) => {
3841 const interval = setInterval ( ( ) => {
3942 setOrder ( ( prev ) => ( prev + 1 ) % bannerImages . length ) ;
@@ -43,18 +46,33 @@ const Banner = () => {
4346
4447 return (
4548 < div className = "relative flex h-[184px] w-full" >
46- < Link to = { order === 0 ? "/mbti-test" : `/contents/${ order } ` } className = "absolute w-full h-full" >
49+ < Link
50+ to = { order === 0 ? "/mbti-test" : `/contents/${ order } ` }
51+ className = "absolute h-full w-full"
52+ onClick = { ( ) => {
53+ if ( bannerEventElements [ order ] ) {
54+ trackEvent ( "Click" , {
55+ page : "홈" ,
56+ element : bannerEventElements [ order ]
57+ } ) ;
58+ }
59+ } }
60+ >
4761 { bannerImages . map ( ( image , index ) => (
4862 < picture
4963 key = { index }
5064 className = { cls (
51- "absolute transition-opacity duration-500 w-full h-full " ,
65+ "absolute h-full w-full transition-opacity duration-500 " ,
5266 order === index ? "opacity-100" : "opacity-0"
5367 ) }
5468 >
5569 < source media = "(min-width: 500px)" srcSet = { image . lg } />
5670 < source media = "(min-width: 375px)" srcSet = { image . md } />
57- < img src = { image . sm } alt = { image . description } className = "w-full h-full object-cover" />
71+ < img
72+ src = { image . sm }
73+ alt = { image . description }
74+ className = "h-full w-full object-cover"
75+ />
5876 </ picture >
5977 ) ) }
6078 </ Link >
0 commit comments