admesh-ui-sdk
Version:
Beautiful, modern React components for displaying AI-powered product recommendations with citation-based conversation ads, auto-triggered widgets, floating chat, conversational interfaces, persistent sidebar, and built-in tracking. Includes zero-code SDK
79 lines • 3.06 kB
TypeScript
import { MRCViewabilityStandards, DeviceType, ViewabilityContextMetrics, ViewabilityAnalyticsEvent } from '../types/analytics';
/**
* Calculate MRC viewability standards based on ad size
*/
export declare function calculateMRCStandards(adWidth: number, adHeight: number, customStandards?: Partial<MRCViewabilityStandards>): MRCViewabilityStandards;
/**
* Detect device type based on viewport width
*/
export declare function detectDeviceType(viewportWidth: number): DeviceType;
/**
* Calculate visibility percentage of element in viewport
*/
export declare function calculateVisibilityPercentage(element: HTMLElement): number;
/**
* Calculate current scroll depth as percentage
*/
export declare function calculateScrollDepth(): number;
/**
* Get element position on page
*/
export declare function getElementPosition(element: HTMLElement): {
top: number;
left: number;
};
/**
* Collect context metrics
*/
export declare function collectContextMetrics(element: HTMLElement): ViewabilityContextMetrics;
/**
* Generate unique session ID
*/
export declare function generateSessionId(): string;
/**
* Generate unique batch ID
*/
export declare function generateBatchId(): string;
/**
* Check if ad meets MRC viewability threshold
*/
export declare function meetsViewabilityThreshold(visibilityPercentage: number, visibleDuration: number, standards: MRCViewabilityStandards): boolean;
/**
* Format timestamp to ISO 8601
*/
export declare function formatTimestamp(date?: Date): string;
/**
* Calculate average from array of numbers
*/
export declare function calculateAverage(numbers: number[]): number;
/**
* Debounce function for performance optimization
*/
export declare function debounce<T extends (...args: unknown[]) => unknown>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* Throttle function for performance optimization
*/
export declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, limit: number): (...args: Parameters<T>) => void;
/**
* Send analytics event to API
*
* NOTE: If apiEndpoint is empty, the event is silently discarded (no error).
* This allows the SDK to collect analytics without sending them to a backend.
*/
export declare function sendAnalyticsEvent(event: ViewabilityAnalyticsEvent, apiEndpoint: string, retryAttempts?: number, retryDelay?: number): Promise<boolean>;
/**
* Send batched analytics events to API
*
* NOTE: If apiEndpoint is empty, the batch is silently discarded (no error).
* This allows the SDK to collect analytics without sending them to a backend.
*/
export declare function sendAnalyticsBatch(events: ViewabilityAnalyticsEvent[], sessionId: string, apiEndpoint: string, retryAttempts?: number, retryDelay?: number): Promise<boolean>;
/**
* Sanitize URL to remove PII (query parameters, fragments)
*/
export declare function sanitizeUrl(url: string): string;
/**
* Check if element is in viewport
*/
export declare function isElementInViewport(element: HTMLElement): boolean;
//# sourceMappingURL=viewabilityTracker.d.ts.map