Files
web/apps/scandic-web/utils/tracking/booking.ts
Bianca Widstam 24e7ab4b71 Merged in fix/SW-2764-remove-ancillaries-breakfast-selection (pull request #2122)
fix(SW-2764): Tracking - remove ancillaries array if no breakfast selected

* fix(SW-2764): remove ancillaries array if no breakfast selected


Approved-by: Tobias Johansson
Approved-by: Joakim Jäderberg
2025-05-16 11:42:56 +00:00

70 lines
1.7 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",
},
...(units > 0 && {
ancillaries: [
{
hotelId,
productCategory: "",
productId: breakfastPackage.code,
productUnits: units,
productPrice: breakfastPackage.localPrice.price * units,
productPoints: 0,
productType: "food",
productName: breakfastPackage.packageType,
},
],
}),
pageInfo: {
pageName: "hotelreservation|breakfast",
pageType: "bookingbreakfastpage",
},
})
}