Skip to content

Commit

Permalink
Merge pull request #12511 from ethereum/glossary-tooltip-matomo
Browse files Browse the repository at this point in the history
feat: add matomo event to glossary tooltip
  • Loading branch information
pettinarip authored Mar 22, 2024
2 parents 85a47d5 + 09e12f7 commit 5c9184b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/Glossary/GlossaryTooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React, { ReactNode } from "react"
import { useRouter } from "next/router"
import { Box, Text } from "@chakra-ui/react"

import GlossaryDefinition from "@/components/Glossary/GlossaryDefinition"
import Tooltip from "@/components/Tooltip"

import { trackCustomEvent } from "@/lib/utils/matomo"
import { cleanPath } from "@/lib/utils/url"

type GlossaryTooltipProps = {
children: ReactNode
termKey: string
}

const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => {
const { asPath } = useRouter()

return (
<Box display="inline-block">
<Tooltip
Expand All @@ -20,6 +26,13 @@ const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => {
options={{ ns: "glossary-tooltip" }}
/>
}
onOpen={() => {
trackCustomEvent({
eventCategory: "Glossary Tooltip",
eventAction: cleanPath(asPath),
eventName: termKey,
})
}}
>
<Text
as="u"
Expand Down

0 comments on commit 5c9184b

Please sign in to comment.