@@ -4,6 +4,8 @@ import {ReactNode, useCallback, useEffect, useRef, useState} from 'react';
4
4
import { ChevronDownIcon , ChevronRightIcon } from '@radix-ui/react-icons' ;
5
5
import * as Sentry from '@sentry/nextjs' ;
6
6
7
+ import { usePlausibleEvent } from 'sentry-docs/hooks/usePlausibleEvent' ;
8
+
7
9
// explicitly not usig CSS modules here
8
10
// because there's some prerendered content that depends on these exact class names
9
11
import '../callout/styles.scss' ;
@@ -39,6 +41,7 @@ export function Expandable({
39
41
const [ isExpanded , setIsExpanded ] = useState ( false ) ;
40
42
const [ copied , setCopied ] = useState ( false ) ;
41
43
const contentRef = useRef < HTMLDivElement > ( null ) ;
44
+ const { emit} = usePlausibleEvent ( ) ;
42
45
43
46
// Ensure we scroll to the element if the URL hash matches
44
47
useEffect ( ( ) => {
@@ -75,6 +78,8 @@ export function Expandable({
75
78
return ;
76
79
}
77
80
81
+ emit ( 'Copy Expandable Content' , { props : { page : window . location . pathname , title} } ) ;
82
+
78
83
// Attempt to get text from markdown code blocks if they exist
79
84
const codeBlocks = contentRef . current . querySelectorAll ( 'code' ) ;
80
85
let contentToCopy = '' ;
@@ -110,13 +115,17 @@ export function Expandable({
110
115
setCopied ( false ) ;
111
116
}
112
117
} ,
113
- [ ]
118
+ [ emit , title ]
114
119
) ;
115
120
116
121
function toggleIsExpanded ( event : React . MouseEvent < HTMLDetailsElement > ) {
117
122
const newVal = event . currentTarget . open ;
118
123
setIsExpanded ( newVal ) ;
119
124
125
+ if ( newVal ) {
126
+ emit ( 'Open Expandable' , { props : { page : window . location . pathname , title} } ) ;
127
+ }
128
+
120
129
if ( id ) {
121
130
if ( newVal ) {
122
131
window . history . pushState ( { } , '' , `#${ id } ` ) ;
0 commit comments