Skip to content

Commit ffb8883

Browse files
committed
feat(analytics): implement Tauri runtime check for event tracking
- Replaced Aptabase's trackEvent with a conditional invocation of the Tauri command for tracking events. - Added a check to ensure the function only executes in a Tauri environment.
1 parent b85b522 commit ffb8883

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/lib/analytics.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import { trackEvent } from "@aptabase/tauri"
1+
import { invoke, isTauri } from "@tauri-apps/api/core"
22

33
/**
44
* Thin wrapper around Aptabase's trackEvent.
55
* Aptabase only supports string and number property values.
66
*/
7+
const APTABASE_TRACK_EVENT_CMD = "plugin:aptabase|track_event"
8+
79
export function track(
810
event: string,
911
props?: Record<string, string | number>,
1012
) {
11-
trackEvent(event, props)
13+
const tauriRuntime = isTauri()
14+
15+
if (!tauriRuntime) {
16+
return
17+
}
18+
19+
void invoke(APTABASE_TRACK_EVENT_CMD, { name: event, props })
1220
}

0 commit comments

Comments
 (0)