Merged in fix/SW-3026-prod---users-are-not-focused-on- (pull request #2379)
fix: SW-3026 Fixed scroll issue * fix: SW-3026 Fixed scroll issue * fix: SW-3026 Moved to global solution for scroll to top after page navigation Approved-by: Tobias Johansson Approved-by: Linus Flood
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { usePathname, useSearchParams } from "next/navigation"
|
||||
import { startTransition, useEffect } from "react"
|
||||
|
||||
import useRouterTransitionStore from "@/stores/router-transition"
|
||||
import useTrackingStore from "@/stores/tracking"
|
||||
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { trackPageViewStart } from "@/utils/tracking"
|
||||
|
||||
export default function RouterTracking() {
|
||||
const pathName = usePathname()
|
||||
const searchParams = useSearchParams()
|
||||
const currentLang = useLang()
|
||||
|
||||
const {
|
||||
setInitialPageLoadTime,
|
||||
updateRouteInfo,
|
||||
hasPathOrLangChanged,
|
||||
hasBookingFlowParamsChanged,
|
||||
} = useTrackingStore()
|
||||
|
||||
const { startRouterTransition } = useRouterTransitionStore()
|
||||
|
||||
useEffect(() => {
|
||||
if (pathName.includes("payment-callback")) {
|
||||
return
|
||||
}
|
||||
|
||||
updateRouteInfo(pathName, currentLang, searchParams)
|
||||
if (hasPathOrLangChanged() || hasBookingFlowParamsChanged()) {
|
||||
setInitialPageLoadTime(Date.now())
|
||||
trackPageViewStart()
|
||||
startTransition(() => {
|
||||
startRouterTransition()
|
||||
})
|
||||
}
|
||||
}, [
|
||||
pathName,
|
||||
searchParams,
|
||||
currentLang,
|
||||
updateRouteInfo,
|
||||
hasPathOrLangChanged,
|
||||
hasBookingFlowParamsChanged,
|
||||
setInitialPageLoadTime,
|
||||
startRouterTransition,
|
||||
])
|
||||
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user