Skip to content

Commit

Permalink
feat: add matomo event to glossary tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
wackerow committed Mar 19, 2024
1 parent 8b7f4c3 commit 09e12f7
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 09e12f7

Please sign in to comment.