UNPKG

@ked3/ktrace

Version:

跨平台埋点分析SDK

63 lines 1.75 kB
import { TrackerConfig, TrackEvent, EventType, EventKey } from "./types"; /** * 核心追踪器类 */ declare class Tracker { private config; private sessionId; version: string; private eventQueue; private readonly BATCH_SIZE; /** * 构造函数 */ constructor(config?: Partial<TrackerConfig>); /** * 设置页面卸载处理器 */ private setupUnloadHandler; /** * 验证事件数据 * @param event 事件数据 */ private validateEvent; /** * 添加事件到队列 * @param event 事件数据 */ private addToQueue; /** * 批量发送事件 * @param isUnload 是否是页面卸载时的发送 */ private batchSend; /** * 手动触发批量发送 * 用于在需要时立即发送当前队列中的所有事件 */ flushEvents(): void; /** * 创建基础事件对象 */ createBaseEvent(eventKey: EventKey, eventType?: EventType, error?: Error, properties?: Record<string, any>): TrackEvent; /** * 追踪自定义事件 * @param eventName 事件名称(必须是EventKey枚举值) * @param properties 事件属性 */ trackEvent(eventName: EventKey, properties?: Record<string, any>): void; /** * 追踪错误事件 * @param error 错误对象 * @param eventKey 错误事件键(可选,默认使用JAVASCRIPT_ERROR) * @param properties 附加属性 */ trackError(error: Error, eventKey?: EventKey, properties?: Record<string, any>): void; /** * 获取当前队列长度 */ getQueueLength(): number; getConfig(): TrackerConfig; } export default Tracker; //# sourceMappingURL=Tracker.d.ts.map