mirror of
https://github.com/Xevion/smart-rgb.git
synced 2025-12-13 08:13:05 -06:00
Update source files
This commit is contained in:
30
frontend/src/browser/analytics/wasmAnalytics.ts
Normal file
30
frontend/src/browser/analytics/wasmAnalytics.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
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 || {},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user