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:
@@ -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(
|
||||
savedCreditCard: CreditCard | undefined,
|
||||
packages: {
|
||||
@@ -60,17 +90,7 @@ export function trackGlaAncillaryAttempt(
|
||||
status: "glacardsaveattempt",
|
||||
type: savedCreditCard?.cardType,
|
||||
},
|
||||
ancillaries: packages.map((pkg) => ({
|
||||
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,
|
||||
})),
|
||||
ancillaries: buildAncillaries(packages, selectedAncillary, deliveryTime),
|
||||
hotelInfo: {
|
||||
hotelId: selectedAncillary?.hotelId,
|
||||
lateArrivalGuarantee: "yes",
|
||||
@@ -104,16 +124,7 @@ export function trackAncillarySuccess(
|
||||
status: "glacardsaveconfirmed",
|
||||
type: cardType,
|
||||
},
|
||||
ancillaries: packages.map((pkg) => ({
|
||||
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,
|
||||
})),
|
||||
ancillaries: buildAncillaries(packages, selectedAncillary, deliveryTime),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -128,16 +139,7 @@ export function trackAncillaryFailed(
|
||||
) {
|
||||
trackEvent({
|
||||
event: "GuaranteeFailAncillary",
|
||||
ancillaries: packages.map((pkg) => ({
|
||||
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,
|
||||
})),
|
||||
ancillaries: buildAncillaries(packages, selectedAncillary, deliveryTime),
|
||||
hotelInfo: {
|
||||
hotelId: selectedAncillary?.hotelId,
|
||||
lateArrivalGuarantee: "yes",
|
||||
|
||||
Reference in New Issue
Block a user