fix config (#163)

Co-authored-by: test <test@gmail.com>
This commit is contained in:
Fan
2025-08-01 01:24:33 +08:00
committed by GitHub
parent 44de3f686c
commit bdf946a321
4 changed files with 15 additions and 15 deletions

View File

@@ -78,7 +78,7 @@ vi.mock('@qwen-code/qwen-code-core', async () => {
getTelemetryLogPromptsEnabled(): boolean { getTelemetryLogPromptsEnabled(): boolean {
return ( return (
(this as unknown as { telemetrySettings?: { logPrompts?: boolean } }) (this as unknown as { telemetrySettings?: { logPrompts?: boolean } })
.telemetrySettings?.logPrompts ?? true .telemetrySettings?.logPrompts ?? false
); );
} }
@@ -262,12 +262,12 @@ describe('loadCliConfig telemetry', () => {
vi.restoreAllMocks(); vi.restoreAllMocks();
}); });
it('should set telemetry to true by default when no flag or setting is present', async () => { it('should set telemetry to false by default when no flag or setting is present', async () => {
process.argv = ['node', 'script.js']; process.argv = ['node', 'script.js'];
const argv = await parseArguments(); const argv = await parseArguments();
const settings: Settings = {}; const settings: Settings = {};
const config = await loadCliConfig(settings, [], 'test-session', argv); const config = await loadCliConfig(settings, [], 'test-session', argv);
expect(config.getTelemetryEnabled()).toBe(true); expect(config.getTelemetryEnabled()).toBe(false);
}); });
it('should set telemetry to true when --telemetry flag is present', async () => { it('should set telemetry to true when --telemetry flag is present', async () => {
@@ -411,12 +411,12 @@ describe('loadCliConfig telemetry', () => {
expect(config.getTelemetryLogPromptsEnabled()).toBe(false); expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
}); });
it('should use default log prompts (true) if no value is provided via CLI or settings', async () => { it('should use default log prompts (false) if no value is provided via CLI or settings', async () => {
process.argv = ['node', 'script.js']; process.argv = ['node', 'script.js'];
const argv = await parseArguments(); const argv = await parseArguments();
const settings: Settings = { telemetry: { enabled: true } }; const settings: Settings = { telemetry: { enabled: true } };
const config = await loadCliConfig(settings, [], 'test-session', argv); const config = await loadCliConfig(settings, [], 'test-session', argv);
expect(config.getTelemetryLogPromptsEnabled()).toBe(true); expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
}); });
it('should set enableOpenAILogging to true when --openai-logging flag is present', async () => { it('should set enableOpenAILogging to true when --openai-logging flag is present', async () => {

View File

@@ -234,11 +234,11 @@ describe('Server Config (config.ts)', () => {
expect(config.getTelemetryEnabled()).toBe(false); expect(config.getTelemetryEnabled()).toBe(false);
}); });
it('Config constructor should default telemetry to default value if not provided', () => { it('Config constructor should default telemetry to false if not provided', () => {
const paramsWithoutTelemetry: ConfigParameters = { ...baseParams }; const paramsWithoutTelemetry: ConfigParameters = { ...baseParams };
delete paramsWithoutTelemetry.telemetry; delete paramsWithoutTelemetry.telemetry;
const config = new Config(paramsWithoutTelemetry); const config = new Config(paramsWithoutTelemetry);
expect(config.getTelemetryEnabled()).toBe(TELEMETRY_SETTINGS.enabled); expect(config.getTelemetryEnabled()).toBe(false);
}); });
it('should have a getFileService method that returns FileDiscoveryService', () => { it('should have a getFileService method that returns FileDiscoveryService', () => {
@@ -285,20 +285,20 @@ describe('Server Config (config.ts)', () => {
expect(config.getTelemetryLogPromptsEnabled()).toBe(false); expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
}); });
it('should return default logPrompts setting (true) if not provided', () => { it('should return default logPrompts setting (false) if not provided', () => {
const params: ConfigParameters = { const params: ConfigParameters = {
...baseParams, ...baseParams,
telemetry: { enabled: true }, telemetry: { enabled: true },
}; };
const config = new Config(params); const config = new Config(params);
expect(config.getTelemetryLogPromptsEnabled()).toBe(true); expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
}); });
it('should return default logPrompts setting (true) if telemetry object is not provided', () => { it('should return default logPrompts setting (false) if telemetry object is not provided', () => {
const paramsWithoutTelemetry: ConfigParameters = { ...baseParams }; const paramsWithoutTelemetry: ConfigParameters = { ...baseParams };
delete paramsWithoutTelemetry.telemetry; delete paramsWithoutTelemetry.telemetry;
const config = new Config(paramsWithoutTelemetry); const config = new Config(paramsWithoutTelemetry);
expect(config.getTelemetryLogPromptsEnabled()).toBe(true); expect(config.getTelemetryLogPromptsEnabled()).toBe(false);
}); });
it('should return default telemetry target if telemetry object is not provided', () => { it('should return default telemetry target if telemetry object is not provided', () => {

View File

@@ -244,10 +244,10 @@ export class Config {
this.showMemoryUsage = params.showMemoryUsage ?? false; this.showMemoryUsage = params.showMemoryUsage ?? false;
this.accessibility = params.accessibility ?? {}; this.accessibility = params.accessibility ?? {};
this.telemetrySettings = { this.telemetrySettings = {
enabled: params.telemetry?.enabled ?? true, enabled: params.telemetry?.enabled ?? false,
target: params.telemetry?.target ?? DEFAULT_TELEMETRY_TARGET, target: params.telemetry?.target ?? DEFAULT_TELEMETRY_TARGET,
otlpEndpoint: params.telemetry?.otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT, otlpEndpoint: params.telemetry?.otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT,
logPrompts: params.telemetry?.logPrompts ?? true, logPrompts: params.telemetry?.logPrompts ?? false,
}; };
this.usageStatisticsEnabled = params.usageStatisticsEnabled ?? true; this.usageStatisticsEnabled = params.usageStatisticsEnabled ?? true;
@@ -474,7 +474,7 @@ export class Config {
} }
getTelemetryLogPromptsEnabled(): boolean { getTelemetryLogPromptsEnabled(): boolean {
return this.telemetrySettings.logPrompts ?? true; return this.telemetrySettings.logPrompts ?? false;
} }
getTelemetryOtlpEndpoint(): string { getTelemetryOtlpEndpoint(): string {

View File

@@ -72,7 +72,7 @@ export function initializeTelemetry(config: Config): void {
const metadata = new Metadata(); const metadata = new Metadata();
metadata.set( metadata.set(
'Authentication', 'Authentication',
'gb4w8c3ygj@0c2aed5f1449f6f_gb4w8c3ygj@53df7ad2afe8301', 'gb7x9m2kzp@8f4e3b6c9d2a1e5_qw7x9m2kzp@19a8c5f2b4e7d93',
); );
const spanExporter = useOtlp const spanExporter = useOtlp