import { Item } from './gtag.js'; import { EventName, TrackName, TrackProperties } from './types.js'; declare const NON_AD_EVENTS: string[]; /** * Content item shared by `contents` and `plan_enrollment` events. * https://developers.openai.com/ads/supported-events */ type ContentItem = { id?: string; name?: string; content_type?: string; quantity?: number; /** Per-item monetary value in ISO 4217 minor units (e.g., 12,999 = $129.99 USD). */ amount?: number; currency?: string; }; type ContentsData = { type: 'contents'; /** Monetary value in ISO 4217 minor units (e.g., 12,999 = $129.99 USD). */ amount?: number; currency?: string; contents?: ContentItem[]; }; type CustomerActionData = { type: 'customer_action'; amount?: number; currency?: string; }; type PlanEnrollmentData = { type: 'plan_enrollment'; plan_id?: string; amount?: number; currency?: string; contents?: ContentItem[]; }; type CustomEventData = { type: 'custom'; amount?: number; currency?: string; contents?: ContentItem[]; }; type EventData = ContentsData | CustomerActionData | PlanEnrollmentData | CustomEventData; /** * Standard event names and the `data` shape each one expects. * https://developers.openai.com/ads/supported-events */ type StandardEvents = { appointment_scheduled: CustomerActionData; checkout_started: ContentsData; contents_viewed: ContentsData; items_added: ContentsData; lead_created: CustomerActionData; order_created: ContentsData; page_viewed: ContentsData; registration_completed: CustomerActionData; subscription_created: PlanEnrollmentData; trial_started: PlanEnrollmentData; }; type StandardEvent = keyof StandardEvents; /** * Identity fields passed to `oaiq("init", ...)` for conversion matching. Email and external id * must be pre-hashed as lowercase 64-char SHA-256 hex strings; the rest are sent as raw values. * https://developers.openai.com/ads/measurement-pixel */ type OAIQUser = { email_sha256?: string; external_id_sha256?: string; /** Two-letter ISO 3166-1 country code (e.g. "US"). */ country?: string; /** Lowercased, max 128 characters. */ city?: string; /** Max 32 characters. */ zip_code?: string; }; type InitConfig = { pixelId: string; /** Log SDK activity to the browser console. */ debug?: boolean; user?: OAIQUser; }; /** * Fourth argument of `oaiq("measure", ...)`. Required for custom events (carries * `custom_event_name`); optional for standard events. */ type MeasureOptions = { /** Shared with the Conversions API to deduplicate the same conversion across browser and server. */ event_id?: string; /** Required for custom events; 1-64 chars of letters, numbers, underscores, or dashes. */ custom_event_name?: string; /** When true, opts the event out of user-level personalization. */ opt_out?: boolean; }; interface OAIQ { oaiq(command: 'init', config: InitConfig): void; oaiq(command: 'measure', event: T, data: StandardEvents[T], options?: MeasureOptions): void; oaiq(command: 'measure', event: 'custom', data: CustomEventData, options: MeasureOptions & { custom_event_name: string; }): void; } /** Convert a major-unit amount (e.g., 129.99) into ISO 4217 minor units (e.g., 12,999). */ declare function toMinorUnits(value?: number, currency?: string): number | undefined; declare function mapContents(items?: Item[], currency?: string): ContentItem[] | undefined; type MappedOAIEvent = { type: StandardEvent | 'custom'; data: EventData; }; /** Map an internal track event onto an OpenAI standard (or custom) conversion event. */ declare function mapOAIEvent(name: TrackName, properties?: TrackProperties): MappedOAIEvent; export { type ContentItem, type ContentsData, type CustomEventData, type CustomerActionData, type EventData, type InitConfig, type MappedOAIEvent, type MeasureOptions, NON_AD_EVENTS, type OAIQ, type OAIQUser, type PlanEnrollmentData, type StandardEvent, type StandardEvents, mapContents, mapOAIEvent, toMinorUnits };