feat: enhanced AI usage logging (model, provider, response) and fixed build blockers

This commit is contained in:
2025-12-27 00:10:55 +01:00
parent 20659567fd
commit c51cd23d5e
10 changed files with 127 additions and 34 deletions

View File

@@ -186,7 +186,10 @@ export async function scanLabel(input: any): Promise<AnalysisResponse> {
userId: userId,
apiType: 'gemini_ai',
endpoint: 'scanLabel_openrouter',
success: true
success: true,
provider: 'openrouter',
model: 'google/gemma-3-27b-it',
responseText: content
});
await deductCredits(userId, 'gemini_ai', 'Bottle OCR scan (OpenRouter)');
@@ -248,7 +251,10 @@ export async function scanLabel(input: any): Promise<AnalysisResponse> {
userId: userId,
apiType: 'gemini_ai',
endpoint: 'scanLabel_gemini',
success: true
success: true,
provider: 'google',
model: 'gemini-2.5-flash',
responseText: result.response.text()
});
await deductCredits(userId, 'gemini_ai', 'Bottle OCR scan (Gemini)');
@@ -279,7 +285,9 @@ export async function scanLabel(input: any): Promise<AnalysisResponse> {
apiType: 'gemini_ai',
endpoint: `scanLabel_${provider}`,
success: false,
errorMessage: aiError.message
errorMessage: aiError.message,
provider: provider,
model: provider === 'openrouter' ? 'google/gemma-3-27b-it' : 'gemini-2.5-flash'
});
return {