mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 14:19:11 +03:00
32 lines
957 B
TypeScript
32 lines
957 B
TypeScript
'use client'
|
|
|
|
import { useRouter } from 'next/compat/router'
|
|
import { usePathname } from 'next/navigation'
|
|
import { isBrowser } from '../helpers'
|
|
|
|
export interface TelemetryProps {
|
|
screenResolution?: string
|
|
page_url: string
|
|
pathname: string
|
|
search: string
|
|
language: string
|
|
viewport_height: number
|
|
viewport_width: number
|
|
}
|
|
|
|
export function useTelemetryProps(): TelemetryProps {
|
|
const router = useRouter()
|
|
const pathname = usePathname()
|
|
const locale = router ? router.locale : undefined
|
|
|
|
return {
|
|
screenResolution: isBrowser ? `${window.innerWidth}x${window.innerHeight}` : undefined,
|
|
page_url: isBrowser ? window.location.href : '',
|
|
pathname: router?.pathname ?? pathname ?? (isBrowser ? window.location.pathname : ''),
|
|
search: isBrowser ? window.location.search : '',
|
|
viewport_height: isBrowser ? window.innerHeight : 0,
|
|
viewport_width: isBrowser ? window.innerWidth : 0,
|
|
language: locale ?? 'en-US',
|
|
}
|
|
}
|