Files
supabase/apps/docs/hooks/useDocsCommandMenuTelemetry.ts
2026-03-12 14:34:55 +01:00

30 lines
690 B
TypeScript

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