From ffb29ddaad4096d77d75f8b8ccdd81f881a56b64 Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Sat, 3 May 2025 09:21:14 +0000 Subject: [PATCH] Merged in fix/tracking-issue-pageview (pull request #1931) fix: tracking issues * fix: tracking issues Approved-by: Hrishikesh Vaipurkar --- .../components/TrackingSDK/RouterTracking.tsx | 4 ++++ apps/scandic-web/components/TrackingSDK/index.tsx | 9 +++++---- apps/scandic-web/stores/tracking.ts | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/scandic-web/components/TrackingSDK/RouterTracking.tsx b/apps/scandic-web/components/TrackingSDK/RouterTracking.tsx index ced0967fc..165c85336 100644 --- a/apps/scandic-web/components/TrackingSDK/RouterTracking.tsx +++ b/apps/scandic-web/components/TrackingSDK/RouterTracking.tsx @@ -24,6 +24,10 @@ export default function RouterTracking() { const { startRouterTransition } = useRouterTransitionStore() useEffect(() => { + if (pathName.includes("payment-callback")) { + return + } + updateRouteInfo(pathName, currentLang, searchParams) if (hasPathOrLangChanged() || hasBookingFlowParamsChanged()) { setInitialPageLoadTime(Date.now()) diff --git a/apps/scandic-web/components/TrackingSDK/index.tsx b/apps/scandic-web/components/TrackingSDK/index.tsx index 74bd5192f..2374a9af8 100644 --- a/apps/scandic-web/components/TrackingSDK/index.tsx +++ b/apps/scandic-web/components/TrackingSDK/index.tsx @@ -1,6 +1,9 @@ "use client" -import { useTrackSoftNavigation } from "@/components/TrackingSDK/hooks" +import { + useTrackHardNavigation, + useTrackSoftNavigation, +} from "@/components/TrackingSDK/hooks" import type { TrackingSDKAncillaries, @@ -20,9 +23,7 @@ export default function TrackingSDK({ paymentInfo?: TrackingSDKPaymentInfo ancillaries?: TrackingSDKAncillaries }) { - // This hook doesnt seem to be needed. Soft navigation hook seems to fire - // on both hard and soft navigations - // useTrackHardNavigation({ pageData, hotelInfo, paymentInfo, ancillaries }) + useTrackHardNavigation({ pageData, hotelInfo, paymentInfo, ancillaries }) useTrackSoftNavigation({ pageData, hotelInfo, paymentInfo, ancillaries }) return null diff --git a/apps/scandic-web/stores/tracking.ts b/apps/scandic-web/stores/tracking.ts index 6a4385efa..c3d57ec85 100644 --- a/apps/scandic-web/stores/tracking.ts +++ b/apps/scandic-web/stores/tracking.ts @@ -1,5 +1,6 @@ "use client" +import isEqual from "fast-deep-equal" import { create } from "zustand" import { convertSearchParamsToObj, searchParamsToRecord } from "@/utils/url" @@ -84,7 +85,7 @@ const useTrackingStore = create((set, get) => ({ searchParamsToRecord(currentParams) ) - return !Object.is(previousParamsObject, currentParamsObject) + return !isEqual(previousParamsObject, currentParamsObject) }, }))