Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(docs): track mouse clicks on Search V2 results (GROWTH-1331) (#51542)

claude[bot]132375e0ca95
diff --git a/apps/docs/features/SearchV2/SearchV2Dialog.tsx b/apps/docs/features/SearchV2/SearchV2Dialog.tsx
index dba642f0f86..67cfde97255 100644
--- a/apps/docs/features/SearchV2/SearchV2Dialog.tsx
+++ b/apps/docs/features/SearchV2/SearchV2Dialog.tsx
@@ -120,14 +120,6 @@ function SearchV2Panel({ onResultSelect, onResultOpen }: SearchV2PanelProps) {
}
}
- function handleSelect(path: string) {
- sendTelemetryEvent({
- action: 'docs_search_v2_result_clicked',
- properties: { resultPath: path, query: highlightQuery },
- })
- onResultSelect(path)
- }
-
// Announced via the aria-live region below — a sighted user sees the spinner/list update,
// but a screen reader user gets no equivalent signal unless we say so explicitly. Also covers
// the result count, which isn't reliably announced by the listbox/option roles alone.
@@ -197,7 +189,7 @@ function SearchV2Panel({ onResultSelect, onResultOpen }: SearchV2PanelProps) {
key={result.path}
result={result}
highlightQuery={highlightQuery}
- onResultSelect={handleSelect}
+ onResultSelect={onResultSelect}
onResultOpen={onResultOpen}
/>
))}
diff --git a/apps/docs/features/SearchV2/SearchV2Result.tsx b/apps/docs/features/SearchV2/SearchV2Result.tsx
index d19147e9d8c..38ff3603105 100644
--- a/apps/docs/features/SearchV2/SearchV2Result.tsx
+++ b/apps/docs/features/SearchV2/SearchV2Result.tsx
@@ -6,6 +6,7 @@ import { useRef, type MouseEvent } from 'react'
import { CommandItem } from 'ui'
import { formatHeadingPath, highlightMatches } from './SearchV2.utils'
+import { useSendTelemetryEvent } from '@/lib/telemetry'
interface SearchV2ResultProps {
result: DocsSearchV2Result
@@ -20,6 +21,7 @@ export function SearchV2Result({
onResultSelect,
onResultOpen,
}: SearchV2ResultProps) {
+ const sendTelemetryEvent = useSendTelemetryEvent()
// clicks navigate via the link and also fire onSelect, so onSelect only navigates for Enter
const isPointerSelectRef = useRef(false)
@@ -30,6 +32,10 @@ export function SearchV2Result({
}
function handleSelect() {
+ sendTelemetryEvent({
+ action: 'docs_search_v2_result_clicked',
+ properties: { resultPath: result.path, query: highlightQuery },
+ })
if (isPointerSelectRef.current) {
isPointerSelectRef.current = false
return