Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(docs): accepting consent (#32594)

Alaister Young91a36c9dcf53
diff --git a/packages/common/hooks/useTelemetryProps.ts b/packages/common/hooks/useTelemetryProps.ts
index 88a16ef8b8f..d70b3d76ac0 100644
--- a/packages/common/hooks/useTelemetryProps.ts
+++ b/packages/common/hooks/useTelemetryProps.ts
@@ -1,11 +1,13 @@
'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
@@ -14,11 +16,13 @@ export interface TelemetryProps {
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 ?? window.location.pathname,
search: isBrowser ? window.location.search : '',
viewport_height: isBrowser ? window.innerHeight : 0,
viewport_width: isBrowser ? window.innerWidth : 0,
diff --git a/packages/ui-patterns/ConsentToast/index.tsx b/packages/ui-patterns/ConsentToast/index.tsx
index 8f3d0376274..ecaf811ba15 100644
--- a/packages/ui-patterns/ConsentToast/index.tsx
+++ b/packages/ui-patterns/ConsentToast/index.tsx
@@ -9,7 +9,6 @@ import {
} from 'common'
import { noop } from 'lodash'
-import router from 'next/router'
import { useCallback, useEffect, useRef, useState } from 'react'
import { toast } from 'sonner'
import { Button, cn } from 'ui'
@@ -110,7 +109,7 @@ export const useConsent = () => {
const telemetryData = {
page_url: telemetryProps.page_url,
page_title: typeof document !== 'undefined' ? document?.title : '',
- pathname: router.pathname,
+ pathname: telemetryProps.pathname,
ph: {
referrer: typeof document !== 'undefined' ? document?.referrer : '',
language: telemetryProps.language,
@@ -200,7 +199,7 @@ export const useConsentValue = (KEY_NAME: string) => {
const telemetryData = {
page_url: telemetryProps.page_url,
page_title: typeof document !== 'undefined' ? document?.title : '',
- pathname: router.pathname,
+ pathname: telemetryProps.pathname,
ph: {
referrer: typeof document !== 'undefined' ? document?.referrer : '',
language: telemetryProps.language,