UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

62 lines (61 loc) 2.54 kB
/** * Performance timing utility for tracking operation duration */ import type { UserEvents } from '../core/user-events'; export interface PerformanceTiming { startTime: number; endTime?: number; duration?: number; } /** * Start timing an operation * @param key - Unique identifier for the operation * @param timings - Map to store timing information * @returns The start timestamp */ export declare const startTiming: (key: string, timings?: Map<string, PerformanceTiming>) => number; /** * End timing an operation and calculate duration * @param key - Unique identifier for the operation * @param timings - Map containing timing information * @returns The duration in milliseconds, or undefined if timing wasn't started */ export declare const endTiming: (key: string, timings: Map<string, PerformanceTiming>) => number | undefined; /** * Get timing information for an operation * @param key - Unique identifier for the operation * @param timings - Map containing timing information * @returns The timing information, or undefined if not found */ export declare const getTiming: (key: string, timings: Map<string, PerformanceTiming>) => PerformanceTiming | undefined; /** * Clear timing information for an operation * @param key - Unique identifier for the operation * @param timings - Map containing timing information */ export declare const clearTiming: (key: string, timings: Map<string, PerformanceTiming>) => void; /** * Clear all timing information * @param timings - Map containing timing information */ export declare const clearAllTimings: (timings: Map<string, PerformanceTiming>) => void; /** * Execute a function with automatic timing * @param key - Unique identifier for the operation * @param fn - Function to execute * @param analytics - UserEvents instance for logging * @param timings - Optional map to store timing information * @returns Promise that resolves with the function result and timing duration */ export declare const withTiming: <T>(key: string, fn: () => Promise<T>, analytics: UserEvents, timings?: Map<string, PerformanceTiming>) => Promise<{ result: T; duration: number; }>; /** * Convenience function to track async operation timing * @param key - Unique identifier for the operation * @param fn - Function to execute * @param analytics - UserEvents instance for logging * @returns Promise that resolves with the function result */ export declare const trackPerformance: <T>(key: string, fn: () => Promise<T>, analytics: UserEvents) => Promise<T>;