File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 33import { Fragment , useEffect } from 'react' ;
44import { useSearchParams } from 'next/navigation' ;
55
6+ import { usePlausibleEvent } from 'sentry-docs/hooks/usePlausibleEvent' ;
7+
68export default function AskAiSearchParams ( ) {
79 const searchParams = useSearchParams ( ) ;
10+ const { emit} = usePlausibleEvent ( ) ;
811
912 useEffect ( ( ) => {
1013 const askAi = searchParams ?. get ( 'askAI' ) ;
@@ -13,11 +16,16 @@ export default function AskAiSearchParams() {
1316 if ( window . Kapa ?. open && askAi === 'true' ) {
1417 // open kapa modal
1518 window . Kapa . open ( { } ) ;
19+ if ( searchParams ?. get ( 'referrer' ) ) {
20+ emit ( 'Ask AI Referrer' , {
21+ props : { referrer : searchParams . get ( 'referrer' ) ?? '' } ,
22+ } ) ;
23+ }
1624 }
1725 } , 300 ) ;
1826
1927 return ( ) => clearTimeout ( timer ) ;
20- } , [ searchParams ] ) ;
28+ } , [ searchParams , emit ] ) ;
2129
2230 return < Fragment /> ;
2331}
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import {ReadProgressMilestone} from 'sentry-docs/types/plausible';
44
55// Adding custom events here will make them available via the hook
66type PlausibleEventProps = {
7+ [ 'Ask AI Referrer' ] : {
8+ referrer : string ;
9+ } ;
710 [ 'Copy Expandable Content' ] : {
811 page : string ;
912 title : string ;
You can’t perform that action at this time.
0 commit comments