fix(usage): match non-standard source ids

Include normalizeUsageSourceId(apiKey) in candidate ids so provider stats can match usage rows when source is classified as text (issue #198).
This commit is contained in:
Supra4E8C
2026-04-11 23:35:47 +08:00
Unverified
parent 7d58341941
commit 62cc7cc92d
+4
View File
@@ -376,6 +376,10 @@ export function buildCandidateUsageSourceIds(input: {
const apiKey = input.apiKey?.trim();
if (apiKey) {
// Include the normalised form first so that "non-standard" keys (e.g. short tokens,
// keys containing '/' etc.) that are classified as text by normalizeUsageSourceId()
// can still match usage details.
result.push(normalizeUsageSourceId(apiKey));
result.push(`${USAGE_SOURCE_PREFIX_KEY}${fnv1a64Hex(apiKey)}`);
result.push(`${USAGE_SOURCE_PREFIX_MASKED}${maskApiKey(apiKey)}`);
}