From 230b56b3bde6972d092e9be0cc777d07b1232aad Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Thu, 6 Mar 2025 10:15:33 +0000 Subject: [PATCH] Merged in feat/SW-1472-destination-tracking (pull request #1474) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Feat/SW-1472 destination tracking * feat(SW-1472): Added default tracking for destination overview page * feat(SW-1472): Added default tracking for destination country/city page * feat(SW-1472): moved tracking functions to different files for better overview * feat(SW-1472): added destination page tracking Approved-by: Fredrik Thorsson Approved-by: Matilda Landström --- .../DestinationCityPage/index.tsx | 5 +- .../DestinationCountryPage/index.tsx | 5 +- .../Map/MapContent/ClusterMarker/index.tsx | 5 +- .../Map/MapContent/Marker/index.tsx | 2 + .../DestinationPage/Sidepeek/index.tsx | 11 +- .../DestinationPage/Tracking/index.tsx | 28 +++ .../destinationCityPage/output.ts | 121 +++++------ .../contentstack/destinationCityPage/query.ts | 26 ++- .../destinationCountryPage/output.ts | 126 +++++------ .../destinationCountryPage/query.ts | 35 +++- .../destinationOverviewPage/query.ts | 8 +- .../stores/destination-data/index.ts | 28 +++ apps/scandic-web/types/components/tracking.ts | 2 - .../contentstack/destinationCityPage.ts | 3 +- .../contentstack/destinationCountryPage.ts | 2 +- apps/scandic-web/utils/tracking.ts | 198 ------------------ apps/scandic-web/utils/tracking/base.ts | 19 ++ apps/scandic-web/utils/tracking/booking.ts | 18 ++ .../utils/tracking/componentEvents.ts | 30 +++ .../utils/tracking/destinationPage.ts | 59 ++++++ apps/scandic-web/utils/tracking/hotelPage.ts | 20 ++ apps/scandic-web/utils/tracking/index.ts | 15 ++ apps/scandic-web/utils/tracking/navigation.ts | 32 +++ apps/scandic-web/utils/tracking/pageview.ts | 39 ++++ apps/scandic-web/utils/tracking/payment.ts | 38 ++++ 25 files changed, 502 insertions(+), 373 deletions(-) create mode 100644 apps/scandic-web/components/ContentType/DestinationPage/Tracking/index.tsx delete mode 100644 apps/scandic-web/utils/tracking.ts create mode 100644 apps/scandic-web/utils/tracking/base.ts create mode 100644 apps/scandic-web/utils/tracking/booking.ts create mode 100644 apps/scandic-web/utils/tracking/componentEvents.ts create mode 100644 apps/scandic-web/utils/tracking/destinationPage.ts create mode 100644 apps/scandic-web/utils/tracking/hotelPage.ts create mode 100644 apps/scandic-web/utils/tracking/index.ts create mode 100644 apps/scandic-web/utils/tracking/navigation.ts create mode 100644 apps/scandic-web/utils/tracking/pageview.ts create mode 100644 apps/scandic-web/utils/tracking/payment.ts diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx index ddf46f4e2..782264645 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCityPage/index.tsx @@ -7,7 +7,6 @@ import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests" import Blocks from "@/components/Blocks" import Breadcrumbs from "@/components/Breadcrumbs" import Body from "@/components/TempDesignSystem/Text/Body" -import TrackingSDK from "@/components/TrackingSDK" import ExperienceList from "../ExperienceList" import HotelDataContainer, { preload } from "../HotelDataContainer" @@ -16,6 +15,7 @@ import SidebarContentWrapper from "../SidebarContentWrapper" import DestinationPageSidePeek from "../Sidepeek" import StaticMap from "../StaticMap" import TopImages from "../TopImages" +import DestinationTracking from "../Tracking" import CityMap from "./CityMap" import DestinationCityPageSkeleton from "./DestinationCityPageSkeleton" @@ -65,6 +65,7 @@ export default async function DestinationCityPage() { )} @@ -85,7 +86,7 @@ export default async function DestinationCityPage() { /> - + ) } diff --git a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx index ad1a738eb..f027a2790 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/DestinationCountryPage/index.tsx @@ -7,7 +7,6 @@ import Blocks from "@/components/Blocks" import Breadcrumbs from "@/components/Breadcrumbs" import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton" import Body from "@/components/TempDesignSystem/Text/Body" -import TrackingSDK from "@/components/TrackingSDK" import CityDataContainer, { preload } from "../CityDataContainer" import CityListing from "../CityListing" @@ -16,6 +15,7 @@ import SidebarContentWrapper from "../SidebarContentWrapper" import DestinationPageSidePeek from "../Sidepeek" import StaticMap from "../StaticMap" import TopImages from "../TopImages" +import DestinationTracking from "../Tracking" import CountryMap from "./CountryMap" import DestinationCountryPageSkeleton from "./DestinationCountryPageSkeleton" @@ -69,6 +69,7 @@ export default async function DestinationCountryPage() { )} - + ) } diff --git a/apps/scandic-web/components/ContentType/DestinationPage/Map/MapContent/ClusterMarker/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/Map/MapContent/ClusterMarker/index.tsx index e1b7c5406..415fd8260 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/Map/MapContent/ClusterMarker/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/Map/MapContent/ClusterMarker/index.tsx @@ -8,6 +8,8 @@ import { useCallback } from "react" import { useDestinationPageHotelsMapStore } from "@/stores/destination-page-hotels-map" +import { trackMapClick } from "@/utils/tracking/destinationPage" + import styles from "./clusterMarker.module.css" interface ClusterMarkerProps { @@ -34,7 +36,8 @@ export default function ClusterMarker({ if (onMarkerClick) { onMarkerClick(position) } - }, [onMarkerClick, position]) + trackMapClick(`cluster with hotelIds: ${hotelIds.join(",")}`) + }, [onMarkerClick, position, hotelIds]) return ( { setClickedHotel(properties.id) + trackMapClick(properties.name) }, [setClickedHotel, properties]) function handleCloseCard() { diff --git a/apps/scandic-web/components/ContentType/DestinationPage/Sidepeek/index.tsx b/apps/scandic-web/components/ContentType/DestinationPage/Sidepeek/index.tsx index e52097ff0..ff4fbf191 100644 --- a/apps/scandic-web/components/ContentType/DestinationPage/Sidepeek/index.tsx +++ b/apps/scandic-web/components/ContentType/DestinationPage/Sidepeek/index.tsx @@ -6,6 +6,7 @@ import { ChevronRightSmallIcon } from "@/components/Icons" import JsonToHtml from "@/components/JsonToHtml" import Button from "@/components/TempDesignSystem/Button" import SidePeek from "@/components/TempDesignSystem/SidePeek" +import { trackOpenSidePeekOnDestinationPagesEvent } from "@/utils/tracking/destinationPage" import type { DestinationCityPageData } from "@/types/trpc/routers/contentstack/destinationCityPage" import type { DestinationCountryPageData } from "@/types/trpc/routers/contentstack/destinationCountryPage" @@ -16,18 +17,25 @@ interface DestinationPageSidepeekProps { | DestinationCityPageData["sidepeek_content"] | DestinationCountryPageData["sidepeek_content"] > + location: string } export default function DestinationPageSidepeek({ buttonText, sidePeekContent, + location, }: DestinationPageSidepeekProps) { const [sidePeekIsOpen, setSidePeekIsOpen] = useState(false) const { heading, content } = sidePeekContent + function handleButtonClick() { + setSidePeekIsOpen(true) + trackOpenSidePeekOnDestinationPagesEvent(location) + } + return (