import { invoke } from "@tauri-apps/api/core"; import { telemetryLog } from "./telemetry"; export type AnalyticsEventProperties = Record; export function trackAnalyticsEvent(name: string, props?: AnalyticsEventProperties) { const details = props && Object.keys(props).length > 0 ? ` ${JSON.stringify(props)}` : ""; telemetryLog("info", `${name}${details}`, `product.${name}`); void invoke("plugin:aptabase|track_event", { name, props: props && Object.keys(props).length > 0 ? props : undefined, }).catch(() => { // Analytics must never interrupt the Git workflow. }); }