Files
supabase/packages/common/telemetry.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

29 lines
694 B
TypeScript

import { post } from './fetchWrappers'
export function handlePageTelemetry(API_URL: string, route: string, telemetryProps: any) {
const { page_url, search, language, viewport_height, viewport_width } = telemetryProps
return post(
`${API_URL}/telemetry/page`,
{
page_url,
page_title: document.title,
pathname: route,
ph: {
referrer: document.referrer,
user_agent: navigator.userAgent,
search,
language,
viewport_height,
viewport_width,
},
},
{
headers: { Version: '2' },
}
)
}
export function handleResetTelemetry(API_URL: string) {
return post(`${API_URL}/telemetry/reset`, {})
}