@@ -4,13 +4,13 @@ import React, { useEffect, useMemo, useRef, useState } from "react"
44import clsx from "clsx"
55import { Highlight , HighlightProps , themes , Token } from "prism-react-renderer"
66import { ApiRunner } from "@/components"
7- import { useColorMode } from "@/providers"
7+ import { useAnalytics , useColorMode } from "@/providers"
88import { CodeBlockHeader , CodeBlockHeaderMeta } from "./Header"
99import { CodeBlockLine } from "./Line"
1010import { ApiAuthType , ApiDataOptions , ApiMethod } from "types"
1111// @ts -expect-error can't install the types package because it doesn't support React v19
1212import { CSSTransition } from "react-transition-group"
13- import { useCollapsibleCodeLines } from "../.."
13+ import { DocsTrackingEvents , useCollapsibleCodeLines } from "../.."
1414import { HighlightProps as CollapsibleHighlightProps } from "@/hooks"
1515import { CodeBlockActions , CodeBlockActionsProps } from "./Actions"
1616import { CodeBlockCollapsibleButton } from "./Collapsible/Button"
@@ -103,6 +103,7 @@ export const CodeBlock = ({
103103 }
104104
105105 const { colorMode } = useColorMode ( )
106+ const { track } = useAnalytics ( )
106107 const [ showTesting , setShowTesting ] = useState ( false )
107108 const codeContainerRef = useRef < HTMLDivElement > ( null )
108109 const codeRef = useRef < HTMLElement > ( null )
@@ -296,6 +297,14 @@ export const CodeBlock = ({
296297 )
297298 } , [ codeContainerRef . current , codeRef . current ] )
298299
300+ const trackCopy = ( ) => {
301+ track ( {
302+ event : {
303+ event : DocsTrackingEvents . CODE_BLOCK_COPY ,
304+ } ,
305+ } )
306+ }
307+
299308 const actionsProps : Omit < CodeBlockActionsProps , "inHeader" > = useMemo (
300309 ( ) => ( {
301310 source,
@@ -435,6 +444,7 @@ export const CodeBlock = ({
435444 "pl-docs_1" ,
436445 preClassName
437446 ) }
447+ onCopy = { trackCopy }
438448 >
439449 < code
440450 className = { clsx (
0 commit comments