Files
web/packages/booking-flow/lib/trackingContext.tsx
Anton Gunnarsson deaba8b5c4 Merged in feat/sw-3241-move-readme-to-booking-flow (pull request #2660)
feat(SW-3241): Move ReadMe to booking-flow and rename to OpenSidePeekButton

* Move ReadMe to booking-flow

* Rename ReadMore to OpenSidePeekButton

* Fix self-referencing import


Approved-by: Joakim Jäderberg
2025-08-19 07:20:44 +00:00

34 lines
813 B
TypeScript

"use client"
import { createContext, useContext } from "react"
export type TrackingFunctions = {
trackBookingSearchClick: (
searchTerm: string,
searchType: "hotel" | "destination"
) => void
trackAccordionItemOpen: (option: string) => void
trackOpenSidePeek: (input: {
name: string | null
hotelId: string
includePathname?: boolean
roomTypeCode?: string | null
}) => void
}
export const TrackingContext = createContext<TrackingFunctions | undefined>(
undefined
)
export const useTrackingContext = (): TrackingFunctions => {
const context = useContext(TrackingContext)
if (!context) {
throw new Error(
"useTrackingContext must be used within a BookingFlowTrackingProvider. Did you forget to use the provider in the consuming app?"
)
}
return context
}