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;
|
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 {
|
export interface RumEvent {
|
||||||
timestamp?: number;
|
timestamp?: number;
|
||||||
event_type?: 'view' | 'action' | 'exception' | 'resource';
|
event_type?: 'view' | 'action' | 'exception' | 'resource';
|
||||||
@@ -78,6 +93,8 @@ export interface RumPayload {
|
|||||||
user: RumUser;
|
user: RumUser;
|
||||||
session: RumSession;
|
session: RumSession;
|
||||||
view: RumView;
|
view: RumView;
|
||||||
|
os?: RumOS;
|
||||||
|
device?: RumDevice;
|
||||||
events: RumEvent[];
|
events: RumEvent[];
|
||||||
properties?: Record<string, unknown>;
|
properties?: Record<string, unknown>;
|
||||||
_v: string;
|
_v: string;
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import {
|
|||||||
afterEach,
|
afterEach,
|
||||||
afterAll,
|
afterAll,
|
||||||
} from 'vitest';
|
} from 'vitest';
|
||||||
|
import * as os from 'node:os';
|
||||||
import { QwenLogger, TEST_ONLY } from './qwen-logger.js';
|
import { QwenLogger, TEST_ONLY } from './qwen-logger.js';
|
||||||
import type { Config } from '../../config/config.js';
|
import type { Config } from '../../config/config.js';
|
||||||
|
import { AuthType } from '../../core/contentGenerator.js';
|
||||||
import {
|
import {
|
||||||
StartSessionEvent,
|
StartSessionEvent,
|
||||||
EndSessionEvent,
|
EndSessionEvent,
|
||||||
@@ -22,7 +24,7 @@ import {
|
|||||||
KittySequenceOverflowEvent,
|
KittySequenceOverflowEvent,
|
||||||
IdeConnectionType,
|
IdeConnectionType,
|
||||||
} from '../types.js';
|
} from '../types.js';
|
||||||
import type { RumEvent } from './event-types.js';
|
import type { RumEvent, RumPayload } from './event-types.js';
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
vi.mock('../../utils/user_id.js', () => ({
|
vi.mock('../../utils/user_id.js', () => ({
|
||||||
@@ -46,6 +48,7 @@ const makeFakeConfig = (overrides: Partial<Config> = {}): Config => {
|
|||||||
getCliVersion: () => '1.0.0',
|
getCliVersion: () => '1.0.0',
|
||||||
getProxy: () => undefined,
|
getProxy: () => undefined,
|
||||||
getContentGeneratorConfig: () => ({ authType: 'test-auth' }),
|
getContentGeneratorConfig: () => ({ authType: 'test-auth' }),
|
||||||
|
getAuthType: () => AuthType.QWEN_OAUTH,
|
||||||
getMcpServers: () => ({}),
|
getMcpServers: () => ({}),
|
||||||
getModel: () => 'test-model',
|
getModel: () => 'test-model',
|
||||||
getEmbeddingModel: () => 'test-embedding',
|
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', () => {
|
describe('event queue management', () => {
|
||||||
it('should handle event overflow gracefully', () => {
|
it('should handle event overflow gracefully', () => {
|
||||||
const debugConfig = makeFakeConfig({ getDebugMode: () => true });
|
const debugConfig = makeFakeConfig({ getDebugMode: () => true });
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
|
import * as os from 'node:os';
|
||||||
import { HttpsProxyAgent } from 'https-proxy-agent';
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
@@ -45,6 +46,7 @@ import type {
|
|||||||
RumResourceEvent,
|
RumResourceEvent,
|
||||||
RumExceptionEvent,
|
RumExceptionEvent,
|
||||||
RumPayload,
|
RumPayload,
|
||||||
|
RumOS,
|
||||||
} from './event-types.js';
|
} from './event-types.js';
|
||||||
import type { Config } from '../../config/config.js';
|
import type { Config } from '../../config/config.js';
|
||||||
import { safeJsonStringify } from '../../utils/safeJsonStringify.js';
|
import { safeJsonStringify } from '../../utils/safeJsonStringify.js';
|
||||||
@@ -214,9 +216,17 @@ export class QwenLogger {
|
|||||||
return this.createRumEvent('exception', type, name, properties);
|
return this.createRumEvent('exception', type, name, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getOsMetadata(): RumOS {
|
||||||
|
return {
|
||||||
|
type: os.platform(),
|
||||||
|
version: os.release(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async createRumPayload(): Promise<RumPayload> {
|
async createRumPayload(): Promise<RumPayload> {
|
||||||
const authType = this.config?.getAuthType();
|
const authType = this.config?.getAuthType();
|
||||||
const version = this.config?.getCliVersion() || 'unknown';
|
const version = this.config?.getCliVersion() || 'unknown';
|
||||||
|
const osMetadata = this.getOsMetadata();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app: {
|
app: {
|
||||||
@@ -235,6 +245,7 @@ export class QwenLogger {
|
|||||||
id: this.sessionId,
|
id: this.sessionId,
|
||||||
name: 'qwen-code-cli',
|
name: 'qwen-code-cli',
|
||||||
},
|
},
|
||||||
|
os: osMetadata,
|
||||||
|
|
||||||
events: this.events.toArray() as RumEvent[],
|
events: this.events.toArray() as RumEvent[],
|
||||||
properties: {
|
properties: {
|
||||||
|
|||||||
Reference in New Issue
Block a user