Skip to content

Commit f5494ea

Browse files
authored
Merge pull request #294 from JEOLLOGA/feat/#292/event-logging
[FEAT] ํ™ˆํŽ˜์ด์ง€ ์ด๋ฒคํŠธ ๋กœ๊น… ์ถ”๊ฐ€
2 parents 038a175 + 20dfd21 commit f5494ea

File tree

8 files changed

+38
-5
lines changed

8 files changed

+38
-5
lines changed

โ€Ž.gitignoreโ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ dist-ssr
2626
*storybook.log
2727

2828
.env
29+
30+
.next
31+
next-env.d.ts
32+
dist

โ€Žsrc/components/card/popularCard/PopularCard.tsxโ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface PopularCardProps {
1313
isLiked?: boolean;
1414
onLikeToggle: (liked: boolean) => void;
1515
link: string;
16+
onClick: () => void;
1617
}
1718

1819
const PopularCard = ({
@@ -24,6 +25,7 @@ const PopularCard = ({
2425
isLiked = false,
2526
onLikeToggle,
2627
link,
28+
onClick,
2729
}: PopularCardProps) => {
2830
const [liked, setLiked] = useState(isLiked);
2931

@@ -42,7 +44,7 @@ const PopularCard = ({
4244
};
4345

4446
return (
45-
<a href={link} className={styles.cardWrapper}>
47+
<a href={link} className={styles.cardWrapper} onClick={onClick}>
4648
<div>
4749
<div className={styles.imgBox} style={{ backgroundImage: `url(${templeImg})` }}>
4850
<RankBtn ranking={ranking} />

โ€Žsrc/components/card/templeStayCard/TempleStayCard.tsxโ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ const TempleStayCard = ({
6666
<a
6767
href={link}
6868
className={isHorizontal ? styles.horizontalContainer : styles.verticalContainer}
69-
onClick={() => logClickEvent('click_card_detail')}>
69+
onClick={() =>
70+
logClickEvent('click_card_detail', {
71+
label: String(templestayId),
72+
})
73+
}>
7074
{imgUrl ? (
7175
<section className={isHorizontal ? styles.horizontalImgSection : styles.verticalImgSection}>
7276
<img

โ€Žsrc/components/carousel/curationCarousel/CurationCarousel.tsxโ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import CurationCard from '@components/curation/curationCard/CurationCard';
22
import { CURATION_INFO } from '@constants/curationInfo';
33
import useCarousel from '@hooks/useCarousel';
44
import registDragEvent from '@utils/registDragEvent';
5+
import useEventLogger from 'src/gtm/hooks/useEventLogger';
56

67
import * as styles from './curationCarousel.css';
78

@@ -11,6 +12,8 @@ const CurationCarousel = () => {
1112
moveDistance: 295,
1213
});
1314

15+
const { logClickEvent } = useEventLogger('home_pick');
16+
1417
return (
1518
<section ref={carouselRef} className={styles.carouselWrapper}>
1619
<div className={styles.emptyBox} />
@@ -28,6 +31,11 @@ const CurationCarousel = () => {
2831
title={data.title}
2932
subtitle={data.subtitle}
3033
link={`/curation/${index + 1}`}
34+
onClick={() => {
35+
logClickEvent('click_curation_card', {
36+
label: index + 1,
37+
});
38+
}}
3139
/>
3240
))}
3341
</div>

โ€Žsrc/components/carousel/popularCarousel/PopularCarousel.tsxโ€Ž

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ExceptLayout from '@components/except/exceptLayout/ExceptLayout';
66
import useCarousel from '@hooks/useCarousel';
77
import { useQueryClient } from '@tanstack/react-query';
88
import registDragEvent from '@utils/registDragEvent';
9+
import useEventLogger from 'src/gtm/hooks/useEventLogger';
910

1011
import * as styles from './popularCarousel.css';
1112

@@ -28,6 +29,8 @@ const PopularCarousel = ({ onRequireLogin }: PopularCarouselProps) => {
2829
moveDistance: 355,
2930
});
3031

32+
const { logClickEvent } = useEventLogger('home_popularity_component');
33+
3134
if (isLoading) {
3235
return <ExceptLayout type="loading" />;
3336
}
@@ -65,7 +68,7 @@ const PopularCarousel = ({ onRequireLogin }: PopularCarouselProps) => {
6568
onDragEnd: handleDragEnd,
6669
})}>
6770
{data?.rankings &&
68-
data.rankings.map((rankings) => (
71+
data.rankings.map((rankings, index) => (
6972
<PopularCard
7073
key={rankings.templestayId}
7174
ranking={rankings.ranking}
@@ -76,6 +79,11 @@ const PopularCarousel = ({ onRequireLogin }: PopularCarouselProps) => {
7679
tag={rankings.tag}
7780
onLikeToggle={(liked: boolean) => handleLikeToggle(rankings.templestayId, liked)}
7881
link={`/detail/${rankings.templestayId}`}
82+
onClick={() => {
83+
logClickEvent('click_popularity_card', {
84+
label: index + 1,
85+
});
86+
}}
7987
/>
8088
))}
8189
</div>

โ€Žsrc/components/curation/curationCard/CurationCard.tsxโ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ interface CurationCardProps {
55
title: string;
66
subtitle: string;
77
link: string;
8+
onClick: () => void;
89
}
910

10-
const CurationCard = ({ bgImage, title, subtitle, link }: CurationCardProps) => {
11+
const CurationCard = ({ bgImage, title, subtitle, link, onClick }: CurationCardProps) => {
1112
return (
12-
<a href={link} className={styles.cardContainer} style={{ backgroundImage: `url(${bgImage})` }}>
13+
<a
14+
href={link}
15+
className={styles.cardContainer}
16+
style={{ backgroundImage: `url(${bgImage})` }}
17+
onClick={onClick}>
1318
<div className={styles.textbox}>
1419
<p className={styles.title}>{title}</p>
1520
<p className={styles.subtitle}>{subtitle}</p>

โ€Žsrc/stories/CurationCard.stories.tsโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const meta = {
2424
title: '๊ณ ์–‘์ด ์žˆ๋Š” ์ ˆ ๋ดค์–ด?',
2525
subtitle: '์šฉ๋ฌธ์‚ฌ์— ์žˆ๋Š” ๊ณ ์–‘์ด ์ข€ ๋ด. ๊ท€์—ฝ์ง€?',
2626
link: 'https://www.gototemplestay.com/',
27+
onClick: () => {},
2728
},
2829
} satisfies Meta<typeof CurationCard>;
2930

โ€Žsrc/stories/PopularCard.stories.tsโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const meta = {
4242
link: 'https://www.gototemplestay.com/',
4343
isLiked: false,
4444
onLikeToggle: () => alert('Liked'),
45+
onClick: () => {},
4546
},
4647
} satisfies Meta<typeof PopularCard>;
4748

0 commit comments

Comments
ย (0)