mirror of
https://github.com/Xevion/smart-rgb.git
synced 2025-12-09 00:08:32 -06:00
31 lines
696 B
TypeScript
31 lines
696 B
TypeScript
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<string, any>): void {
|
|
if (!this.worker) {
|
|
console.error("Worker not set for analytics");
|
|
return;
|
|
}
|
|
|
|
this.worker.postMessage({
|
|
type: "ANALYTICS_EVENT",
|
|
payload: {
|
|
event,
|
|
properties: properties || {},
|
|
},
|
|
});
|
|
}
|
|
}
|