mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
* 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>
24 lines
690 B
TypeScript
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]
|
|
)
|
|
}
|