import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types'; import { TikTokPixelOptions } from './schemas.js'; type StandardEvents = 'ViewContent' | 'ClickButton' | 'Search' | 'AddToWishlist' | 'AddToCart' | 'InitiateCheckout' | 'AddPaymentInfo' | 'CompletePayment' | 'PlaceAnOrder' | 'Contact' | 'Download' | 'SubmitForm' | 'CompleteRegistration' | 'Subscribe'; interface EventProperties { content_id?: string; content_type?: string; content_name?: string; contents?: Array<{ content_id: string; content_type?: string; content_name?: string; price?: number; quantity?: number; }>; currency?: string; value?: number; description?: string; query?: string; [key: string]: any; } interface IdentifyProperties { email?: string; phone_number?: string; external_id?: string; } type TtqFns = ((cmd: 'track', event: StandardEvents | (string & {}), properties?: EventProperties) => void) & ((cmd: 'page') => void) & ((cmd: 'identify', properties: IdentifyProperties) => void) & ((cmd: (string & {}), ...args: any[]) => void); export interface TikTokPixelApi { ttq: TtqFns & { push: TtqFns; loaded: boolean; queue: any[]; /** Opt user in to tracking. Queued before the script loads; live once `events.js` binds. */ grantConsent: () => void; /** Opt user out of tracking. Queued before the script loads; live once `events.js` binds. */ revokeConsent: () => void; /** Defer consent until an explicit grant/revoke. Queued before the script loads; live once `events.js` binds. */ holdConsent: () => void; }; } declare global { interface Window extends TikTokPixelApi { TiktokAnalyticsObject: string; } } export { TikTokPixelOptions }; export type TikTokPixelInput = RegistryScriptInput; export interface TikTokPixelConsent { /** Call `ttq.grantConsent()`. */ grant: () => void; /** Call `ttq.revokeConsent()`. */ revoke: () => void; /** Call `ttq.holdConsent()` to defer the decision. */ hold: () => void; } export declare function useScriptTikTokPixel(_options?: TikTokPixelInput): UseScriptContext;