Files
web/apps/scandic-web/utils/tracking/booking.ts
Anton Gunnarsson e4a66499e5 Merged in feat/sw-3322-move-base-tracking-to-common (pull request #2713)
feat(SW-3322): Move base tracking to common package

* Move base tracking to common package

* Update lock file


Approved-by: Joakim Jäderberg
2025-08-27 12:29:46 +00:00

78 lines
1.7 KiB
TypeScript

"use client"
import { trackEvent } from "@scandic-hotels/common/tracking/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,
},
})
}
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,
},
],
}),
})
}
export function trackBookingSearchClick(
searchTerm: string,
searchType: string
) {
trackEvent({
event: "hotelSearchButtonClick",
hotelInfo: {
searchTerm,
searchType,
action: "Hotel search",
},
})
}