Merged in fix/BOOK-459-tracking-search (pull request #2984)
fix(BOOK-459): update searchTerm to city or hotelname * fix(BOOK-459): update searchTerm to city or hotelname Approved-by: Erik Tiekstra
This commit is contained in:
@@ -7,7 +7,6 @@ import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
import { useBookingFlowConfig } from "../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import { clearPaymentInfoSessionStorage } from "../../../components/EnterDetails/Payment/helpers"
|
||||
import useLang from "../../../hooks/useLang"
|
||||
import { useSearchHistory } from "../../../hooks/useSearchHistory"
|
||||
import { useBookingConfirmationStore } from "../../../stores/booking-confirmation"
|
||||
import { getTracking } from "./tracking"
|
||||
|
||||
@@ -37,9 +36,6 @@ export default function BookingConfirmationTracking({
|
||||
sessionStorage.setItem("loadedBookingConfirmationRefId", refId)
|
||||
}, [refId])
|
||||
|
||||
const searchHistory = useSearchHistory()
|
||||
const searchTerm = searchHistory.searchHistory[0]?.name
|
||||
|
||||
let trackingData = null
|
||||
|
||||
if (bookingRooms.every(Boolean)) {
|
||||
@@ -49,8 +45,7 @@ export default function BookingConfirmationTracking({
|
||||
bookingConfirmation.booking,
|
||||
bookingConfirmation.hotel,
|
||||
rooms,
|
||||
config,
|
||||
searchTerm
|
||||
config
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,7 @@ export function getTracking(
|
||||
booking: BookingConfirmation["booking"],
|
||||
hotel: BookingConfirmation["hotel"],
|
||||
rooms: Room[],
|
||||
config: Pick<BookingFlowConfig, "bookingCodeEnabled">,
|
||||
searchTerm?: string
|
||||
config: Pick<BookingFlowConfig, "bookingCodeEnabled">
|
||||
) {
|
||||
const arrivalDate = new Date(booking.checkInDate)
|
||||
const departureDate = new Date(booking.checkOutDate)
|
||||
@@ -160,7 +159,7 @@ export function getTracking(
|
||||
points: booking.roomPoints > 0 ? booking.roomPoints : undefined,
|
||||
roomPrice: rooms.reduce((total, room) => total + room.roomPrice, 0),
|
||||
roomTypeCode: rooms.map((r) => r.roomTypeCode ?? "").join(","),
|
||||
searchTerm,
|
||||
searchTerm: hotel.name,
|
||||
searchType: "hotel",
|
||||
specialRoomType: rooms
|
||||
.map((room) => getSpecialRoomType(room.packages))
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useSessionId } from "@scandic-hotels/common/hooks/useSessionId"
|
||||
import useStickyPosition from "@scandic-hotels/common/hooks/useStickyPosition"
|
||||
import { Alert } from "@scandic-hotels/design-system/Alert"
|
||||
import { trackNoAvailability } from "@scandic-hotels/tracking/NoAvailabilityTracking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
|
||||
|
||||
import useLang from "../../../../hooks/useLang"
|
||||
@@ -169,6 +170,7 @@ export default function BookingAlert({ isVisible = false }: BookingAlertProps) {
|
||||
function useNoAvailabilityTracking() {
|
||||
const { fromDate, toDate, hotelId, bookingCode, searchType, rooms } =
|
||||
useEnterDetailsStore((state) => state.booking)
|
||||
const hotelName = useEnterDetailsStore((state) => state.hotelName)
|
||||
const lang = useLang()
|
||||
const sessionId = useSessionId()
|
||||
|
||||
@@ -186,12 +188,13 @@ function useNoAvailabilityTracking() {
|
||||
trackNoAvailability({
|
||||
specialRoomType,
|
||||
lang,
|
||||
searchTerm: hotelId,
|
||||
searchTerm: hotelName,
|
||||
fromDate,
|
||||
toDate,
|
||||
hotelId,
|
||||
noOfRooms: rooms.length,
|
||||
searchType,
|
||||
searchType: "hotel",
|
||||
rewardNight: searchType === SEARCH_TYPE_REDEMPTION ? "yes" : "no",
|
||||
bookingCode: bookingCode ?? "n/a",
|
||||
pageId: "details",
|
||||
pageName: "hotelreservation|details",
|
||||
@@ -203,9 +206,10 @@ function useNoAvailabilityTracking() {
|
||||
[
|
||||
specialRoomType,
|
||||
lang,
|
||||
hotelId,
|
||||
hotelName,
|
||||
fromDate,
|
||||
toDate,
|
||||
hotelId,
|
||||
rooms.length,
|
||||
searchType,
|
||||
bookingCode,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
|
||||
|
||||
import { useBookingFlowConfig } from "../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import { useSearchHistory } from "../../../hooks/useSearchHistory"
|
||||
import { useEnterDetailsStore } from "../../../stores/enter-details"
|
||||
import { getTracking } from "./tracking"
|
||||
|
||||
@@ -33,8 +32,6 @@ export default function EnterDetailsTrackingWrapper({
|
||||
breakfastPackages: state.breakfastPackages,
|
||||
}))
|
||||
const config = useBookingFlowConfig()
|
||||
const searchHistory = useSearchHistory()
|
||||
const searchTerm = searchHistory.searchHistory[0]?.name
|
||||
|
||||
const { hotelsTrackingData, pageTrackingData, ancillaries } = getTracking(
|
||||
booking,
|
||||
@@ -44,8 +41,7 @@ export default function EnterDetailsTrackingWrapper({
|
||||
lang,
|
||||
storedRooms,
|
||||
breakfastPackages,
|
||||
config,
|
||||
searchTerm
|
||||
config
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
@@ -36,8 +36,7 @@ export function getTracking(
|
||||
lang: Lang,
|
||||
storedRooms: RoomState[],
|
||||
breakfastPackages: BreakfastPackages,
|
||||
config: Pick<BookingFlowConfig, "bookingCodeEnabled">,
|
||||
searchTerm?: string
|
||||
config: Pick<BookingFlowConfig, "bookingCodeEnabled">
|
||||
) {
|
||||
const arrivalDate = new Date(booking.fromDate)
|
||||
const departureDate = new Date(booking.toDate)
|
||||
@@ -205,7 +204,7 @@ export function getTracking(
|
||||
// @ts-expect-error - redemption object doesn't exist error
|
||||
rooms.find((room) => "redemption" in room.roomRate)?.roomRate.redemption
|
||||
.localPrice.pointsPerStay ?? "n/a",
|
||||
searchTerm,
|
||||
searchTerm: hotel.name,
|
||||
searchType: "hotel",
|
||||
specialRoomType: rooms
|
||||
.map((room) => getSpecialRoomType(room.packages))
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useIntl } from "react-intl"
|
||||
import { useSessionId } from "@scandic-hotels/common/hooks/useSessionId"
|
||||
import { toast } from "@scandic-hotels/design-system/Toast"
|
||||
import { trackNoAvailability } from "@scandic-hotels/tracking/NoAvailabilityTracking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
|
||||
|
||||
import useLang from "../../hooks/useLang"
|
||||
@@ -16,9 +17,13 @@ import type { SelectRateBooking } from "../../types/components/selectRate/select
|
||||
|
||||
type AvailabilityErrorProps = {
|
||||
booking: SelectRateBooking
|
||||
hotelName: string
|
||||
}
|
||||
|
||||
export default function AvailabilityError({ booking }: AvailabilityErrorProps) {
|
||||
export default function AvailabilityError({
|
||||
booking,
|
||||
hotelName,
|
||||
}: AvailabilityErrorProps) {
|
||||
const intl = useIntl()
|
||||
const pathname = usePathname()
|
||||
const searchParams = useSearchParams()
|
||||
@@ -53,13 +58,14 @@ export default function AvailabilityError({ booking }: AvailabilityErrorProps) {
|
||||
|
||||
trackNoAvailability({
|
||||
specialRoomType,
|
||||
searchTerm: hotelId,
|
||||
searchTerm: hotelName,
|
||||
lang,
|
||||
fromDate,
|
||||
toDate,
|
||||
noOfRooms: rooms.length,
|
||||
searchType,
|
||||
searchType: "hotel",
|
||||
hotelId,
|
||||
rewardNight: searchType === SEARCH_TYPE_REDEMPTION ? "yes" : "no",
|
||||
bookingCode,
|
||||
pageId: "select-rate",
|
||||
pageName: "hotelreservation|select-rate",
|
||||
@@ -70,11 +76,12 @@ export default function AvailabilityError({ booking }: AvailabilityErrorProps) {
|
||||
})
|
||||
}, [
|
||||
rooms,
|
||||
hotelId,
|
||||
hotelName,
|
||||
lang,
|
||||
fromDate,
|
||||
toDate,
|
||||
searchType,
|
||||
hotelId,
|
||||
bookingCode,
|
||||
sessionId,
|
||||
])
|
||||
|
||||
@@ -26,7 +26,7 @@ export function SelectRateTracking({ hotelData, booking }: TrackingProps) {
|
||||
|
||||
const { fromDate, toDate } = getValidDates(booking.fromDate, booking.toDate)
|
||||
|
||||
const { rooms, searchType, bookingCode, city: paramCity } = booking
|
||||
const { rooms, searchType, bookingCode } = booking
|
||||
|
||||
const arrivalDate = fromDate.toDate()
|
||||
const departureDate = toDate.toDate()
|
||||
@@ -47,7 +47,6 @@ export function SelectRateTracking({ hotelData, booking }: TrackingProps) {
|
||||
hotelName: hotelData.hotel.name,
|
||||
country: hotelData.hotel.address.country,
|
||||
hotelCity: hotelData.hotel.address.city,
|
||||
paramCity,
|
||||
bookingCode,
|
||||
isRedemption: searchType === SEARCH_TYPE_REDEMPTION,
|
||||
specialRoomType,
|
||||
|
||||
@@ -24,7 +24,6 @@ type SelectRateTrackingInput = {
|
||||
hotelName: string
|
||||
country: string | undefined
|
||||
hotelCity: string | undefined
|
||||
paramCity: string | undefined
|
||||
bookingCode?: string
|
||||
isRedemption?: boolean
|
||||
specialRoomType?: string
|
||||
@@ -39,7 +38,6 @@ export function getSelectRateTracking({
|
||||
hotelName,
|
||||
country,
|
||||
hotelCity,
|
||||
paramCity,
|
||||
bookingCode,
|
||||
isRedemption = false,
|
||||
specialRoomType,
|
||||
@@ -80,7 +78,7 @@ export function getSelectRateTracking({
|
||||
noOfChildren: childrenInRoom?.map((kids) => kids?.length ?? 0).join(","),
|
||||
noOfRooms: rooms?.length ?? 0,
|
||||
region: hotelCity,
|
||||
searchTerm: paramCity ?? hotelName,
|
||||
searchTerm: hotelName,
|
||||
searchType: "hotel",
|
||||
bookingCode: bookingCode ?? "n/a",
|
||||
rewardNight: isRedemption ? "yes" : "no",
|
||||
|
||||
@@ -87,7 +87,7 @@ export async function SelectRate({
|
||||
/>
|
||||
)}
|
||||
|
||||
<AvailabilityError booking={booking} />
|
||||
<AvailabilityError booking={booking} hotelName={hotelData.hotel.name} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ type DetailsProviderProps = React.PropsWithChildren & {
|
||||
searchParamsStr: string
|
||||
user: User | null
|
||||
vat: number
|
||||
hotelName: string
|
||||
roomCategories: RoomCategories
|
||||
}
|
||||
|
||||
@@ -53,6 +54,7 @@ export default function EnterDetailsProvider({
|
||||
searchParamsStr,
|
||||
user,
|
||||
vat,
|
||||
hotelName,
|
||||
roomCategories,
|
||||
}: DetailsProviderProps) {
|
||||
// This state is needed to be able to use defaultValues for
|
||||
@@ -93,6 +95,7 @@ export default function EnterDetailsProvider({
|
||||
isFlexRate: room.isFlexRate,
|
||||
})),
|
||||
vat,
|
||||
hotelName,
|
||||
roomCategories,
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export async function AlternativeHotelsMapPage({
|
||||
departureDate,
|
||||
rooms: booking.rooms,
|
||||
hotelsResult: hotels.length,
|
||||
searchTerm: isAlternativeFor ? booking.hotelId : cityIdentifier,
|
||||
searchTerm: isAlternativeFor ? isAlternativeFor.name : cityIdentifier,
|
||||
country: hotels?.[0]?.hotel.address.country,
|
||||
hotelCity: hotels?.[0]?.hotel.address.city,
|
||||
bookingCode: booking.bookingCode,
|
||||
|
||||
@@ -102,7 +102,7 @@ export async function AlternativeHotelsPage({
|
||||
rooms: booking.rooms,
|
||||
hotelsResult: hotels?.length ?? 0,
|
||||
searchTerm: searchDetails.hotel
|
||||
? booking.hotelId
|
||||
? searchDetails.hotel.name
|
||||
: searchDetails.cityIdentifier,
|
||||
country: hotels?.[0]?.hotel.address.country,
|
||||
hotelCity: hotels?.[0]?.hotel.address.city,
|
||||
|
||||
@@ -128,6 +128,7 @@ export async function EnterDetailsPage({
|
||||
rooms={rooms}
|
||||
searchParamsStr={selectRoomParams.toString()}
|
||||
user={user}
|
||||
hotelName={hotel.name}
|
||||
vat={hotel.vat}
|
||||
roomCategories={hotelData.roomCategories}
|
||||
>
|
||||
|
||||
@@ -99,7 +99,7 @@ export async function SelectHotelMapPage({
|
||||
departureDate,
|
||||
rooms: booking.rooms,
|
||||
hotelsResult: hotels.length,
|
||||
searchTerm: isAlternativeFor ? booking.hotelId : cityIdentifier,
|
||||
searchTerm: isAlternativeFor ? isAlternativeFor.name : cityIdentifier,
|
||||
country: hotels?.[0]?.hotel.address.country,
|
||||
hotelCity: hotels?.[0]?.hotel.address.city,
|
||||
bookingCode: booking.bookingCode,
|
||||
|
||||
@@ -371,6 +371,7 @@ export function createDetailsStore(
|
||||
searchParamString: searchParams,
|
||||
totalPrice: initialTotalPrice,
|
||||
vat: initialState.vat,
|
||||
hotelName: initialState.hotelName,
|
||||
defaultCurrency: initialTotalPrice.local.currency,
|
||||
preSubmitCallbacks: {},
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ export type InitialState = {
|
||||
booking: DetailsBooking
|
||||
rooms: InitialRoomData[]
|
||||
vat: number
|
||||
hotelName: string
|
||||
roomCategories: RoomCategories
|
||||
}
|
||||
|
||||
@@ -108,6 +109,7 @@ export interface DetailsState {
|
||||
searchParamString: string
|
||||
totalPrice: Price
|
||||
vat: number
|
||||
hotelName: string
|
||||
roomCategories: RoomCategories
|
||||
defaultCurrency: CurrencyEnum
|
||||
preSubmitCallbacks: Record<string, () => void>
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
type TrackingSDKHotelInfo,
|
||||
type TrackingSDKPageData,
|
||||
} from "@scandic-hotels/tracking/types"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import { trackEvent } from "./base"
|
||||
import { createSDKPageObject } from "./pageview"
|
||||
@@ -88,6 +87,7 @@ type TrackNoAvailabilityParams = {
|
||||
searchType?: string
|
||||
bookingCode?: string
|
||||
searchTerm: string
|
||||
rewardNight: string
|
||||
pageId: string
|
||||
pageName: string
|
||||
pageType: string
|
||||
@@ -107,6 +107,7 @@ export function trackNoAvailability({
|
||||
searchType,
|
||||
bookingCode,
|
||||
searchTerm,
|
||||
rewardNight,
|
||||
pageId,
|
||||
pageName,
|
||||
pageType,
|
||||
@@ -128,7 +129,7 @@ export function trackNoAvailability({
|
||||
leadTime: differenceInCalendarDays(arrivalDate, new Date()),
|
||||
noOfRooms,
|
||||
bookingCode: bookingCode ?? "n/a",
|
||||
rewardNight: searchType === SEARCH_TYPE_REDEMPTION ? "yes" : "no",
|
||||
rewardNight,
|
||||
bookingTypeofDay: isWeekend(arrivalDate) ? "weekend" : "weekday",
|
||||
duration: differenceInCalendarDays(departureDate, arrivalDate),
|
||||
specialRoomType,
|
||||
|
||||
Reference in New Issue
Block a user