mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat: add os platform and version in log report (#1053)
This commit is contained in:
@@ -19,6 +19,21 @@ export interface RumView {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface RumOS {
|
||||
type?: string;
|
||||
version?: string;
|
||||
container?: string;
|
||||
container_version?: string;
|
||||
}
|
||||
|
||||
export interface RumDevice {
|
||||
id?: string;
|
||||
name?: string;
|
||||
type?: string;
|
||||
brand?: string;
|
||||
model?: string;
|
||||
}
|
||||
|
||||
export interface RumEvent {
|
||||
timestamp?: number;
|
||||
event_type?: 'view' | 'action' | 'exception' | 'resource';
|
||||
@@ -78,6 +93,8 @@ export interface RumPayload {
|
||||
user: RumUser;
|
||||
session: RumSession;
|
||||
view: RumView;
|
||||
os?: RumOS;
|
||||
device?: RumDevice;
|
||||
events: RumEvent[];
|
||||
properties?: Record<string, unknown>;
|
||||
_v: string;
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import { Buffer } from 'buffer';
|
||||
import * as https from 'https';
|
||||
import * as os from 'node:os';
|
||||
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||
|
||||
import type {
|
||||
@@ -45,6 +46,7 @@ import type {
|
||||
RumResourceEvent,
|
||||
RumExceptionEvent,
|
||||
RumPayload,
|
||||
RumOS,
|
||||
} from './event-types.js';
|
||||
import type { Config } from '../../config/config.js';
|
||||
import { safeJsonStringify } from '../../utils/safeJsonStringify.js';
|
||||
@@ -214,9 +216,17 @@ export class QwenLogger {
|
||||
return this.createRumEvent('exception', type, name, properties);
|
||||
}
|
||||
|
||||
private getOsMetadata(): RumOS {
|
||||
return {
|
||||
type: os.platform(),
|
||||
version: os.release(),
|
||||
};
|
||||
}
|
||||
|
||||
async createRumPayload(): Promise<RumPayload> {
|
||||
const authType = this.config?.getAuthType();
|
||||
const version = this.config?.getCliVersion() || 'unknown';
|
||||
const osMetadata = this.getOsMetadata();
|
||||
|
||||
return {
|
||||
app: {
|
||||
@@ -235,6 +245,7 @@ export class QwenLogger {
|
||||
id: this.sessionId,
|
||||
name: 'qwen-code-cli',
|
||||
},
|
||||
os: osMetadata,
|
||||
|
||||
events: this.events.toArray() as RumEvent[],
|
||||
properties: {
|
||||
|
||||
Reference in New Issue
Block a user