Files
supabase/packages/common/hooks/useTelemetryProps.ts
T
Joshen Lim ed207751ad Update telemetry calls for docs to support PH (#29749)
* Update telemetry calls for docs to support PH

* Update telemetry calls for www to support PH

* Add ts ignore

* Remove use of useRouter for docs

* Add credentials include for www and docs for telemetry calls

* Update TELEMETRY_CONSENT in common for www and docs to reset telemetry opt in preference

* Update common telemetry to use new endpoint and payload, and trigger reset request when opting out of telemetry from ui patterns PrigacySettings

* Fix

* Fix

* Fix

* Fix build issue in docs

* Fix build issue in docs

* I hope this fixes the build issues

* once more...

* Fix

* Add credentials include

* Fix
2024-10-16 15:16:33 +08:00

28 lines
768 B
TypeScript

'use client'
import { useRouter } from 'next/compat/router'
import { isBrowser } from '../helpers'
export interface TelemetryProps {
screenResolution?: string
page_url: string
search: string
language: string
viewport_height: number
viewport_width: number
}
export function useTelemetryProps(): TelemetryProps {
const router = useRouter()
const locale = router ? router.locale : undefined
return {
screenResolution: isBrowser ? `${window.innerWidth}x${window.innerHeight}` : undefined,
page_url: isBrowser ? window.location.href : '',
search: isBrowser ? window.location.search : '',
viewport_height: isBrowser ? window.innerHeight : 0,
viewport_width: isBrowser ? window.innerWidth : 0,
language: locale ?? 'en-US',
}
}