feat: add API endpoint dimension to usage statistics dashboard (#152)
- Tracks endpoints like /v1/chat/completions, /v1/messages, /v1/responses - New sortable/groupable table in usage dashboard with expandable groups - Enhanced usage database aggregation by endpoint + model + provider - Added endpoint tracking to all saveRequestUsage/saveRequestDetail calls - Maintains backward compatibility with existing data structure
This commit is contained in:
@@ -622,7 +622,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
thinking: null,
|
||||
finish_reason: jsonResponse.status || "unknown"
|
||||
},
|
||||
status: "success"
|
||||
status: "success",
|
||||
endpoint: clientRawRequest?.endpoint || null
|
||||
}).catch(() => { });
|
||||
|
||||
return {
|
||||
@@ -656,7 +657,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
tokens: usage,
|
||||
timestamp: new Date().toISOString(),
|
||||
connectionId: connectionId || undefined,
|
||||
apiKey: apiKey || undefined
|
||||
apiKey: apiKey || undefined,
|
||||
endpoint: clientRawRequest?.endpoint || null
|
||||
}).catch(() => { });
|
||||
}
|
||||
|
||||
@@ -676,7 +678,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
thinking: parsed.choices?.[0]?.message?.reasoning_content || null,
|
||||
finish_reason: parsed.choices?.[0]?.finish_reason || "unknown"
|
||||
},
|
||||
status: "success"
|
||||
status: "success",
|
||||
endpoint: clientRawRequest?.endpoint || null
|
||||
}).catch(() => { });
|
||||
|
||||
return {
|
||||
@@ -749,7 +752,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
tokens: usage,
|
||||
timestamp: new Date().toISOString(),
|
||||
connectionId: connectionId || undefined,
|
||||
apiKey: apiKey || undefined
|
||||
apiKey: apiKey || undefined,
|
||||
endpoint: clientRawRequest?.endpoint || null
|
||||
}).catch(err => {
|
||||
console.error("Failed to save usage stats:", err.message);
|
||||
});
|
||||
@@ -808,7 +812,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
null,
|
||||
finish_reason: translatedResponse?.choices?.[0]?.finish_reason || "unknown"
|
||||
},
|
||||
status: "success"
|
||||
status: "success",
|
||||
endpoint: clientRawRequest?.endpoint || null
|
||||
};
|
||||
|
||||
// Async save (don't block response)
|
||||
@@ -886,7 +891,8 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
||||
tokens: usage,
|
||||
timestamp: new Date().toISOString(),
|
||||
connectionId: connectionId || undefined,
|
||||
apiKey: apiKey || undefined
|
||||
apiKey: apiKey || undefined,
|
||||
endpoint: clientRawRequest?.endpoint || null
|
||||
}).catch(err => {
|
||||
console.error("Failed to save streaming usage stats:", err.message);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user