Files
supabase/apps/docs/hooks/useDocsCommandMenuTelemetry.ts
2025-10-26 17:01:24 +08:00

29 lines
630 B
TypeScript

'use client'
import { useCallback } from 'react'
import type {
CommandMenuOpenedEvent,
CommandMenuCommandClickedEvent,
CommandMenuSearchSubmittedEvent,
} from 'common/telemetry-constants'
import { useSendTelemetryEvent } from 'lib/telemetry'
export function useDocsCommandMenuTelemetry() {
const sendTelemetryEvent = useSendTelemetryEvent()
const onTelemetry = useCallback(
(
event:
| CommandMenuOpenedEvent
| CommandMenuCommandClickedEvent
| CommandMenuSearchSubmittedEvent
) => {
sendTelemetryEvent(event)
},
[sendTelemetryEvent]
)
return { onTelemetry }
}