1
+ import { useCallback } from 'react'
2
+ import { captureEvent } from '../analytics'
1
3
import { PromotionResponse } from './api'
2
4
3
5
interface Props {
4
6
data : PromotionResponse
5
7
}
6
8
7
9
function Promotion ( { data } : Props ) {
10
+ const capturePromotionClick = useCallback ( ( ) => {
11
+ captureEvent ( 'click_promotion' , { link : data . url } )
12
+ } , [ data . url ] )
13
+
8
14
if ( data . image && ! data . text ) {
9
15
return (
10
- < a href = { data . url } target = "_blank" rel = "noreferrer" className = "mt-5" >
16
+ < a
17
+ href = { data . url }
18
+ target = "_blank"
19
+ rel = "noreferrer"
20
+ className = "mt-5"
21
+ onClick = { capturePromotionClick }
22
+ >
11
23
< img src = { data . image . url } className = "w-full" />
12
24
</ a >
13
25
)
14
26
}
15
27
return (
16
28
< div className = "chat-gpt-card flex flex-row gap-2 mt-5 gpt-promotion" >
17
29
{ ! ! data . image && (
18
- < a href = { data . url } target = "_blank" rel = "noreferrer" >
30
+ < a href = { data . url } target = "_blank" rel = "noreferrer" onClick = { capturePromotionClick } >
19
31
< img
20
32
src = { data . image . url }
21
33
width = { data . image . size || 100 }
@@ -26,22 +38,28 @@ function Promotion({ data }: Props) {
26
38
< div className = "flex flex-col justify-between" >
27
39
< div >
28
40
{ ! ! data . title && (
29
- < a href = { data . url } target = "_blank" rel = "noreferrer" >
41
+ < a href = { data . url } target = "_blank" rel = "noreferrer" onClick = { capturePromotionClick } >
30
42
< p className = "font-bold" > { data . title } </ p >
31
43
</ a >
32
44
) }
33
45
{ ! ! data . text &&
34
46
( data . title ? (
35
47
< p > { data . text } </ p >
36
48
) : (
37
- < a href = { data . url } target = "_blank" rel = "noreferrer" >
49
+ < a href = { data . url } target = "_blank" rel = "noreferrer" onClick = { capturePromotionClick } >
38
50
< p > { data . text } </ p >
39
51
</ a >
40
52
) ) }
41
53
</ div >
42
54
< div className = "flex flex-row justify-between" >
43
55
{ ! ! data . footer && (
44
- < a href = { data . footer . url } target = "_blank" rel = "noreferrer" className = "text-xs" >
56
+ < a
57
+ href = { data . footer . url }
58
+ target = "_blank"
59
+ rel = "noreferrer"
60
+ className = "text-xs"
61
+ onClick = { capturePromotionClick }
62
+ >
45
63
{ data . footer . text }
46
64
</ a >
47
65
) }
@@ -51,6 +69,7 @@ function Promotion({ data }: Props) {
51
69
target = "_blank"
52
70
rel = "noreferrer"
53
71
className = "text-xs rounded-sm border border-solid px-[2px] text-inherit"
72
+ onClick = { capturePromotionClick }
54
73
>
55
74
{ data . label . text }
56
75
</ a >
0 commit comments