Files
web/apps/partner-sas/app/utils/tracking.ts
Joakim Jäderberg 7dee6d5083 Merged in chore/move-enter-details (pull request #2778)
Chore/move enter details

Approved-by: Anton Gunnarsson
2025-09-11 07:16:24 +00:00

152 lines
3.6 KiB
TypeScript

"use client"
import type {
PaymentEvent,
PaymentFailEvent,
} from "@scandic-hotels/tracking/types"
import type { BreakfastPackages } from "@scandic-hotels/trpc/routers/hotels/output"
export function trackBookingSearchClick(
searchTerm: string,
searchType: "hotel" | "destination"
) {
console.warn("TODO: Implement trackBookingSearchClick", {
searchTerm,
searchType,
})
}
export function trackAccordionItemOpen(option: string) {
console.warn("TODO: Implement trackAccordionItemOpen", { option })
}
export function trackOpenSidePeek(input: {
name: string | null
hotelId: string
includePathname?: boolean
roomTypeCode?: string | null
}) {
console.warn("TODO: Implement trackOpenSidePeek", { input })
}
export function trackGenericEvent(data: any) {
console.warn("TODO: Implement trackGenericEvent", { data })
}
export function trackGlaSaveCardAttempt({
hotelId,
hasSavedCreditCard,
creditCardType,
lateArrivalGuarantee,
}: {
hotelId: string
hasSavedCreditCard: boolean
creditCardType?: string
lateArrivalGuarantee: "mandatory" | "yes" | "no" | "na"
}) {
console.warn("TODO: Implement trackGlaSaveCardAttempt", {
event: "glaCardSaveAttempt",
hotelInfo: {
hotelId,
lateArrivalGuarantee,
guaranteedProduct: "room",
},
paymentInfo: {
status: "glacardsaveattempt",
isSavedCreditCard: hasSavedCreditCard,
type: creditCardType,
},
})
}
export function trackLoginClick(
position:
| "top menu"
| "hamburger menu"
| "join scandic friends sidebar"
| "enter details"
| "my stay"
) {
console.warn("TODO: Implement trackLoginClick", {
event: "loginStart",
login: {
position,
action: "login start",
ctaName: "login",
},
})
}
export function trackPaymentEvent(paymentEvent: PaymentEvent) {
console.warn("TODO: Implement trackPaymentEvent", {
event: paymentEvent.event,
hotelInfo: {
hotelId: paymentEvent.hotelId,
},
paymentInfo: {
isSavedCard: paymentEvent.isSavedCreditCard,
status: paymentEvent.status,
type: paymentEvent.method,
smsEnable: paymentEvent.smsEnable,
errorMessage: isPaymentFailEvent(paymentEvent)
? paymentEvent.errorMessage
: undefined,
},
})
}
export function trackUpdatePaymentMethod({ method }: { method: string }) {
console.warn("TODO: Implement trackUpdatePaymentMethod", {
event: "paymentSelection",
hotelInfo: {
hotelId: "", // TODO: Needs to be verified with analytics if this should even be here
},
cta: {
name: method,
},
})
}
export function trackBreakfastSelection({
breakfastPackage,
hotelId,
units,
}: {
breakfastPackage: BreakfastPackages[number]
hotelId: string
units: number
}) {
console.warn("TODO: Implement trackBreakfastSelection", {
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 trackBedSelection(bedType: string) {
console.warn("TODO: Implement trackBedSelection", {
event: "bedSelection",
selection: {
name: "bed options selection click",
bedType: bedType,
},
})
}
function isPaymentFailEvent(event: PaymentEvent): event is PaymentFailEvent {
return "errorMessage" in event
}