Merged in feat/sw-3473-remove-tracking-context (pull request #2843)
feat(SW-3473): Rework booking-flow tracking provider * Remove tracking context and import instead * Remove unused file Approved-by: Joakim Jäderberg
This commit is contained in:
64
packages/tracking/lib/booking.ts
Normal file
64
packages/tracking/lib/booking.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
"use client"
|
||||
|
||||
import { trackEvent } from "./base"
|
||||
|
||||
import type { BreakfastPackages } from "@scandic-hotels/trpc/routers/hotels/output"
|
||||
|
||||
// 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,
|
||||
breakfastOption,
|
||||
}: {
|
||||
breakfastPackage: BreakfastPackages[number]
|
||||
hotelId: string
|
||||
units: number
|
||||
breakfastOption: string
|
||||
}) {
|
||||
trackEvent({
|
||||
event: "breakfastSelection",
|
||||
selection: {
|
||||
name: "breakfast options selection click",
|
||||
breakfastOption,
|
||||
},
|
||||
...(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",
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user