/** * Types for the GuestMaker Events browser SDK (`/sdk/gm-events.js`). * https://www.guestmaker.ai/developers/events */ export type FunnelStage = "dates" | "room" | "extras" | "details" | "payment" export interface InitOptions { /** The PUBLIC browser key (`gme_pk_…`). Never a `gme_sk_` secret key. */ key: string /** Defaults to the origin the script was loaded from. */ endpoint?: string /** Your hotel code from Settings → Properties, added to every event. */ hotelCode?: string hotelId?: string /** Log what the SDK does to the console. */ debug?: boolean /** Remember `identify()` for the tab so a multi-page checkout still knows the guest. Default true; stored in sessionStorage only. */ persistContact?: boolean /** Queue events until `allow()` is called (your cookie banner). */ waitForConsent?: boolean } export interface Contact { email?: string phone?: string first_name?: string last_name?: string language?: string } export interface Consent { email_marketing: boolean /** The exact sentence the guest agreed to. Without it the tick is ignored. */ text?: string captured_at?: string language?: string form_id?: string } export interface EventContext { hotel_id?: string hotel_code?: string hotel_name?: string stage?: FunnelStage check_in?: string check_out?: string adults?: number children?: number rooms?: number room_name?: string rate_name?: string value?: number currency?: string cart_id?: string session_id?: string resume_url?: string page_url?: string referrer?: string } export interface TrackData { contact?: Contact consent?: Consent context?: EventContext properties?: Record idempotencyKey?: string /** Log it and validate it, but change nothing. */ test?: boolean } export interface GMEventsApi { readonly version: string init(options: InitOptions): void track(event: string, data?: TrackData): void identify(contact: Contact, options?: { consent?: Consent }): void abandonOnLeave(options: { getCart: () => (EventContext & { cart_id: string }) | null | undefined }): void completed(cart?: EventContext): void allow(): void deny(): void flush(): void reset(): void } /** The `gme('command', …)` function analytics-style snippets use, so the script can load async. */ export type GmeCommand = ((command: keyof Omit, ...args: unknown[]) => void) & { q?: unknown[] } declare global { interface Window { GMEvents?: GMEventsApi gme?: GmeCommand } }