UNPKG

react-facebook

Version:

Facebook components like a Login button, Like, Share, Comments, Embedded Post/Video, Messenger Chat, and Facebook Pixel tracking

34 lines (33 loc) 1.38 kB
export type PixelOptions = { pixelId: string; autoConfig?: boolean; debug?: boolean; advancedMatching?: Record<string, any>; }; export type PixelEventData = Record<string, any>; export type PixelEventName = 'PageView' | 'ViewContent' | 'Search' | 'AddToCart' | 'AddToWishlist' | 'InitiateCheckout' | 'AddPaymentInfo' | 'Purchase' | 'Lead' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'Schedule' | 'StartTrial' | 'SubmitApplication' | 'Subscribe' | 'Custom'; declare global { interface Window { fbq: any; _fbq: any; } } export default class FacebookPixel { private options; private loadingPromise; constructor(options: PixelOptions); private warn; private log; private loadPixelScript; init(): Promise<FacebookPixel>; pageView(): Promise<void>; track(eventName: PixelEventName, data?: PixelEventData): Promise<void>; trackSingle(pixelId: string, eventName: PixelEventName, data?: PixelEventData): Promise<void>; trackCustom(eventName: string, data?: PixelEventData): Promise<void>; trackSingleCustom(pixelId: string, eventName: string, data?: PixelEventData): Promise<void>; grantConsent(): Promise<void>; revokeConsent(): Promise<void>; fbq(...args: any[]): Promise<void>; isInitialized(): boolean; getOptions(): PixelOptions; }