import type OptableSDK from "../../sdk"; declare global { interface Window { pbjs?: any; } } interface OptablePrebidAnalyticsConfig { debug?: boolean; analytics?: boolean; tenant?: string; bidWinTimeout?: number; samplingVolume?: "session" | "event"; samplingSeed?: string; samplingRate?: number; samplingRateFn?: () => boolean; } declare class OptablePrebidAnalytics { private readonly optableInstance; private config; readonly isInitialized: boolean; private readonly labelStyle; private readonly maxAuctionDataSize; private auctions; private prebidInstance; /** * Create a new OptablePrebidAnalytics instance. * @param optableInstance - An initialized Optable SDK instance that exposes a `witness()` method. * @param config - Optional configuration for sampling, debug and analytics behavior. */ constructor(optableInstance: OptableSDK, config?: OptablePrebidAnalyticsConfig); /** * Log messages to the console when debugging is enabled. * @param args - Values to log. * @returns void */ log(...args: unknown[]): void; /** * Determine whether the current event/session should be sampled according to * the configured sampling rate, seed or function. * @returns true if the event should be sampled and analytics calls may proceed. */ shouldSample(): boolean; /** * Send an event to the Witness API when analytics are enabled and sampling passes. * @param eventName - The name of the event to send (e.g. "optable.prebid.auction"). * @param properties - An object of event properties to include in the payload. * @returns A small result object indicating whether the call was disabled or sent. */ sendToWitnessAPI(eventName: string, properties?: Record): Promise<{ disabled: boolean; eventName: string; properties: Record; }>; /** * Attach listeners to a Prebid.js instance and process any missed events. * This will replay past `auctionEnd` and `bidWon` events and then register live handlers. * @param pbjs - The Prebid.js global instance (or equivalent) to hook into. * @returns void */ setHooks(pbjs: any): void; /** * Hook into Prebid.js by attaching event hooks either immediately or by * queueing callbacks when `pbjs.onEvent` is not available yet. * @param prebidInstance - Optional Prebid.js instance to use (defaults to `window.pbjs`). * @returns true when a hook has been registered, false when Prebid is not present. */ hookIntoPrebid(prebidInstance?: any): boolean; /** * Process a Prebid `auctionEnd` event: build an internal representation of * requests, merge in received bids and schedule a delayed Witness API call * (to allow `bidWon` to be received) or mark as missed. * @param event - The raw Prebid auctionEnd event object. * @param missed - True when the event was previously emitted (missed replay). * @returns void */ trackAuctionEnd(event: any, missed?: boolean): Promise; /** * Accumulate a Prebid `bidWon` event into the matching auction's event list * for deferred emission when the auction timeout fires. * @param event - The raw Prebid bidWon event object. * @param missed - True when the event was previously emitted (missed replay). * @returns void */ trackBidWon(event: any, missed?: boolean): Promise; /** * Clean up old auctions to prevent memory leaks. * Removes the oldest auction when the internal store grows past the configured size. * @returns void */ cleanupOldAuctions(): void; /** * Clear all stored analytics data (useful for tests). * @returns void */ clearData(): void; /** * Convert internal auction state and accumulated bidWon events into a Witness payload. * This collects matcher/source metadata, bid counts and optional custom analytics. * @param auctionEndEvent - The `auctionEnd` event object from Prebid.js. * @param bidWonEvents - Array of `bidWon` events accumulated during the auction window. * @param missed - True when the original events were already emitted (replayed). * @returns A payload object compatible with the Witness API. */ toWitness(auctionEndEvent: any, bidWonEvents: any[], missed?: boolean): Promise>; } export default OptablePrebidAnalytics;