Skip to content

Commit 5c9184b

Browse files
authored
Merge pull request #12511 from ethereum/glossary-tooltip-matomo
feat: add matomo event to glossary tooltip
2 parents 85a47d5 + 09e12f7 commit 5c9184b

File tree

1 file changed

+13
-0
lines changed
  • src/components/Glossary/GlossaryTooltip

1 file changed

+13
-0
lines changed

src/components/Glossary/GlossaryTooltip/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import React, { ReactNode } from "react"
2+
import { useRouter } from "next/router"
23
import { Box, Text } from "@chakra-ui/react"
34

45
import GlossaryDefinition from "@/components/Glossary/GlossaryDefinition"
56
import Tooltip from "@/components/Tooltip"
67

8+
import { trackCustomEvent } from "@/lib/utils/matomo"
9+
import { cleanPath } from "@/lib/utils/url"
10+
711
type GlossaryTooltipProps = {
812
children: ReactNode
913
termKey: string
1014
}
1115

1216
const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => {
17+
const { asPath } = useRouter()
18+
1319
return (
1420
<Box display="inline-block">
1521
<Tooltip
@@ -20,6 +26,13 @@ const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => {
2026
options={{ ns: "glossary-tooltip" }}
2127
/>
2228
}
29+
onOpen={() => {
30+
trackCustomEvent({
31+
eventCategory: "Glossary Tooltip",
32+
eventAction: cleanPath(asPath),
33+
eventName: termKey,
34+
})
35+
}}
2336
>
2437
<Text
2538
as="u"

0 commit comments

Comments
 (0)