feat: add os platform and version in log report (#1053)

This commit is contained in:
tanzhenxin
2025-11-18 13:43:17 +08:00
committed by GitHub
parent 0eeffc6875
commit 5bc309b3dc
3 changed files with 50 additions and 1 deletions

View File

@@ -13,8 +13,10 @@ import {
afterEach,
afterAll,
} from 'vitest';
import * as os from 'node:os';
import { QwenLogger, TEST_ONLY } from './qwen-logger.js';
import type { Config } from '../../config/config.js';
import { AuthType } from '../../core/contentGenerator.js';
import {
StartSessionEvent,
EndSessionEvent,
@@ -22,7 +24,7 @@ import {
KittySequenceOverflowEvent,
IdeConnectionType,
} from '../types.js';
import type { RumEvent } from './event-types.js';
import type { RumEvent, RumPayload } from './event-types.js';
// Mock dependencies
vi.mock('../../utils/user_id.js', () => ({
@@ -46,6 +48,7 @@ const makeFakeConfig = (overrides: Partial<Config> = {}): Config => {
getCliVersion: () => '1.0.0',
getProxy: () => undefined,
getContentGeneratorConfig: () => ({ authType: 'test-auth' }),
getAuthType: () => AuthType.QWEN_OAUTH,
getMcpServers: () => ({}),
getModel: () => 'test-model',
getEmbeddingModel: () => 'test-embedding',
@@ -102,6 +105,24 @@ describe('QwenLogger', () => {
});
});
describe('createRumPayload', () => {
it('includes os metadata in payload', async () => {
const logger = QwenLogger.getInstance(mockConfig)!;
const payload = await (
logger as unknown as {
createRumPayload(): Promise<RumPayload>;
}
).createRumPayload();
expect(payload.os).toEqual(
expect.objectContaining({
type: os.platform(),
version: os.release(),
}),
);
});
});
describe('event queue management', () => {
it('should handle event overflow gracefully', () => {
const debugConfig = makeFakeConfig({ getDebugMode: () => true });