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.deep_linking
7 changed files with 137 additions and 56 deletions
@ -1,19 +1,71 @@ |
|||||
export const loadPlanWithRetry = async (handle: string, retries = 3) => { |
import axios from 'axios'; |
||||
for (let i = 0; i < retries; i++) { |
|
||||
|
interface PlanResponse { |
||||
|
data?: any; |
||||
|
status?: number; |
||||
|
error?: string; |
||||
|
} |
||||
|
|
||||
|
export const loadPlanWithRetry = async (handle: string, retries = 3): Promise<PlanResponse> => { |
||||
try { |
try { |
||||
const plan = await loadPlan(handle); |
console.log(`[Plan Service] Loading plan ${handle}, attempt 1/${retries}`); |
||||
if (plan) return plan; |
console.log(`[Plan Service] Context: Deep link handle=${handle}, isClaimFlow=${handle.includes('claim')}`); |
||||
} catch (err) { |
|
||||
console.warn(`[Plan Load] Attempt ${i + 1} failed for ${handle}`); |
// Different endpoint if this is a claim flow
|
||||
if (i === retries - 1) throw err; |
const response = await loadPlan(handle); |
||||
await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1))); |
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) => { |
export const loadPlan = async (handle: string): Promise<PlanResponse> => { |
||||
// Implement your plan loading logic here
|
console.log(`[Plan Service] Making API request for plan ${handle}`); |
||||
// This is a placeholder - replace with actual implementation
|
|
||||
const response = await fetch(`/api/plans/${handle}`); |
const endpoint = handle.includes('claim') |
||||
return response.json(); |
? `/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