diff --git a/src/components/askAiSearchParams.tsx b/src/components/askAiSearchParams.tsx index 180528b276e08..17a75e9eb1945 100644 --- a/src/components/askAiSearchParams.tsx +++ b/src/components/askAiSearchParams.tsx @@ -3,8 +3,11 @@ import {Fragment, useEffect} from 'react'; import {useSearchParams} from 'next/navigation'; +import {usePlausibleEvent} from 'sentry-docs/hooks/usePlausibleEvent'; + export default function AskAiSearchParams() { const searchParams = useSearchParams(); + const {emit} = usePlausibleEvent(); useEffect(() => { const askAi = searchParams?.get('askAI'); @@ -13,11 +16,16 @@ export default function AskAiSearchParams() { if (window.Kapa?.open && askAi === 'true') { // open kapa modal window.Kapa.open({}); + if (searchParams?.get('referrer')) { + emit('Ask AI Referrer', { + props: {referrer: searchParams.get('referrer') ?? ''}, + }); + } } }, 300); return () => clearTimeout(timer); - }, [searchParams]); + }, [searchParams, emit]); return ; } diff --git a/src/hooks/usePlausibleEvent.tsx b/src/hooks/usePlausibleEvent.tsx index d4a3d06341ff1..aeeac51454907 100644 --- a/src/hooks/usePlausibleEvent.tsx +++ b/src/hooks/usePlausibleEvent.tsx @@ -4,6 +4,9 @@ import {ReadProgressMilestone} from 'sentry-docs/types/plausible'; // Adding custom events here will make them available via the hook type PlausibleEventProps = { + ['Ask AI Referrer']: { + referrer: string; + }; ['Copy Expandable Content']: { page: string; title: string;