From 62cc7cc92d431008883d9a893c48f80e31e1a238 Mon Sep 17 00:00:00 2001 From: Supra4E8C Date: Sat, 11 Apr 2026 23:35:47 +0800 Subject: [PATCH] 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). --- src/utils/usage.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/usage.ts b/src/utils/usage.ts index 70d2c3a..a6827b5 100644 --- a/src/utils/usage.ts +++ b/src/utils/usage.ts @@ -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)}`); }