Added basic tracking on booking confirmation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
|
||||
import { Suspense } from "react"
|
||||
|
||||
import { getBookingConfirmation } from "@/lib/trpc/memoizedRequests"
|
||||
@@ -11,10 +12,17 @@ import Rooms from "@/components/HotelReservation/BookingConfirmation/Rooms"
|
||||
import SidePanel from "@/components/HotelReservation/SidePanel"
|
||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||
import Divider from "@/components/TempDesignSystem/Divider"
|
||||
import TrackingSDK from "@/components/TrackingSDK"
|
||||
import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
TrackingSDKHotelInfo,
|
||||
TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import { CurrencyEnum } from "@/types/enums/currency"
|
||||
import type { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function BookingConfirmationPage({
|
||||
@@ -25,6 +33,54 @@ export default async function BookingConfirmationPage({
|
||||
void getBookingConfirmation(searchParams.confirmationNumber)
|
||||
const { confirmationNumber } = searchParams
|
||||
|
||||
const { hotel, booking } = await getBookingConfirmation(confirmationNumber)
|
||||
|
||||
const arrivalDate = new Date(booking.checkInDate)
|
||||
const departureDate = new Date(booking.checkOutDate)
|
||||
|
||||
const initialPageTrackingData: TrackingSDKPageData = {
|
||||
pageId: "booking-confirmation",
|
||||
domainLanguage: params.lang,
|
||||
channel: TrackingChannelEnum["hotelreservation"],
|
||||
pageName: `hotelreservation|confirmation`,
|
||||
siteSections: `hotelreservation|confirmation`,
|
||||
pageType: "confirmation",
|
||||
siteVersion: "new-web",
|
||||
}
|
||||
|
||||
const initialHotelsTrackingData: TrackingSDKHotelInfo = {
|
||||
searchTerm: searchParams.city,
|
||||
arrivalDate: format(arrivalDate, "yyyy-MM-dd"),
|
||||
departureDate: format(departureDate, "yyyy-MM-dd"),
|
||||
noOfAdults: booking.adults,
|
||||
noOfChildren: booking.childrenAges?.length,
|
||||
ageOfChildren: booking.childrenAges?.join(","),
|
||||
childBedPreference: booking?.extraBedTypes?.map((c) => c.bedType).join("|"),
|
||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||
searchType: "hotel",
|
||||
bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday",
|
||||
country: hotel?.address.country,
|
||||
region: hotel?.address.city,
|
||||
rateCode: booking.rateDefinition.rateCode ?? undefined,
|
||||
rateCodeType: booking.rateDefinition.title ?? undefined,
|
||||
rateCodeName: booking.rateDefinition.rateCode ?? undefined,
|
||||
rateCodeCancellationRule:
|
||||
booking.rateDefinition?.cancellationText ?? undefined,
|
||||
revenueCurrencyCode: CurrencyEnum[booking.currencyCode],
|
||||
breakfastOption: booking.rateDefinition.breakfastIncluded
|
||||
? "breakfast buffet"
|
||||
: "no breakfast",
|
||||
totalPrice: booking.totalPrice,
|
||||
//specialRoomType: getSpecialRoomType(booking.packages), TODO: Add
|
||||
//roomTypeName: booking.roomTypeCode ?? undefined, TODO: Do we get the name?
|
||||
//bedType: bedType?.description, TODO: Can we get bedType?
|
||||
roomTypeCode: booking.roomTypeCode ?? undefined,
|
||||
roomPrice: booking.roomPrice,
|
||||
bnr: booking.confirmationNumber ?? undefined,
|
||||
}
|
||||
|
||||
return (
|
||||
<main className={styles.main}>
|
||||
<Suspense fallback={<LoadingSpinner fullPage />}>
|
||||
@@ -46,6 +102,10 @@ export default async function BookingConfirmationPage({
|
||||
<Receipt confirmationNumber={searchParams.confirmationNumber} />
|
||||
</SidePanel>
|
||||
</aside>
|
||||
<TrackingSDK
|
||||
pageData={initialPageTrackingData}
|
||||
hotelInfo={initialHotelsTrackingData}
|
||||
/>
|
||||
</Suspense>
|
||||
</main>
|
||||
)
|
||||
|
||||
@@ -17,6 +17,7 @@ import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import { fetchAvailableHotels, getFiltersFromHotels } from "../../utils"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import type { HotelData } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
|
||||
import type { SelectHotelSearchParams } from "@/types/components/hotelReservation/selectHotel/selectHotelSearchParams"
|
||||
import {
|
||||
@@ -85,7 +86,7 @@ export default async function SelectHotelMapPage({
|
||||
noOfAdults: adults,
|
||||
noOfChildren: child?.length,
|
||||
ageOfChildren: child?.map((c) => c.age).join(","),
|
||||
childBedPreference: child?.map((c) => c.bed).join("|"),
|
||||
childBedPreference: child?.map((c) => ChildBedMapEnum[c.bed]).join("|"),
|
||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||
|
||||
@@ -15,6 +15,7 @@ import { safeTry } from "@/utils/safeTry"
|
||||
|
||||
import { getValidDates } from "./getValidDates"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import type { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
@@ -86,7 +87,7 @@ export default async function SelectRatePage({
|
||||
noOfAdults: adults,
|
||||
noOfChildren: children?.length,
|
||||
ageOfChildren: children?.map((c) => c.age).join(","),
|
||||
childBedPreference: children?.map((c) => c.bed).join("|"),
|
||||
childBedPreference: children?.map((c) => ChildBedMapEnum[c.bed]).join("|"),
|
||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||
|
||||
@@ -34,6 +34,7 @@ import EnterDetailsTracking from "./enterDetailsTracking"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums"
|
||||
import { SelectRateSearchParams } from "@/types/components/hotelReservation/selectRate/selectRate"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
@@ -173,7 +174,7 @@ export default async function StepPage({
|
||||
noOfAdults: adults,
|
||||
noOfChildren: children?.length,
|
||||
ageOfChildren: children?.map((c) => c.age).join(","),
|
||||
childBedPreference: children?.map((c) => c.bed).join("|"),
|
||||
childBedPreference: children?.map((c) => ChildBedMapEnum[c.bed]).join("|"),
|
||||
noOfRooms: 1, // // TODO: Handle multiple rooms
|
||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||
|
||||
Reference in New Issue
Block a user