Browse Source
			
			
			
			
				
		Improves application logging and error tracking: - Add structured logging in main.common.ts for app initialization - Enhance API error handling with detailed context in services - Add deep link debugging in Capacitor platform - Improve plan service logging with retry information - Update endorser server logs for better cache debugging Technical changes: - Replace console.error with info for non-critical cache misses - Add component context to global error handler - Add detailed logging for plan loading and retries - Improve deep link route matching logs - Add mount state logging for Capacitor This improves debugging capabilities across web and mobile platforms.side_step
				 7 changed files with 137 additions and 56 deletions
			
			
		| @ -1,19 +1,71 @@ | |||
| export const loadPlanWithRetry = async (handle: string, retries = 3) => { | |||
|   for (let i = 0; i < retries; i++) { | |||
|     try { | |||
|       const plan = await loadPlan(handle); | |||
|       if (plan) return plan; | |||
|     } catch (err) { | |||
|       console.warn(`[Plan Load] Attempt ${i + 1} failed for ${handle}`); | |||
|       if (i === retries - 1) throw err; | |||
|       await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1))); | |||
| import axios from 'axios'; | |||
| 
 | |||
| interface PlanResponse { | |||
|   data?: any; | |||
|   status?: number; | |||
|   error?: string; | |||
| } | |||
| 
 | |||
| export const loadPlanWithRetry = async (handle: string, retries = 3): Promise<PlanResponse> => { | |||
|   try { | |||
|     console.log(`[Plan Service] Loading plan ${handle}, attempt 1/${retries}`); | |||
|     console.log(`[Plan Service] Context: Deep link handle=${handle}, isClaimFlow=${handle.includes('claim')}`); | |||
|      | |||
|     // Different endpoint if this is a claim flow
 | |||
|     const response = await loadPlan(handle); | |||
|     console.log(`[Plan Service] Plan ${handle} loaded successfully:`, { | |||
|       status: response?.status, | |||
|       headers: response?.headers, | |||
|       data: response?.data | |||
|     }); | |||
|      | |||
|     return response; | |||
|   } catch (error: any) { | |||
|     console.error(`[Plan Service] Error loading plan ${handle}:`, { | |||
|       message: error.message, | |||
|       status: error.response?.status, | |||
|       statusText: error.response?.statusText, | |||
|       data: error.response?.data, | |||
|       headers: error.response?.headers, | |||
|       config: { | |||
|         url: error.config?.url, | |||
|         method: error.config?.method, | |||
|         baseURL: error.config?.baseURL, | |||
|         headers: error.config?.headers | |||
|       } | |||
|     }); | |||
| 
 | |||
|     if (retries > 1) { | |||
|       console.log(`[Plan Service] Retrying plan ${handle}, ${retries-1} attempts remaining`); | |||
|       await new Promise(resolve => setTimeout(resolve, 1000)); | |||
|       return loadPlanWithRetry(handle, retries - 1); | |||
|     } | |||
|      | |||
|     return { | |||
|       error: `Failed to load plan ${handle} after ${4-retries} attempts: ${error.message}`, | |||
|       status: error.response?.status | |||
|     }; | |||
|   } | |||
| }; | |||
| 
 | |||
| const loadPlan = async (handle: string) => { | |||
|   // Implement your plan loading logic here
 | |||
|   // This is a placeholder - replace with actual implementation
 | |||
|   const response = await fetch(`/api/plans/${handle}`); | |||
|   return response.json(); | |||
| export const loadPlan = async (handle: string): Promise<PlanResponse> => { | |||
|   console.log(`[Plan Service] Making API request for plan ${handle}`); | |||
|    | |||
|   const endpoint = handle.includes('claim')  | |||
|     ? `/api/claims/${handle}` | |||
|     : `/api/plans/${handle}`; | |||
|      | |||
|   console.log(`[Plan Service] Using endpoint: ${endpoint}`); | |||
|    | |||
|   try { | |||
|     const response = await axios.get(endpoint); | |||
|     return response; | |||
|   } catch (error: any) { | |||
|     console.error(`[Plan Service] API request failed for ${handle}:`, { | |||
|       endpoint, | |||
|       error: error.message, | |||
|       response: error.response?.data | |||
|     }); | |||
|     throw error; | |||
|   } | |||
| };  | |||
					Loading…
					
					
				
		Reference in new issue