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,64 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { trackEvent } from "@scandic-hotels/tracking/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",
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
"use client"
|
||||
import { trackEvent } from "@scandic-hotels/tracking/base"
|
||||
|
||||
export function trackAccordionClick(option: string) {
|
||||
trackEvent({
|
||||
event: "accordionClick",
|
||||
accordion: {
|
||||
action: "accordion open click",
|
||||
option,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function trackOpenSidePeekEvent({
|
||||
name,
|
||||
hotelId,
|
||||
includePathname,
|
||||
roomTypeCode,
|
||||
}: {
|
||||
name: string | null
|
||||
hotelId: string
|
||||
includePathname?: boolean
|
||||
roomTypeCode?: string | null
|
||||
}) {
|
||||
trackEvent({
|
||||
event: "openSidePeek",
|
||||
hotelInfo: {
|
||||
hotelId: hotelId,
|
||||
},
|
||||
cta: {
|
||||
name,
|
||||
...(roomTypeCode ? { roomTypeCode } : {}),
|
||||
...(includePathname ? { pathName: window.location.pathname } : {}),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
export { trackAccordionClick, trackOpenSidePeekEvent } from "./componentEvents"
|
||||
export { trackHotelMapClick, trackHotelTabClick } from "./hotelPage"
|
||||
export { trackCancelStay, trackMyStayPageLink } from "./myStay"
|
||||
export { trackClick } from "@scandic-hotels/tracking/base"
|
||||
export {
|
||||
trackAccordionClick,
|
||||
trackOpenSidePeekEvent,
|
||||
} from "@scandic-hotels/tracking/componentEvents"
|
||||
export {
|
||||
trackFooterClick,
|
||||
trackLoginClick,
|
||||
trackSocialMediaClick,
|
||||
} from "./navigation"
|
||||
export { trackPaymentEvent, trackUpdatePaymentMethod } from "./payment"
|
||||
export { trackClick } from "@scandic-hotels/tracking/base"
|
||||
} from "@scandic-hotels/tracking/navigation"
|
||||
export { trackPageViewStart } from "@scandic-hotels/tracking/pageview"
|
||||
export {
|
||||
trackPaymentEvent,
|
||||
trackUpdatePaymentMethod,
|
||||
} from "@scandic-hotels/tracking/payment"
|
||||
|
||||
@@ -35,32 +35,6 @@ export function trackMyStayPageLink(ctaName: string) {
|
||||
})
|
||||
}
|
||||
|
||||
export function trackGlaSaveCardAttempt({
|
||||
hotelId,
|
||||
hasSavedCreditCard,
|
||||
creditCardType,
|
||||
lateArrivalGuarantee,
|
||||
}: {
|
||||
hotelId: string
|
||||
hasSavedCreditCard: boolean
|
||||
creditCardType?: string
|
||||
lateArrivalGuarantee: "mandatory" | "yes" | "no" | "na"
|
||||
}) {
|
||||
trackEvent({
|
||||
event: "glaCardSaveAttempt",
|
||||
hotelInfo: {
|
||||
hotelId,
|
||||
lateArrivalGuarantee,
|
||||
guaranteedProduct: "room",
|
||||
},
|
||||
paymentInfo: {
|
||||
status: "glacardsaveattempt",
|
||||
isSavedCreditCard: hasSavedCreditCard,
|
||||
type: creditCardType,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function buildAncillariesTracking(
|
||||
packages: {
|
||||
code: string
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import { trackEvent } from "@scandic-hotels/tracking/base"
|
||||
|
||||
import type { TrackingPosition } from "@scandic-hotels/tracking/types"
|
||||
|
||||
export function trackFooterClick(group: string, name: string) {
|
||||
trackEvent({
|
||||
event: "footer link",
|
||||
footer: {
|
||||
footerLinkClicked: `${group}:${name}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function trackSocialMediaClick(socialMediaName: string) {
|
||||
trackEvent({
|
||||
event: "social media",
|
||||
social: {
|
||||
socialIconClicked: socialMediaName,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function trackLoginClick(position: TrackingPosition) {
|
||||
trackEvent({
|
||||
event: "loginStart",
|
||||
login: {
|
||||
position,
|
||||
action: "login start",
|
||||
ctaName: "login",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function trackLanguageSwitchClick(fromLang: string, toLang: string) {
|
||||
trackEvent({
|
||||
event: "languageSelection",
|
||||
language: {
|
||||
fromSelection: fromLang,
|
||||
toSelection: toLang,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import { trackEvent } from "@scandic-hotels/tracking/base"
|
||||
|
||||
import type {
|
||||
PaymentEvent,
|
||||
PaymentFailEvent,
|
||||
} from "@scandic-hotels/tracking/types"
|
||||
|
||||
function isPaymentFailEvent(event: PaymentEvent): event is PaymentFailEvent {
|
||||
return "errorMessage" in event
|
||||
}
|
||||
|
||||
export function trackUpdatePaymentMethod({ method }: { method: string }) {
|
||||
trackEvent({
|
||||
event: "paymentSelection",
|
||||
hotelInfo: {
|
||||
hotelId: "", // TODO: Needs to be verified with analytics if this should even be here
|
||||
},
|
||||
cta: {
|
||||
name: method,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function trackPaymentEvent(paymentEvent: PaymentEvent) {
|
||||
const paymentAttempt = {
|
||||
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,
|
||||
},
|
||||
}
|
||||
trackEvent(paymentAttempt)
|
||||
}
|
||||
Reference in New Issue
Block a user