@@ -4,6 +4,8 @@ import {ReactNode, useCallback, useEffect, useRef, useState} from 'react';
44import { ChevronDownIcon , ChevronRightIcon } from '@radix-ui/react-icons' ;
55import * as Sentry from '@sentry/nextjs' ;
66
7+ import { usePlausibleEvent } from 'sentry-docs/hooks/usePlausibleEvent' ;
8+
79// explicitly not usig CSS modules here
810// because there's some prerendered content that depends on these exact class names
911import '../callout/styles.scss' ;
@@ -39,6 +41,7 @@ export function Expandable({
3941 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
4042 const [ copied , setCopied ] = useState ( false ) ;
4143 const contentRef = useRef < HTMLDivElement > ( null ) ;
44+ const { emit} = usePlausibleEvent ( ) ;
4245
4346 // Ensure we scroll to the element if the URL hash matches
4447 useEffect ( ( ) => {
@@ -75,6 +78,8 @@ export function Expandable({
7578 return ;
7679 }
7780
81+ emit ( 'Copy Expandable Content' , { props : { page : window . location . pathname , title} } ) ;
82+
7883 // Attempt to get text from markdown code blocks if they exist
7984 const codeBlocks = contentRef . current . querySelectorAll ( 'code' ) ;
8085 let contentToCopy = '' ;
@@ -110,13 +115,17 @@ export function Expandable({
110115 setCopied ( false ) ;
111116 }
112117 } ,
113- [ ]
118+ [ emit , title ]
114119 ) ;
115120
116121 function toggleIsExpanded ( event : React . MouseEvent < HTMLDetailsElement > ) {
117122 const newVal = event . currentTarget . open ;
118123 setIsExpanded ( newVal ) ;
119124
125+ if ( newVal ) {
126+ emit ( 'Open Expandable' , { props : { page : window . location . pathname , title} } ) ;
127+ }
128+
120129 if ( id ) {
121130 if ( newVal ) {
122131 window . history . pushState ( { } , '' , `#${ id } ` ) ;
0 commit comments