Files
web/types/components/tracking.ts
Bianca Widstam 541b91e34c Merged in feat/SW-1281-ancillaries-add-flow (pull request #1399)
Feat/SW-1281 ancillaries add flow

* feat(SW-1546): update design

* feat(SW-1546): show points only if logged in

* feat(SW-1546): always show points

* feat(SW-1281): ancillary add flow initial

* feat(SW-1546): add api call

* feat(SW-1281): refactor naming and break out components

* feat(SW-1281): handle back button

* feat(SW-1281): make mobile cards clickable

* feat(SW-1281): refactor spread ancillaries

* feat(SW-1281): add deliverytimes

* feat(SW-1281): rebase master

* feat(SW-1281): add design for logged in or not

* feat(SW-1281): add design

* feat(SW-1281): add mobile design

* feat(SW-1281): fix carousel

* feat(SW-1281): show deliverytime only if ancillary has not been added

* feat(SW-1281): add design

* feat(SW-1281): add translations

* feat(SW-1281): add translations

* feat(SW-1281): add translations

* feat(SW-1281): base dates on check in date only

* feat(SW-1281): fix show correct toast when no valid data

* feat(SW-1281): hande logic if deliverytime is not required

* feat(SW-1281): fix max width for mobile

* feat(SW-1281): refactor after pr comment


Approved-by: Niclas Edenvin
Approved-by: Linus Flood
2025-02-26 07:20:45 +00:00

192 lines
5.0 KiB
TypeScript

import type { Lang } from "@/constants/languages"
import type { MembershipLevel } from "@/constants/membershipLevels"
export enum TrackingChannelEnum {
"scandic-friends" = "scandic-friends",
"static-content-page" = "static-content-page",
"hotelreservation" = "hotelreservation",
"collection-page" = "collection-page",
"destination-overview-page" = "destination-overview-page",
"destination-page" = "destination-page",
"hotels" = "hotels",
"start-page" = "start-page",
}
export type TrackingChannel = keyof typeof TrackingChannelEnum
export type TrackingSDKPageData = {
pageId: string
createDate?: string
publishDate?: string
domainLanguage: Lang
pageType: string
channel: TrackingChannel
siteVersion: "new-web"
pageName: string
domain?: string
siteSections: string
pageLoadTime?: number // Page load time in seconds
sessionId?: string | null
}
export enum LoginTypeEnum {
email = "email",
"membership number" = "membership number",
"email link" = "email link",
}
export type LoginType = keyof typeof LoginTypeEnum
export type TrackingSDKUserData = {
loginStatus: "logged in" | "Non-logged in"
loginType?: LoginType
memberId?: string
membershipNumber?: string
memberLevel?: MembershipLevel
noOfNightsStayed?: number
totalPointsAvailableToSpend?: number
loginAction?: "login success"
}
export type TrackingSDKHotelInfo = {
hotelID?: string
arrivalDate?: string
departureDate?: string
noOfAdults?: number
noOfChildren?: number
ageOfChildren?: string // "10", "2,5,10"
//rewardNight?: boolean
//bookingCode?: string
//bookingCodeAvailability?: boolean
leadTime?: number // Number of days from booking date until arrivalDate
noOfRooms?: number
//bonuscheque?: boolean
childBedPreference?: string
duration?: number // Number of nights to stay
availableResults?: number // Number of hotels to choose from after a city search
bookingTypeofDay?: "weekend" | "weekday"
searchTerm?: string
roomPrice?: number
rateCode?: string
rateCodeCancellationRule?: string
rateCodeName?: string // Scandic Friends - full flex inkl. frukost
rateCodeType?: string // regular, promotion etc
revenueCurrencyCode?: string // SEK, DKK, NOK, EUR
roomTypeCode?: string
roomTypePosition?: number // Which position the room had in the list of available rooms
roomTypeName?: string
bedType?: string
bedTypePosition?: number // Which position the bed type had in the list of available bed types
breakfastOption?: string // "no breakfast" or "breakfast buffet"
bnr?: string // Booking number
analyticsrateCode?: "flex" | "change" | "save" | string
specialRoomType?: string // allergy room, pet-friendly, accesibillity room
//modifyValues?: string // <price:<value>,roomtype:value>,bed:<value,<breakfast:value>
country?: string // Country of the hotel
region?: string // Region of the hotel
discount?: number
totalPrice?: number
lowestRoomPrice?: number
searchType?: "destination" | "hotel"
ancillaries?: Ancillary[]
}
export type Ancillary = {
productId: string
productUnits?: number
hotelid?: string
productPoints: number
productPrice: number
productType: string
productName: string
productCategory: string
}
export type TrackingSDKPaymentInfo = {
edccCurrencyFrom?: string
edccCurrencyTo?: string
isedcc?: string
isSavedCard?: boolean
isCreditCard?: boolean
paymentStatus?: "confirmed"
paymentType?: string
}
export type TrackingSDKProps = {
pageData: TrackingSDKPageData
userData: TrackingSDKUserData
hotelInfo?: TrackingSDKHotelInfo
paymentInfo?: TrackingSDKPaymentInfo
}
export type TrackingSDKData = TrackingSDKPageData & {
pathName: string
}
type BasePaymentEvent = {
event: string
hotelId: string | undefined
method?: string
isSavedCreditCard?: boolean
smsEnable?: boolean
status: "attempt" | "cancelled" | "failed"
}
export type PaymentAttemptStartEvent = BasePaymentEvent
export type PaymentCancelEvent = BasePaymentEvent
export type PaymentFailEvent = BasePaymentEvent & {
errorMessage?: string
}
export type PaymentEvent =
| PaymentAttemptStartEvent
| PaymentCancelEvent
| PaymentFailEvent
export type LowestRoomPriceEvent = {
hotelId: string | null
arrivalDate: string | null
departureDate: string | null
lowestPrice: number
currency?: string
}
// Old tracking setup types:
// TODO: Remove this when we delete "current site"
export type TrackingProps = {
pageData: {
pageId: string
createdDate: string
publishedDate: string
englishUrl?: string
lang: Lang
}
}
export type TrackingData = {
lang: Lang
englishUrl?: string
pathName: string
queryString: string
pageId: string
publishedDate: string
createdDate: string
}
export type SiteSectionObject = {
sitesection1: string
sitesection2: string
sitesection3: string
sitesection4: string
sitesection5: string
sitesection6: string
}
export type TrackingPosition =
| "top menu"
| "hamburger menu"
| "join scandic friends sidebar"
| "enter details"
| "my stay"