mirror of
https://github.com/Xevion/smart-rgb.git
synced 2025-12-18 06:13:22 -06:00
Update source files
This commit is contained in:
32
frontend/src/desktop/analytics/tauriAnalytics.ts
Normal file
32
frontend/src/desktop/analytics/tauriAnalytics.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type { AnalyticsAPI } from "@/shared/analytics/AnalyticsAPI";
|
||||
|
||||
/**
|
||||
* Desktop implementation of AnalyticsAPI using Tauri commands.
|
||||
*
|
||||
* Events are sent to the Rust backend which handles batching and
|
||||
* sending to PostHog.
|
||||
*/
|
||||
export class TauriAnalytics implements AnalyticsAPI {
|
||||
track(event: string, properties?: Record<string, any>): void {
|
||||
invoke("track_analytics_event", {
|
||||
payload: {
|
||||
event,
|
||||
properties: properties || {},
|
||||
},
|
||||
}).catch((err) => {
|
||||
console.error("Failed to track analytics event:", err);
|
||||
});
|
||||
}
|
||||
|
||||
async flush(): Promise<void> {
|
||||
try {
|
||||
await invoke("flush_analytics");
|
||||
} catch (err) {
|
||||
console.error("Failed to flush analytics:", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
export const tauriAnalytics = new TauriAnalytics();
|
||||
Reference in New Issue
Block a user