fix: handleRouteChange and condition to send initial page event

This commit is contained in:
phamhieu authored and Joshen Lim committed 2023-02-07 13:13:44 +08:00
1 parent 7faeb7c961
commit 561a6777d4
1 file changed
+4 -4
+4 -4
View File
@@ -10,8 +10,8 @@ const PageTelemetry: FC = ({ children }) => {
const { ui } = useStore()
useEffect(() => {
function handleRouteChange() {
handlePageTelemetry(router.route)
function handleRouteChange(url: string) {
handlePageTelemetry(url)
}
// Listen for page changes after a navigation or when the query changes
@@ -24,9 +24,9 @@ const PageTelemetry: FC = ({ children }) => {
useEffect(() => {
/**
* Send page telemetry on first page load
* if there asPath is defined, then this isn't needed
* if the route is not ready. Don't need to send it will be picked up by router.event above
*/
if (router.route === '/' && router.asPath === '/') {
if (router.isReady) {
handlePageTelemetry(router.route)
}
}, [])