From 1c5b116ed8f8ae9bccc18e152be695734e7ca25e Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Mon, 14 Apr 2025 11:10:03 +0000 Subject: [PATCH] Merged in feat/SW-1355-reward-night-booking-tracking (pull request #1758) feat: SW-1355 Tracking implementation reward night booking * feat: SW-1355 Tracking implementation reward night booking * feat: SW-1355 Updated checks and optional params * feat: SW-1355 Typings updated * feat: SW-1355 Removed undefined check * feat: SW-1355 optimized code Approved-by: Christian Andolf --- .../(standard)/details/tracking.ts | 5 +++++ .../BookingConfirmation/Tracking/tracking.ts | 3 +++ .../SelectHotelMap/SelectHotelMapContainer.tsx | 9 ++++++++- .../SelectHotel/SelectHotelMap/tracking.ts | 6 +++++- .../HotelReservation/SelectHotel/index.tsx | 9 ++++++++- .../HotelReservation/SelectHotel/tracking.ts | 6 +++++- .../SelectRate/RoomsContainer/Rooms/index.tsx | 15 ++++++++++----- .../HotelReservation/SelectRate/index.tsx | 4 +++- .../HotelReservation/SelectRate/tracking.ts | 4 +++- apps/scandic-web/types/components/tracking.ts | 6 ++++-- 10 files changed, 54 insertions(+), 13 deletions(-) diff --git a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts index e57b3632d..ebeef6b18 100644 --- a/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts +++ b/apps/scandic-web/app/[lang]/(live)/(public)/hotelreservation/(standard)/details/tracking.ts @@ -1,5 +1,7 @@ import { differenceInCalendarDays, format, isWeekend } from "date-fns" +import { REDEMPTION } from "@/constants/booking" + import { getSpecialRoomType } from "@/utils/specialRoomType" import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums" @@ -122,6 +124,9 @@ export function getTracking( return CurrencyEnum.Unknown }) .join(","), + rewardNight: booking.searchType === REDEMPTION ? "yes" : "no", + rewardNightAvailability: + booking.searchType === REDEMPTION ? "true" : "false", searchTerm: city, searchType: "hotel", specialRoomType: rooms diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts index 20881b4ba..3ea9ec214 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts @@ -146,6 +146,9 @@ export function getTracking( //rateCodeType: , //TODO: Add when available in API. "regular, promotion, corporate etx", region: hotel?.address.city, revenueCurrencyCode: rooms.map((r) => r.currencyCode).join(","), + rewardNight: booking.roomPoints > 0 ? "yes" : "no", + rewardNightAvailability: booking.roomPoints > 0 ? "true" : "false", + points: booking.roomPoints > 0 ? booking.roomPoints : undefined, roomPrice: rooms.map((r) => r.roomPrice).join(","), roomTypeCode: rooms.map((r) => r.roomTypeCode ?? "-").join(","), searchType: "hotel", diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx index 65ad59bc5..5da0f917c 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx @@ -73,6 +73,11 @@ export async function SelectHotelMapContainer({ const arrivalDate = new Date(selectHotelParams.fromDate) const departureDate = new Date(selectHotelParams.toDate) + const isRedemptionAvailability = redemption + ? hotels.some( + (hotel) => hotel.availability.productType?.redemptions?.length + ) + : false const isBookingCodeRateAvailable = bookingCode ? hotels?.some( @@ -97,7 +102,9 @@ export async function SelectHotelMapContainer({ hotels?.[0]?.hotel.address.city, selectHotelParams.city, bookingCode, - isBookingCodeRateAvailable + isBookingCodeRateAvailable, + redemption, + isRedemptionAvailability ) return ( diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts index 83f61cb46..585d82525 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/tracking.ts @@ -24,7 +24,9 @@ export function getTracking( hotelCity: string | undefined, paramCity: string | undefined, bookingCode?: string, - isBookingCodeRateAvailable?: boolean + isBookingCodeRateAvailable?: boolean, + isRedemption?: boolean, + isRedemptionAvailability?: boolean ) { const pageTrackingData: TrackingSDKPageData = { channel: TrackingChannelEnum["hotelreservation"], @@ -60,6 +62,8 @@ export function getTracking( noOfChildren: childrenInRoom?.map((kids) => kids?.length ?? 0).join(","), noOfRooms, region: hotelCity, + rewardNight: isRedemption ? "yes" : "no", + rewardNightAvailability: isRedemptionAvailability ? "true" : "false", searchTerm: isAlternativeFor ? hotelId : (paramCity as string), searchType: "destination", } diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx index 42d172ddd..282b8f2f0 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/index.tsx @@ -118,6 +118,11 @@ export default async function SelectHotel({ ] const isAllUnavailable = !hotels.length + const isRedemptionAvailability = redemption + ? hotels.some( + (hotel) => hotel.availability.productType?.redemptions?.length + ) + : false const suspenseKey = stringify(searchParams) @@ -155,7 +160,9 @@ export default async function SelectHotel({ hotels?.[0]?.hotel.address.city, selectHotelParams.city, bookingCode, - isBookingCodeRateAvailable ? "true" : "false" + isBookingCodeRateAvailable ? "true" : "false", + redemption, + isRedemptionAvailability ) // Special rates (corporate cheque, voucher and reward nights) will not have regular rate hotels availability diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts b/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts index 9a60af56d..cf4ee1803 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/tracking.ts @@ -23,7 +23,9 @@ export function getTracking( hotelCity: string | undefined, paramCity: string | undefined, bookingCode?: string, - isBookingCodeRateAvailable?: string + isBookingCodeRateAvailable?: string, + isRedemption?: boolean, + isRedemptionAvailable?: boolean ) { const pageTrackingData: TrackingSDKPageData = { channel: TrackingChannelEnum["hotelreservation"], @@ -63,6 +65,8 @@ export function getTracking( bookingCodeAvailability: bookingCode ? isBookingCodeRateAvailable : undefined, + rewardNight: isRedemption ? "yes" : "no", + rewardNightAvailability: isRedemptionAvailable ? "true" : "false", } return { diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/index.tsx index cfbbcc0e3..157f2210e 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/index.tsx @@ -51,12 +51,17 @@ export default function Rooms() { })) ) ) - const lowestPrice = pricesWithCurrencies.reduce( - (minPrice, { price }) => Math.min(minPrice, price), - Infinity - ) - const currency = pricesWithCurrencies[0]?.currency + // Specific n/a when no prices available in reward night and voucher scenarios + const lowestPrice = pricesWithCurrencies.length + ? pricesWithCurrencies + .reduce((minPrice, { price }) => Math.min(minPrice, price), Infinity) + .toString() + : "n/a" + + const currency = pricesWithCurrencies.length + ? pricesWithCurrencies[0]?.currency + : "n/a" trackLowestRoomPrice({ hotelId, diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx index 7d9dc4e1d..6ea8f6a9b 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/index.tsx @@ -2,6 +2,7 @@ import stringify from "json-stable-stringify-without-jsonify" import { notFound } from "next/navigation" import { Suspense } from "react" +import { REDEMPTION } from "@/constants/booking" import { getHotel } from "@/lib/trpc/memoizedRequests" import { auth } from "@/auth" @@ -70,7 +71,8 @@ export default async function SelectRatePage({ hotelData.hotel.address.country, hotelData.hotel.address.city, selectHotelParams.city, - bookingCode + bookingCode, + selectHotelParams.searchType === REDEMPTION ) const booking = convertSearchParamsToObj(searchParams) diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts b/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts index e2519719d..822926e45 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/SelectRate/tracking.ts @@ -21,7 +21,8 @@ export function getTracking( country: string | undefined, hotelCity: string | undefined, paramCity: string | undefined, - bookingCode?: string + bookingCode?: string, + isRedemption?: boolean ) { const pageTrackingData: TrackingSDKPageData = { channel: TrackingChannelEnum.hotelreservation, @@ -54,6 +55,7 @@ export function getTracking( searchTerm: paramCity ?? hotelName, searchType: "hotel", bookingCode: bookingCode ?? "n/a", + rewardNight: isRedemption ? "yes" : "no", } return { diff --git a/apps/scandic-web/types/components/tracking.ts b/apps/scandic-web/types/components/tracking.ts index c69711bae..d0317d353 100644 --- a/apps/scandic-web/types/components/tracking.ts +++ b/apps/scandic-web/types/components/tracking.ts @@ -78,13 +78,15 @@ export type TrackingSDKHotelInfo = { noOfAdults?: number | string // multiroom support, "2,1,3" noOfChildren?: number | string // multiroom support, "2,1,3" noOfRooms?: number - //rewardNight?: boolean rateCode?: string rateCodeCancellationRule?: string rateCodeName?: string // Scandic Friends - full flex inkl. frukost rateCodeType?: string // regular, promotion etc region?: string // Region of the hotel revenueCurrencyCode?: string // SEK, DKK, NOK, EUR + rewardNight?: string + rewardNightAvailability?: string + points?: number // Should be sent only on confirmation page roomPrice?: number | string roomTypeCode?: string roomTypeName?: string @@ -156,7 +158,7 @@ export type LowestRoomPriceEvent = { hotelId: string | null arrivalDate: string | null departureDate: string | null - lowestPrice: number + lowestPrice: string currency?: string }