File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 11export type AppConfiguration = {
22 data_folder : string
33 quick_ask : boolean
4+ distinct_id ?: string
45}
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ import ImportModelOptionModal from '@/screens/Settings/ImportModelOptionModal'
2626import ImportingModelModal from '@/screens/Settings/ImportingModelModal'
2727import SelectingModelModal from '@/screens/Settings/SelectingModelModal'
2828
29+ import { getAppDistinctId , updateDistinctId } from '@/utils/settings'
30+
2931import LoadingModal from '../LoadingModal'
3032
3133import MainViewContainer from '../MainViewContainer'
@@ -93,8 +95,16 @@ const BaseLayout = () => {
9395 return properties
9496 } ,
9597 } )
96- posthog . opt_in_capturing ( )
97- posthog . register ( { app_version : VERSION } )
98+ // Attempt to restore distinct Id from app global settings
99+ getAppDistinctId ( )
100+ . then ( ( id ) => {
101+ if ( id ) posthog . identify ( id )
102+ } )
103+ . finally ( ( ) => {
104+ posthog . opt_in_capturing ( )
105+ posthog . register ( { app_version : VERSION } )
106+ updateDistinctId ( posthog . get_distinct_id ( ) )
107+ } )
98108 } else {
99109 posthog . opt_out_capturing ( )
100110 }
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export default function useFactoryReset() {
5858 const configuration : AppConfiguration = {
5959 data_folder : defaultJanDataFolder ,
6060 quick_ask : appConfiguration ?. quick_ask ?? false ,
61+ distinct_id : appConfiguration ?. distinct_id ,
6162 }
6263 await window . core ?. api ?. updateAppConfiguration ( configuration )
6364 }
Original file line number Diff line number Diff line change 1+ import { AppConfiguration } from '@janhq/core'
2+
3+ /**
4+ * Update app distinct Id
5+ * @param id
6+ */
7+ export const updateDistinctId = async ( id : string ) => {
8+ const appConfiguration : AppConfiguration =
9+ await window . core ?. api ?. getAppConfigurations ( )
10+ appConfiguration . distinct_id = id
11+ await window . core ?. api ?. updateAppConfiguration ( appConfiguration )
12+ }
13+
14+ /**
15+ * Retrieve app distinct Id
16+ * @param id
17+ */
18+ export const getAppDistinctId = async ( ) : Promise < string | undefined > => {
19+ const appConfiguration : AppConfiguration =
20+ await window . core ?. api ?. getAppConfigurations ( )
21+ return appConfiguration . distinct_id
22+ }
You can’t perform that action at this time.
0 commit comments