Merged in fix/SW-1997-tracking-correct-price-or-points (pull request #1869)
fix(SW-1997): only add points or card if payed with * fix(SW-1997): only add points or card if payed with * fix(SW-1997): use buildAncillaries function Approved-by: Michael Zetterberg
This commit is contained in:
@@ -5,9 +5,13 @@ import { useEffect } from "react"
|
|||||||
|
|
||||||
import { PaymentCallbackStatusEnum } from "@/constants/booking"
|
import { PaymentCallbackStatusEnum } from "@/constants/booking"
|
||||||
|
|
||||||
import { readGlaFromSessionStorage } from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/helpers"
|
import {
|
||||||
|
clearGlaSessionStorage,
|
||||||
|
readGlaFromSessionStorage,
|
||||||
|
} from "@/components/HotelReservation/EnterDetails/Payment/PaymentCallback/helpers"
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||||
import { trackEvent } from "@/utils/tracking/base"
|
import { trackEvent } from "@/utils/tracking/base"
|
||||||
|
import { buildAncillaries } from "@/utils/tracking/myStay"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
buildAncillaryPackages,
|
buildAncillaryPackages,
|
||||||
@@ -42,22 +46,16 @@ export default function TrackGuarantee({
|
|||||||
trackEvent({
|
trackEvent({
|
||||||
event,
|
event,
|
||||||
paymentInfo: { status },
|
paymentInfo: { status },
|
||||||
ancillaries: packages.map((pkg) => ({
|
|
||||||
hotelId: selectedAncillary?.hotelId,
|
|
||||||
productId: pkg.code,
|
|
||||||
productUnits: pkg.quantity,
|
|
||||||
productPoints: selectedAncillary?.points,
|
|
||||||
productDeliveryTime: formData?.deliveryTime,
|
|
||||||
productPrice: selectedAncillary?.price.total,
|
|
||||||
currency: selectedAncillary?.price.currency,
|
|
||||||
productName: selectedAncillary?.title,
|
|
||||||
productCategory: selectedAncillary?.categoryName,
|
|
||||||
})),
|
|
||||||
hotelInfo: {
|
hotelInfo: {
|
||||||
hotelId: selectedAncillary?.hotelId,
|
hotelId: selectedAncillary?.hotelId,
|
||||||
lateArrivalGuarantee: "yes",
|
lateArrivalGuarantee: "yes",
|
||||||
guaranteedProduct: "room + ancillary",
|
guaranteedProduct: "room + ancillary",
|
||||||
},
|
},
|
||||||
|
ancillaries: buildAncillaries(
|
||||||
|
packages,
|
||||||
|
selectedAncillary,
|
||||||
|
formData?.deliveryTime
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +73,7 @@ export default function TrackGuarantee({
|
|||||||
...(errorMessage && { errorMessage }),
|
...(errorMessage && { errorMessage }),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
clearGlaSessionStorage()
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@@ -88,6 +87,7 @@ export default function TrackGuarantee({
|
|||||||
guaranteedProduct: "room",
|
guaranteedProduct: "room",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
clearGlaSessionStorage()
|
||||||
break
|
break
|
||||||
|
|
||||||
case PaymentCallbackStatusEnum.Cancel:
|
case PaymentCallbackStatusEnum.Cancel:
|
||||||
|
|||||||
@@ -44,6 +44,36 @@ export function trackGlaSaveCardAttempt(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildAncillaries(
|
||||||
|
packages: {
|
||||||
|
code: string
|
||||||
|
quantity: number
|
||||||
|
comment?: string
|
||||||
|
}[],
|
||||||
|
selectedAncillary: SelectedAncillary | null | undefined,
|
||||||
|
deliveryTime: string | string[] | null | undefined
|
||||||
|
) {
|
||||||
|
return packages.map((pkg) => {
|
||||||
|
const payedWithCard = pkg.code === selectedAncillary?.id
|
||||||
|
const payedWithPoints = pkg.code === selectedAncillary?.loyaltyCode
|
||||||
|
|
||||||
|
return {
|
||||||
|
productId: pkg.code,
|
||||||
|
productUnits: pkg.quantity,
|
||||||
|
productDeliveryTime: deliveryTime,
|
||||||
|
productName: selectedAncillary?.title,
|
||||||
|
productCategory: selectedAncillary?.categoryName,
|
||||||
|
...(payedWithCard && {
|
||||||
|
productPrice: (selectedAncillary?.price.total ?? 0) * pkg.quantity,
|
||||||
|
currency: selectedAncillary?.price.currency,
|
||||||
|
}),
|
||||||
|
...(payedWithPoints && {
|
||||||
|
productPoints: (selectedAncillary?.points ?? 0) * pkg.quantity,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function trackGlaAncillaryAttempt(
|
export function trackGlaAncillaryAttempt(
|
||||||
savedCreditCard: CreditCard | undefined,
|
savedCreditCard: CreditCard | undefined,
|
||||||
packages: {
|
packages: {
|
||||||
@@ -60,17 +90,7 @@ export function trackGlaAncillaryAttempt(
|
|||||||
status: "glacardsaveattempt",
|
status: "glacardsaveattempt",
|
||||||
type: savedCreditCard?.cardType,
|
type: savedCreditCard?.cardType,
|
||||||
},
|
},
|
||||||
ancillaries: packages.map((pkg) => ({
|
ancillaries: buildAncillaries(packages, selectedAncillary, deliveryTime),
|
||||||
hotelId: selectedAncillary?.hotelId,
|
|
||||||
productId: pkg.code,
|
|
||||||
productUnits: pkg.quantity,
|
|
||||||
productPoints: selectedAncillary?.points,
|
|
||||||
productDeliveryTime: deliveryTime,
|
|
||||||
productPrice: selectedAncillary?.price.total,
|
|
||||||
currency: selectedAncillary?.price.currency,
|
|
||||||
productName: selectedAncillary?.title,
|
|
||||||
productCategory: selectedAncillary?.categoryName,
|
|
||||||
})),
|
|
||||||
hotelInfo: {
|
hotelInfo: {
|
||||||
hotelId: selectedAncillary?.hotelId,
|
hotelId: selectedAncillary?.hotelId,
|
||||||
lateArrivalGuarantee: "yes",
|
lateArrivalGuarantee: "yes",
|
||||||
@@ -104,16 +124,7 @@ export function trackAncillarySuccess(
|
|||||||
status: "glacardsaveconfirmed",
|
status: "glacardsaveconfirmed",
|
||||||
type: cardType,
|
type: cardType,
|
||||||
},
|
},
|
||||||
ancillaries: packages.map((pkg) => ({
|
ancillaries: buildAncillaries(packages, selectedAncillary, deliveryTime),
|
||||||
productId: pkg.code,
|
|
||||||
productUnits: pkg.quantity,
|
|
||||||
productPoints: selectedAncillary?.points,
|
|
||||||
productDeliveryTime: deliveryTime,
|
|
||||||
productPrice: selectedAncillary?.price.total,
|
|
||||||
currency: selectedAncillary?.price.currency,
|
|
||||||
productName: selectedAncillary?.title,
|
|
||||||
productCategory: selectedAncillary?.categoryName,
|
|
||||||
})),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,16 +139,7 @@ export function trackAncillaryFailed(
|
|||||||
) {
|
) {
|
||||||
trackEvent({
|
trackEvent({
|
||||||
event: "GuaranteeFailAncillary",
|
event: "GuaranteeFailAncillary",
|
||||||
ancillaries: packages.map((pkg) => ({
|
ancillaries: buildAncillaries(packages, selectedAncillary, deliveryTime),
|
||||||
productId: pkg.code,
|
|
||||||
productUnits: pkg.quantity,
|
|
||||||
productPoints: selectedAncillary?.points,
|
|
||||||
productDeliveryTime: deliveryTime,
|
|
||||||
productPrice: selectedAncillary?.price.total,
|
|
||||||
currency: selectedAncillary?.price.currency,
|
|
||||||
productName: selectedAncillary?.title,
|
|
||||||
productCategory: selectedAncillary?.categoryName,
|
|
||||||
})),
|
|
||||||
hotelInfo: {
|
hotelInfo: {
|
||||||
hotelId: selectedAncillary?.hotelId,
|
hotelId: selectedAncillary?.hotelId,
|
||||||
lateArrivalGuarantee: "yes",
|
lateArrivalGuarantee: "yes",
|
||||||
|
|||||||
Reference in New Issue
Block a user