Merged in fix/SW-3442-tracking-event-lowestroomprice- (pull request #2797)
fix(SW-3442): Fixed lowest price tracking and other lint issues * fix(SW-3442): Fixed lowest price tracking and other lint issues Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -14,9 +14,9 @@ import {
|
||||
import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast"
|
||||
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
|
||||
import { readPaymentInfoFromSessionStorage } from "../../../components/EnterDetails/Payment/helpers"
|
||||
import { invertedBedTypeMap } from "../../../utils/SelectRate"
|
||||
import { getSpecialRoomType } from "../../../utils/specialRoomType"
|
||||
import { readPaymentInfoFromSessionStorage } from "../../EnterDetails/Payment/helpers"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { useSelectRateContext } from "../../../../../contexts/SelectRate/SelectRateContext"
|
||||
import { RoomListItem } from "./RoomListItem"
|
||||
import { RoomsListSkeleton } from "./RoomsListSkeleton"
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
"use client"
|
||||
|
||||
import { TRPCClientError } from "@trpc/client"
|
||||
import { useEffect } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
|
||||
import { Alert } from "@scandic-hotels/design-system/Alert"
|
||||
|
||||
import { useSelectRateContext } from "../../../contexts/SelectRate/SelectRateContext"
|
||||
import { trackLowestRoomPrice } from "../Tracking/tracking"
|
||||
import { RateSummary } from "./RateSummary"
|
||||
import Rooms from "./Rooms"
|
||||
import { RoomsContainerSkeleton } from "./RoomsContainerSkeleton"
|
||||
@@ -23,10 +25,26 @@ export function RoomsContainer({}: RoomsContainerProps) {
|
||||
const intl = useIntl()
|
||||
|
||||
const {
|
||||
availability: { error, isFetching, isError },
|
||||
input: { hasError: hasInputError, errorCode },
|
||||
availability: { error, isFetching, isError, data: availabilityData },
|
||||
input: { hasError: hasInputError, errorCode, data: inputData },
|
||||
getLowestRoomPrice,
|
||||
} = useSelectRateContext()
|
||||
|
||||
useEffect(() => {
|
||||
if (availabilityData) {
|
||||
const lowestRoomPrice = getLowestRoomPrice()
|
||||
const booking = inputData?.booking!
|
||||
|
||||
trackLowestRoomPrice({
|
||||
hotelId: booking.hotelId,
|
||||
arrivalDate: booking?.fromDate,
|
||||
departureDate: booking?.toDate,
|
||||
lowestPrice: lowestRoomPrice.price.toString(),
|
||||
currency: lowestRoomPrice.currency,
|
||||
})
|
||||
}
|
||||
}, [availabilityData, inputData, getLowestRoomPrice])
|
||||
|
||||
if (isFetching) {
|
||||
return <RoomsContainerSkeleton />
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
|
||||
|
||||
import { trackEvent } from "@scandic-hotels/tracking/base"
|
||||
import {
|
||||
type LowestRoomPriceEvent,
|
||||
TrackingChannelEnum,
|
||||
type TrackingSDKHotelInfo,
|
||||
type TrackingSDKPageData,
|
||||
@@ -107,3 +109,18 @@ export function getSelectRateTracking({
|
||||
pageTrackingData,
|
||||
}
|
||||
}
|
||||
|
||||
export function trackLowestRoomPrice(event: LowestRoomPriceEvent) {
|
||||
trackEvent({
|
||||
event: "lowestRoomPrice",
|
||||
hotelInfo: {
|
||||
hotelId: event.hotelId,
|
||||
arrivalDate: event.arrivalDate,
|
||||
departureDate: event.departureDate,
|
||||
},
|
||||
viewItemInfo: {
|
||||
lowestPrice: event.lowestPrice,
|
||||
currency: event.currency,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user