Merged in feat/SW-1472-destination-tracking (pull request #1474)
Feat/SW-1472 destination tracking * feat(SW-1472): Added default tracking for destination overview page * feat(SW-1472): Added default tracking for destination country/city page * feat(SW-1472): moved tracking functions to different files for better overview * feat(SW-1472): added destination page tracking Approved-by: Fredrik Thorsson Approved-by: Matilda Landström
This commit is contained in:
38
apps/scandic-web/utils/tracking/payment.ts
Normal file
38
apps/scandic-web/utils/tracking/payment.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { trackEvent } from "./base"
|
||||
|
||||
import type { PaymentEvent, PaymentFailEvent } from "@/types/components/tracking"
|
||||
|
||||
function isPaymentFailEvent(event: PaymentEvent): event is PaymentFailEvent {
|
||||
return "errorMessage" in event
|
||||
}
|
||||
|
||||
export function trackUpdatePaymentMethod(hotelId: string, method: string) {
|
||||
trackEvent({
|
||||
event: "paymentSelection",
|
||||
hotelInfo: {
|
||||
hotelId: hotelId,
|
||||
},
|
||||
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