Logs the auth type in the user prompts, api responses and errors (#3795)

This commit is contained in:
uttamkanodia14
2025-07-11 22:17:46 +05:30
committed by GitHub
parent ed00612cf7
commit 93284281de
9 changed files with 65 additions and 4 deletions

View File

@@ -212,6 +212,7 @@ export async function main() {
'event.timestamp': new Date().toISOString(),
prompt: input,
prompt_id,
auth_type: config.getContentGeneratorConfig().authType!,
prompt_length: input.length,
});

View File

@@ -273,6 +273,13 @@ describe('useGeminiStream', () => {
return clientInstance;
});
const contentGeneratorConfig = {
model: 'test-model',
apiKey: 'test-key',
vertexai: false,
authType: AuthType.USE_GEMINI,
};
mockConfig = {
apiKey: 'test-api-key',
model: 'gemini-pro',
@@ -307,6 +314,9 @@ describe('useGeminiStream', () => {
},
setQuotaErrorOccurred: vi.fn(),
getQuotaErrorOccurred: vi.fn(() => false),
getContentGeneratorConfig: vi
.fn()
.mockReturnValue(contentGeneratorConfig),
} as unknown as Config;
mockOnDebugMessage = vi.fn();
mockHandleSlashCommand = vi.fn().mockResolvedValue(false);

View File

@@ -223,7 +223,12 @@ export const useGeminiStream = (
const trimmedQuery = query.trim();
logUserPrompt(
config,
new UserPromptEvent(trimmedQuery.length, prompt_id, trimmedQuery),
new UserPromptEvent(
trimmedQuery.length,
prompt_id,
config.getContentGeneratorConfig().authType!,
trimmedQuery,
),
);
onDebugMessage(`User query: '${trimmedQuery}'`);
await logger?.logMessage(MessageSenderType.USER, trimmedQuery);