/** * VibePing SDK — Type definitions * All event types, config, and transport payload types. */ /** SDK configuration passed to vibeping.init() */ export interface VibePingConfig { /** API key from VibePing dashboard (e.g. 'vp_abc123') */ id: string; /** API endpoint URL (defaults to https://app.vibeping.dev) */ apiUrl?: string; /** Enable debug logging to console */ debug?: boolean; } /** Internal resolved config with defaults applied */ export interface ResolvedConfig { id: string; apiUrl: string; debug: boolean; } /** Event type discriminator */ export declare const EventType: { readonly Pageview: "pageview"; readonly Error: "error"; readonly Vital: "vital"; readonly Custom: "custom"; readonly Session: "session"; readonly Identify: "identify"; }; export type EventType = (typeof EventType)[keyof typeof EventType]; /** Base fields shared by all events */ export interface BaseEvent { /** Event type discriminator */ type: EventType; /** Stable unique ID for this event (UUID) — used for server-side idempotency */ eventId: string; /** ISO 8601 timestamp */ timestamp: string; /** Session ID */ sessionId: string; /** Current page URL */ url: string; } /** Pageview event — fired on navigation */ export interface PageviewEvent extends BaseEvent { type: typeof EventType.Pageview; referrer: string; title: string; screenWidth: number; screenHeight: number; language: string; } /** Error event — captured from window.onerror / unhandledrejection */ export interface VibePingErrorEvent extends BaseEvent { type: typeof EventType.Error; message: string; stack: string; file: string; line: number; column: number; errorType: string; } /** Rating bucket for a web vital metric */ export type VitalRating = 'good' | 'needs-improvement' | 'poor'; /** Web vital metric name (FID kept for back-compat, deprecated) */ export type VitalName = 'LCP' | 'CLS' | 'TTFB' | 'INP' | 'FID'; /** Web vital metric event */ export interface VitalEvent extends BaseEvent { type: typeof EventType.Vital; /** Metric name: LCP, CLS, TTFB, INP, FID (deprecated) */ name: VitalName; /** Metric value */ value: number; /** Rating bucket */ rating: VitalRating; } /** Custom user-defined event */ export interface CustomEvent extends BaseEvent { type: typeof EventType.Custom; /** Event name */ name: string; /** Optional properties */ properties: Record; } /** Session lifecycle event */ export interface SessionEvent extends BaseEvent { type: typeof EventType.Session; /** Session action: start or end */ action: 'start' | 'end'; /** Duration in milliseconds (set on end) */ duration: number; } /** Identify event — associate user data with a session */ export interface IdentifyEvent extends BaseEvent { type: typeof EventType.Identify; /** User properties */ traits: Record; } /** Union of all event types */ export type VibePingEvent = PageviewEvent | VibePingErrorEvent | VitalEvent | CustomEvent | SessionEvent | IdentifyEvent; /** Batch payload sent to the API */ export interface TransportPayload { /** API key for authentication */ apiKey: string; /** Batch of events */ events: VibePingEvent[]; /** SDK version */ sdkVersion: string; /** Sent timestamp */ sentAt: string; } /** Transport interface for sending events */ export interface Transport { /** Queue an event for sending */ send(event: VibePingEvent): void; /** Flush all queued events immediately */ flush(): void; /** Stop the transport (clear timers) */ destroy(): void; }