Added documentation for the auto-population feature and the analytics integration.

This commit is contained in:
ajaysi
2026-01-17 11:01:10 +05:30
parent 8193cdba67
commit 1db10ccd0f
61 changed files with 6773 additions and 579 deletions

View File

@@ -118,22 +118,22 @@ apiClient.interceptors.request.use(
return Promise.reject(new Error('Authentication not ready. Please wait for sign-in to complete.'));
}
try {
const token = await authTokenGetter();
if (token) {
config.headers = config.headers || {};
(config.headers as any)['Authorization'] = `Bearer ${token}`;
console.log(`[apiClient] ✅ Added auth token to request: ${config.url}`);
} else {
try {
const token = await authTokenGetter();
if (token) {
config.headers = config.headers || {};
(config.headers as any)['Authorization'] = `Bearer ${token}`;
console.log(`[apiClient] ✅ Added auth token to request: ${config.url}`);
} else {
// Token getter returned null - reject request to prevent 401 errors
// ProtectedRoute should ensure user is authenticated before components render
console.error(`[apiClient] ❌ authTokenGetter returned null for ${config.url} - rejecting request`);
console.error(`[apiClient] User ID from localStorage: ${localStorage.getItem('user_id') || 'none'}`);
console.error(`[apiClient] This usually means user is not signed in or token expired. ProtectedRoute should prevent this.`);
return Promise.reject(new Error('Authentication token not available. Please sign in to continue.'));
}
} catch (tokenError) {
console.error(`[apiClient] ❌ Error getting auth token for ${config.url}:`, tokenError);
}
} catch (tokenError) {
console.error(`[apiClient] ❌ Error getting auth token for ${config.url}:`, tokenError);
// Reject request if token getter throws an error
return Promise.reject(new Error('Failed to get authentication token. Please try signing in again.'));
}

View File

@@ -18,6 +18,9 @@ export interface OnboardingStepResponse {
step: number;
data?: any;
validation_errors?: string[];
detail?: string; // Error detail from HTTP responses
message?: string; // Success message
warnings?: string[]; // Warning messages
}
export interface OnboardingSessionResponse {
@@ -50,12 +53,24 @@ export async function getCurrentStep() {
export async function setCurrentStep(step: number, stepData?: any) {
// Complete the current step to move to the next one
console.log('setCurrentStep: Completing step', step, 'with data:', stepData);
const res: AxiosResponse<OnboardingStepResponse> = await apiClient.post(`/api/onboarding/step/${step}/complete`, {
data: stepData || {},
validation_errors: []
});
console.log('setCurrentStep: Backend response:', res.data);
return { step };
try {
const res: AxiosResponse<OnboardingStepResponse> = await apiClient.post(`/api/onboarding/step/${step}/complete`, {
data: stepData || {},
validation_errors: []
});
console.log('setCurrentStep: Backend response:', res.data);
return { step, response: res.data }; // Include the full response data including warnings
} catch (error: any) {
// Handle HTTP errors from the backend
console.error('setCurrentStep: Backend error:', error);
if (error.response?.status >= 400) {
const errorData = error.response.data;
const errorMessage = errorData?.detail || errorData?.message || `Step completion failed with status ${error.response.status}`;
throw new Error(errorMessage);
}
// Re-throw other errors
throw error;
}
}
export async function getApiKeys() {