import type { AnalyticsAPI } from "@/shared/analytics/AnalyticsAPI"; /** * Browser/WASM implementation of AnalyticsAPI. * * Events are sent through the WASM worker which handles batching and * sending to PostHog. */ export class WasmAnalytics implements AnalyticsAPI { private worker: Worker | null = null; constructor(worker: Worker) { this.worker = worker; } track(event: string, properties?: Record): void { if (!this.worker) { console.error("Worker not set for analytics"); return; } this.worker.postMessage({ type: "ANALYTICS_EVENT", payload: { event, properties: properties || {}, }, }); } }