Feat/SW-3461 setup auth with sas eurobonus * feat(SW-3461): Setup auth for sas eurobonus * . * feat: setup auth towards SAS * Fix auth via SAS and add logout route * . * merge * auth via SAS * fix powered by scandic logo * Merge branch 'master' of bitbucket.org:scandic-swap/web into feat/SW-3461-setup-auth-with-sas-eurobonus * Include access_token in jwt after successful login * merge Approved-by: Anton Gunnarsson
153 lines
3.7 KiB
TypeScript
153 lines
3.7 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 })
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
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
|
|
}
|