Files
web/apps/scandic-web/utils/tracking/booking.ts
Hrishikesh Vaipurkar 6520bc5bc5 Merged in fix/SW-1879-aa-track-bed-breakfast-pay-3 (pull request #1900)
fix: SW-1879 Updated values in tracking

* fix: SW-1879 Updated bed type value in tracking

* fix: SW-1879 Updated breakfast price to indicate total price


Approved-by: Michael Zetterberg
2025-04-29 10:00:58 +00:00

68 lines
1.6 KiB
TypeScript

import { trackEvent } from "./base"
import type { BreakfastPackages } from "@/types/components/hotelReservation/breakfast"
import type { LowestRoomPriceEvent } from "@/types/components/tracking"
export function trackLowestRoomPrice(event: LowestRoomPriceEvent) {
trackEvent({
event: "lowestRoomPrice",
hotelInfo: {
hotelId: event.hotelId,
arrivalDate: event.arrivalDate,
departureDate: event.departureDate,
},
viewItemInfo: {
lowestPrice: event.lowestPrice,
currency: event.currency,
},
})
}
// Tracking for sections of booking flow enter-details page
export function trackBedSelection(bedType: string) {
trackEvent({
event: "bedSelection",
selection: {
name: "bed options selection click",
bedType: bedType,
},
pageInfo: {
pageName: "hotelreservation|bed",
pageType: "bookingbedtypepage",
},
})
}
export function trackBreakfastSelection({
breakfastPackage,
hotelId,
units,
}: {
breakfastPackage: BreakfastPackages[number]
hotelId: string
units: number
}) {
trackEvent({
event: "breakfastSelection",
selection: {
name: "breakfast options selection click",
},
ancillaries: [
{
hotelId: hotelId,
productCategory: "",
productId: breakfastPackage.code,
productUnits: units,
productPrice: units > 0 ? breakfastPackage.localPrice.price * units : 0,
productPoints: 0,
productType: "food",
productName: breakfastPackage.packageType,
},
],
pageInfo: {
pageName: "hotelreservation|breakfast",
pageType: "bookingbreakfastpage",
},
})
}