Merged in fix/SW-3020-tracking-card-type (pull request #2431)
fix(SW-3020)-tracking-card-type * fix(SW-3020): add card type for guarantee success * fix(SW-3020): fix pr comment Approved-by: Tobias Johansson
This commit is contained in:
@@ -100,6 +100,7 @@ export default async function PaymentCallbackPage(
|
|||||||
refId={refId}
|
refId={refId}
|
||||||
sig={sig}
|
sig={sig}
|
||||||
successRedirectUrl={confirmationUrl}
|
successRedirectUrl={confirmationUrl}
|
||||||
|
cardType={booking.guaranteeInfo?.cardType}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import { BookingStatusEnum, MEMBERSHIP_FAILED_ERROR } from "@/constants/booking"
|
|||||||
|
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||||
import { useHandleBookingStatus } from "@/hooks/booking/useHandleBookingStatus"
|
import { useHandleBookingStatus } from "@/hooks/booking/useHandleBookingStatus"
|
||||||
import { trackEvent } from "@/utils/tracking/base"
|
|
||||||
|
|
||||||
import { clearGlaSessionStorage, readGlaFromSessionStorage } from "./helpers"
|
|
||||||
import TimeoutSpinner from "./TimeoutSpinner"
|
import TimeoutSpinner from "./TimeoutSpinner"
|
||||||
|
import { trackGuaranteeBookingSuccess } from "./tracking"
|
||||||
|
|
||||||
const validBookingStatuses = [
|
const validBookingStatuses = [
|
||||||
BookingStatusEnum.PaymentSucceeded,
|
BookingStatusEnum.PaymentSucceeded,
|
||||||
@@ -21,12 +20,14 @@ interface HandleStatusPollingProps {
|
|||||||
refId: string
|
refId: string
|
||||||
sig: string
|
sig: string
|
||||||
successRedirectUrl: string
|
successRedirectUrl: string
|
||||||
|
cardType?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function HandleSuccessCallback({
|
export default function HandleSuccessCallback({
|
||||||
refId,
|
refId,
|
||||||
sig,
|
sig,
|
||||||
successRedirectUrl,
|
successRedirectUrl,
|
||||||
|
cardType,
|
||||||
}: HandleStatusPollingProps) {
|
}: HandleStatusPollingProps) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@@ -57,23 +58,7 @@ export default function HandleSuccessCallback({
|
|||||||
bookingStatus.booking.reservationStatus as BookingStatusEnum
|
bookingStatus.booking.reservationStatus as BookingStatusEnum
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const glaSessionData = readGlaFromSessionStorage()
|
trackGuaranteeBookingSuccess(cardType)
|
||||||
if (glaSessionData) {
|
|
||||||
trackEvent({
|
|
||||||
event: "guaranteeBookingSuccess",
|
|
||||||
hotelInfo: {
|
|
||||||
lateArrivalGuarantee: glaSessionData.lateArrivalGuarantee,
|
|
||||||
hotelId: glaSessionData.hotelId,
|
|
||||||
guaranteedProduct: "room",
|
|
||||||
},
|
|
||||||
paymentInfo: {
|
|
||||||
hotelId: glaSessionData.hotelId,
|
|
||||||
type: glaSessionData.paymentMethod,
|
|
||||||
isSavedCreditCard: glaSessionData.isSavedCreditCard,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
clearGlaSessionStorage()
|
|
||||||
}
|
|
||||||
// a successful booking can still have membership errors
|
// a successful booking can still have membership errors
|
||||||
const membershipFailedError = bookingStatus.booking.errors.find(
|
const membershipFailedError = bookingStatus.booking.errors.find(
|
||||||
(e) => e.errorCode === MEMBERSHIP_FAILED_ERROR
|
(e) => e.errorCode === MEMBERSHIP_FAILED_ERROR
|
||||||
@@ -84,7 +69,7 @@ export default function HandleSuccessCallback({
|
|||||||
|
|
||||||
router.replace(`${successRedirectUrl}${errorParam}`)
|
router.replace(`${successRedirectUrl}${errorParam}`)
|
||||||
}
|
}
|
||||||
}, [bookingStatus, successRedirectUrl, router])
|
}, [bookingStatus, cardType, successRedirectUrl, router])
|
||||||
|
|
||||||
if (isTimeout || error) {
|
if (isTimeout || error) {
|
||||||
return <TimeoutSpinner />
|
return <TimeoutSpinner />
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { trackEvent } from "@/utils/tracking/base"
|
||||||
|
|
||||||
|
import { clearGlaSessionStorage, readGlaFromSessionStorage } from "./helpers"
|
||||||
|
|
||||||
|
export function trackGuaranteeBookingSuccess(cardType?: string) {
|
||||||
|
const glaSessionData = readGlaFromSessionStorage()
|
||||||
|
if (glaSessionData) {
|
||||||
|
trackEvent({
|
||||||
|
event: "guaranteeBookingSuccess",
|
||||||
|
hotelInfo: {
|
||||||
|
lateArrivalGuarantee: glaSessionData.lateArrivalGuarantee,
|
||||||
|
hotelId: glaSessionData.hotelId,
|
||||||
|
guaranteedProduct: "room",
|
||||||
|
},
|
||||||
|
paymentInfo: {
|
||||||
|
hotelId: glaSessionData.hotelId,
|
||||||
|
type: cardType ?? glaSessionData.paymentMethod,
|
||||||
|
isSavedCreditCard: glaSessionData.isSavedCreditCard,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
clearGlaSessionStorage()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user