@@ -41,13 +41,7 @@ export const init_tracking = async () => {
4141 }
4242
4343 if ( track ) {
44- let appVersion : string | null = null ;
45-
46- try {
47- appVersion = await invoke < string > ( "get_app_version" ) ;
48- } catch ( e ) {
49- console . error ( "Failed to get app version:" , e ) ;
50- }
44+ const appVersion = await getAppVersion ( ) ;
5145
5246 Sentry . init ( {
5347 dsn : "https://ac8c00adf29c329694a0b105e1981ca3@o4507730431442944.ingest.us.sentry.io/4507741947232256" ,
@@ -102,28 +96,22 @@ export default async function track_event(event: string, properties: any = {}) {
10296 // Get current org context from store
10397 const store = useStore . getState ( ) ;
10498 const selectedOrg = store . selectedOrg ;
105-
99+
106100 // Determine org context (anonymous - just personal vs org)
107101 const orgContext = selectedOrg ? "org" : "personal" ;
108102
109103 if ( AtuinEnv . isDev ) {
110104 console . log (
111- `[dev] track_event: ${ event } -> ${ JSON . stringify ( {
112- ...properties ,
105+ `[dev] track_event: ${ event } -> ${ JSON . stringify ( {
106+ ...properties ,
113107 platform : platformInfo ,
114- org_context : orgContext
108+ org_context : orgContext ,
115109 } ) } `,
116110 ) ;
117111 return ;
118112 }
119113
120- let appVersion : string | null = null ;
121-
122- try {
123- appVersion = await invoke < string > ( "get_app_version" ) ;
124- } catch ( e ) {
125- console . error ( "Failed to get app version:" , e ) ;
126- }
114+ const appVersion = await getAppVersion ( ) ;
127115
128116 // Always include platform info and org context in every event
129117 const eventProperties = {
@@ -136,3 +124,19 @@ export default async function track_event(event: string, properties: any = {}) {
136124 const { default : posthog } = await import ( "posthog-js" ) ;
137125 posthog . capture ( event , eventProperties ) ;
138126}
127+
128+ async function getAppVersion ( ) {
129+ const version = useStore . getState ( ) . appVersion ;
130+
131+ if ( version . isSome ( ) ) {
132+ return version . unwrap ( ) ;
133+ }
134+
135+ try {
136+ const backendVersion = await invoke < string > ( "get_app_version" ) ;
137+ if ( backendVersion ) {
138+ useStore . getState ( ) . setAppVersion ( backendVersion ) ;
139+ return backendVersion ;
140+ }
141+ } catch ( _e ) { }
142+ }
0 commit comments