Skip to content

Commit 76d750f

Browse files
authored
Update www page leave behaviour (supabase#29945)
1 parent 7feff8f commit 76d750f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

apps/www/pages/_app.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,20 @@ export default function App({ Component, pageProps }: AppProps) {
8989
}, [router.isReady, consentValue])
9090

9191
useEffect(() => {
92-
if (blockEvents) return
93-
9492
const handleBeforeUnload = async () => {
95-
await post(`${API_URL}/telemetry/page-leave`, {
96-
page_url: window.location.href,
97-
page_title: title,
98-
pathname: router.pathname,
99-
})
93+
if (!blockEvents) {
94+
await post(`${API_URL}/telemetry/page-leave`, {
95+
page_url: window.location.href,
96+
page_title: title,
97+
pathname: router.pathname,
98+
})
99+
}
100100
}
101101
window.addEventListener('beforeunload', handleBeforeUnload)
102-
103102
return () => {
104103
window.removeEventListener('beforeunload', handleBeforeUnload)
105104
}
106-
}, [])
105+
}, [blockEvents, router.pathname, title])
107106

108107
const site_title = `${APP_NAME} | The Open Source Firebase Alternative`
109108
const { basePath } = useRouter()

0 commit comments

Comments
 (0)