feat: add Gemini AI tracking and fix admin dashboard
- Integrated API tracking into analyze-bottle service - Added credit balance check before Gemini API calls - Deduct credits after successful Gemini analysis - Track both successful and failed Gemini API calls - Added debug logging to admin dashboard for recent API calls - Fixed error handling in analyze-bottle Now tracks both Google Search and Gemini AI API usage!
This commit is contained in:
@@ -30,7 +30,8 @@ export default async function AdminPage() {
|
||||
const stats = await getGlobalApiStats();
|
||||
|
||||
// Fetch recent API usage
|
||||
const { data: recentUsage } = await supabase
|
||||
console.log('[Admin Page] Fetching recent API usage...');
|
||||
const { data: recentUsage, error: recentError } = await supabase
|
||||
.from('api_usage')
|
||||
.select(`
|
||||
*,
|
||||
@@ -41,6 +42,8 @@ export default async function AdminPage() {
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(50);
|
||||
|
||||
console.log('[Admin Page] Recent usage - count:', recentUsage?.length, 'error:', recentError);
|
||||
|
||||
// Fetch per-user statistics
|
||||
const { data: userStats } = await supabase
|
||||
.from('api_usage')
|
||||
|
||||
Reference in New Issue
Block a user