mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
Clearcut logging - initial implementation (#1274)
Flag-guarded initial implementation of a clearcut logger to collect telemetry data and send it to Concord for dashboards, etc.
This commit is contained in:
parent
c9950b3cb2
commit
4cfab0a893
23 changed files with 1051 additions and 335 deletions
|
|
@ -38,12 +38,17 @@ const MockedGeminiClientClass = vi.hoisted(() =>
|
|||
}),
|
||||
);
|
||||
|
||||
const MockedUserPromptEvent = vi.hoisted(() =>
|
||||
vi.fn().mockImplementation(() => {}),
|
||||
);
|
||||
|
||||
vi.mock('@gemini-cli/core', async (importOriginal) => {
|
||||
const actualCoreModule = (await importOriginal()) as any;
|
||||
return {
|
||||
...actualCoreModule,
|
||||
GitService: vi.fn(),
|
||||
GeminiClient: MockedGeminiClientClass,
|
||||
UserPromptEvent: MockedUserPromptEvent,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -283,6 +288,7 @@ describe('useGeminiStream', () => {
|
|||
getProjectRoot: vi.fn(() => '/test/dir'),
|
||||
getCheckpointingEnabled: vi.fn(() => false),
|
||||
getGeminiClient: mockGetGeminiClient,
|
||||
getDisableDataCollection: () => false,
|
||||
addHistory: vi.fn(),
|
||||
} as unknown as Config;
|
||||
mockOnDebugMessage = vi.fn();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {
|
|||
EditorType,
|
||||
ThoughtSummary,
|
||||
isAuthError,
|
||||
UserPromptEvent,
|
||||
} from '@gemini-cli/core';
|
||||
import { type Part, type PartListUnion } from '@google/genai';
|
||||
import {
|
||||
|
|
@ -213,10 +214,10 @@ export const useGeminiStream = (
|
|||
|
||||
if (typeof query === 'string') {
|
||||
const trimmedQuery = query.trim();
|
||||
logUserPrompt(config, {
|
||||
prompt: trimmedQuery,
|
||||
prompt_length: trimmedQuery.length,
|
||||
});
|
||||
logUserPrompt(
|
||||
config,
|
||||
new UserPromptEvent(trimmedQuery.length, trimmedQuery),
|
||||
);
|
||||
onDebugMessage(`User query: '${trimmedQuery}'`);
|
||||
await logger?.logMessage(MessageSenderType.USER, trimmedQuery);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ const mockToolRegistry = {
|
|||
const mockConfig = {
|
||||
getToolRegistry: vi.fn(() => mockToolRegistry as unknown as ToolRegistry),
|
||||
getApprovalMode: vi.fn(() => ApprovalMode.DEFAULT),
|
||||
getDisableDataCollection: () => false,
|
||||
};
|
||||
|
||||
const mockTool: Tool = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue