Files
supabase/apps/www/lib/telemetry.ts
T
Francesco SansalvadoreandCharis af43adb9a4 chore: command events (#39775)
* add CommandMenuTriggerInput in ui-patterns
* optimize search input responsiveness
* add event on commandMenu opened
* add event on debounced commandMenu input submission
* add event on commandMenu command selection
* add commandMenu telemetry to studio, www and docs

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2025-10-24 11:06:31 +02:00

24 lines
690 B
TypeScript

'use client'
import { sendTelemetryEvent } from 'common'
import type { TelemetryEvent } from 'common/telemetry-constants'
import { API_URL } from 'lib/constants'
import { usePathname, useSearchParams } from 'next/navigation'
import { useCallback } from 'react'
export function useSendTelemetryEvent() {
const pathname = usePathname()
const searchParams = useSearchParams()
return useCallback(
(event: TelemetryEvent) => {
const url = new URL(API_URL ?? 'http://localhost:3000')
url.pathname = pathname ?? ''
url.search = searchParams?.toString() ?? ''
return sendTelemetryEvent(API_URL, event, url.toString())
},
[pathname, searchParams]
)
}