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:
@@ -1,21 +1,8 @@
|
||||
"use client"
|
||||
|
||||
import { BookingFlowContextProvider } from "@scandic-hotels/booking-flow/BookingFlowContextProvider"
|
||||
import { BookingFlowTrackingProvider } from "@scandic-hotels/booking-flow/BookingFlowTrackingProvider"
|
||||
|
||||
import { useIsUserLoggedIn } from "../hooks/useIsUserLoggedIn"
|
||||
import {
|
||||
trackAccordionItemOpen,
|
||||
trackBedSelection,
|
||||
trackBookingSearchClick,
|
||||
trackBreakfastSelection,
|
||||
trackGenericEvent,
|
||||
trackGlaSaveCardAttempt,
|
||||
trackLoginClick,
|
||||
trackOpenSidePeek,
|
||||
trackPaymentEvent,
|
||||
trackUpdatePaymentMethod,
|
||||
} from "../utils/tracking"
|
||||
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
@@ -24,22 +11,7 @@ export function BookingFlowProviders({ children }: { children: ReactNode }) {
|
||||
|
||||
return (
|
||||
<BookingFlowContextProvider data={{ isLoggedIn }}>
|
||||
<BookingFlowTrackingProvider
|
||||
trackingFunctions={{
|
||||
trackBookingSearchClick,
|
||||
trackAccordionItemOpen,
|
||||
trackOpenSidePeek,
|
||||
trackGenericEvent,
|
||||
trackGlaSaveCardAttempt,
|
||||
trackLoginClick,
|
||||
trackPaymentEvent,
|
||||
trackUpdatePaymentMethod,
|
||||
trackBreakfastSelection,
|
||||
trackBedSelection,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</BookingFlowTrackingProvider>
|
||||
{children}
|
||||
</BookingFlowContextProvider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
"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
|
||||
}
|
||||
Reference in New Issue
Block a user