@@ -94,6 +94,12 @@ export function initializeRecallSDK(
9494 posthogKey : string ,
9595 posthogHost : string ,
9696) {
97+ console . log ( "[Recall SDK] initializeRecallSDK called with:" , {
98+ recallApiUrl,
99+ posthogHost,
100+ hasKey : ! ! posthogKey ,
101+ } ) ;
102+
97103 if ( sdkInitialized ) {
98104 console . warn ( "[Recall SDK] Already initialized, skipping" ) ;
99105 return ;
@@ -106,28 +112,17 @@ export function initializeRecallSDK(
106112 return ;
107113 }
108114
109- console . log ( "[Recall SDK] Initializing..." ) ;
110-
111- sdkInitialized = true ;
112- posthogClient = new PostHogAPIClient ( posthogKey , posthogHost ) ;
113-
114- RecallAiSdk . init ( {
115- apiUrl : recallApiUrl ,
116- acquirePermissionsOnStartup : [
117- "accessibility" ,
118- "screen-capture" ,
119- "microphone" ,
120- ] ,
121- restartOnError : true ,
122- } ) ;
115+ console . log ( "[Recall SDK] Setting up event listeners..." ) ;
123116
124- console . log ( "[Recall SDK] Ready. Listening for meetings..." ) ;
117+ // IMPORTANT: Register ALL event listeners BEFORE calling init()
118+ // This is required by Recall SDK
125119
126120 RecallAiSdk . addEventListener ( "permissions-granted" , async ( ) => {
127121 console . log ( "[Recall SDK] Permissions granted" ) ;
128122 } ) ;
129123
130124 RecallAiSdk . addEventListener ( "permission-status" , async ( evt ) => {
125+ console . log ( "[Recall SDK] Permission status:" , evt . permission , evt . status ) ;
131126 if ( evt . status === "denied" || evt . status === "error" ) {
132127 console . warn ( `[Recall SDK] Permission ${ evt . permission } : ${ evt . status } ` ) ;
133128 }
@@ -385,6 +380,34 @@ export function initializeRecallSDK(
385380 ) ;
386381 }
387382 } ) ;
383+
384+ console . log ( "[Recall SDK] All event listeners registered" ) ;
385+
386+ // NOW initialize the SDK (after all event listeners are set up)
387+ console . log ( "[Recall SDK] Initializing SDK..." ) ;
388+ sdkInitialized = true ;
389+ posthogClient = new PostHogAPIClient ( posthogKey , posthogHost ) ;
390+ console . log ( "[Recall SDK] PostHog client created" ) ;
391+
392+ try {
393+ RecallAiSdk . init ( {
394+ apiUrl : recallApiUrl ,
395+ acquirePermissionsOnStartup : [
396+ "accessibility" ,
397+ "screen-capture" ,
398+ "microphone" ,
399+ ] ,
400+ restartOnError : true ,
401+ } ) ;
402+ console . log ( "[Recall SDK] RecallAiSdk.init() completed successfully" ) ;
403+ } catch ( error ) {
404+ console . error ( "[Recall SDK] Failed to initialize SDK:" , error ) ;
405+ sdkInitialized = false ;
406+ posthogClient = null ;
407+ throw error ;
408+ }
409+
410+ console . log ( "[Recall SDK] ✓ Ready. Listening for meetings..." ) ;
388411}
389412
390413export function requestRecallPermission (
@@ -398,18 +421,37 @@ export function shutdownRecallSDK() {
398421}
399422
400423export function registerRecallIPCHandlers ( ) {
424+ console . log ( "[Recall SDK] Registering IPC handlers..." ) ;
425+
401426 ipcMain . handle (
402427 "recall:initialize" ,
403428 async ( _event , recallApiUrl , posthogKey , posthogHost ) => {
404- initializeRecallSDK ( recallApiUrl , posthogKey , posthogHost ) ;
429+ console . log ( "[Recall SDK] IPC handler 'recall:initialize' called" ) ;
430+ try {
431+ initializeRecallSDK ( recallApiUrl , posthogKey , posthogHost ) ;
432+ console . log ( "[Recall SDK] IPC handler 'recall:initialize' completed" ) ;
433+ } catch ( error ) {
434+ console . error (
435+ "[Recall SDK] IPC handler 'recall:initialize' error:" ,
436+ error ,
437+ ) ;
438+ throw error ;
439+ }
405440 } ,
406441 ) ;
407442
408443 ipcMain . handle ( "recall:request-permission" , async ( _event , permission ) => {
444+ console . log (
445+ "[Recall SDK] IPC handler 'recall:request-permission' called:" ,
446+ permission ,
447+ ) ;
409448 requestRecallPermission ( permission ) ;
410449 } ) ;
411450
412451 ipcMain . handle ( "recall:shutdown" , async ( ) => {
452+ console . log ( "[Recall SDK] IPC handler 'recall:shutdown' called" ) ;
413453 shutdownRecallSDK ( ) ;
414454 } ) ;
455+
456+ console . log ( "[Recall SDK] IPC handlers registered successfully" ) ;
415457}
0 commit comments