refactor: rename `disableDataCollection` to `dataCollectionEnabled` (#1319)
Renames the `disableDataCollection` flag to the more intuitive and positive `dataCollectionEnabled`. This change improves code clarity by avoiding double negatives and making the purpose of the flag more direct. The logic has been inverted wherever the flag is used to accommodate the new naming convention. Using a suffix like `"Enabled"` follows a common convention that improves readability. - A condition like `if (dataCollectionEnabled)` reads like a natural language sentence ("if data collection is enabled"), which reduces cognitive load. - Distinguishes the boolean flag (representing a state) from potential functions that would perform an action (e.g., `enableDataCollection()` or `disableDataCollection()`), avoiding ambiguity between checking a value and calling a function. #750
This commit is contained in:
parent
4d88054d35
commit
98f3a7066e
|
@ -226,7 +226,8 @@ export async function loadCliConfig(
|
||||||
process.env.OTEL_EXPORTER_OTLP_ENDPOINT ??
|
process.env.OTEL_EXPORTER_OTLP_ENDPOINT ??
|
||||||
settings.telemetry?.otlpEndpoint,
|
settings.telemetry?.otlpEndpoint,
|
||||||
logPrompts: argv.telemetryLogPrompts ?? settings.telemetry?.logPrompts,
|
logPrompts: argv.telemetryLogPrompts ?? settings.telemetry?.logPrompts,
|
||||||
disableDataCollection: settings.telemetry?.disableDataCollection ?? false,
|
usageStatisticsEnabled:
|
||||||
|
settings.telemetry?.usageStatisticsEnabled ?? true,
|
||||||
},
|
},
|
||||||
// Git-aware file filtering settings
|
// Git-aware file filtering settings
|
||||||
fileFiltering: {
|
fileFiltering: {
|
||||||
|
|
|
@ -288,7 +288,7 @@ describe('useGeminiStream', () => {
|
||||||
getProjectRoot: vi.fn(() => '/test/dir'),
|
getProjectRoot: vi.fn(() => '/test/dir'),
|
||||||
getCheckpointingEnabled: vi.fn(() => false),
|
getCheckpointingEnabled: vi.fn(() => false),
|
||||||
getGeminiClient: mockGetGeminiClient,
|
getGeminiClient: mockGetGeminiClient,
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
addHistory: vi.fn(),
|
addHistory: vi.fn(),
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
mockOnDebugMessage = vi.fn();
|
mockOnDebugMessage = vi.fn();
|
||||||
|
|
|
@ -48,7 +48,7 @@ const mockToolRegistry = {
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getToolRegistry: vi.fn(() => mockToolRegistry as unknown as ToolRegistry),
|
getToolRegistry: vi.fn(() => mockToolRegistry as unknown as ToolRegistry),
|
||||||
getApprovalMode: vi.fn(() => ApprovalMode.DEFAULT),
|
getApprovalMode: vi.fn(() => ApprovalMode.DEFAULT),
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTool: Tool = {
|
const mockTool: Tool = {
|
||||||
|
|
|
@ -57,7 +57,7 @@ export interface TelemetrySettings {
|
||||||
target?: TelemetryTarget;
|
target?: TelemetryTarget;
|
||||||
otlpEndpoint?: string;
|
otlpEndpoint?: string;
|
||||||
logPrompts?: boolean;
|
logPrompts?: boolean;
|
||||||
disableDataCollection?: boolean;
|
usageStatisticsEnabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MCPServerConfig {
|
export class MCPServerConfig {
|
||||||
|
@ -181,7 +181,7 @@ export class Config {
|
||||||
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 ?? true,
|
||||||
disableDataCollection: params.telemetry?.disableDataCollection ?? false,
|
usageStatisticsEnabled: params.telemetry?.usageStatisticsEnabled ?? true,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fileFiltering = {
|
this.fileFiltering = {
|
||||||
|
@ -205,7 +205,7 @@ export class Config {
|
||||||
initializeTelemetry(this);
|
initializeTelemetry(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.getDisableDataCollection()) {
|
if (this.getUsageStatisticsEnabled()) {
|
||||||
ClearcutLogger.getInstance(this)?.logStartSessionEvent(
|
ClearcutLogger.getInstance(this)?.logStartSessionEvent(
|
||||||
new StartSessionEvent(this),
|
new StartSessionEvent(this),
|
||||||
);
|
);
|
||||||
|
@ -385,8 +385,8 @@ export class Config {
|
||||||
return this.fileDiscoveryService;
|
return this.fileDiscoveryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDisableDataCollection(): boolean {
|
getUsageStatisticsEnabled(): boolean {
|
||||||
return this.telemetrySettings.disableDataCollection ?? false;
|
return this.telemetrySettings.usageStatisticsEnabled ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getExtensionContextFilePaths(): string[] {
|
getExtensionContextFilePaths(): string[] {
|
||||||
|
|
|
@ -77,7 +77,7 @@ describe('CoreToolScheduler', () => {
|
||||||
|
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
} as Config;
|
} as Config;
|
||||||
|
|
||||||
const scheduler = new CoreToolScheduler({
|
const scheduler = new CoreToolScheduler({
|
||||||
|
|
|
@ -27,7 +27,7 @@ const mockModelsModule = {
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getTelemetryLogPromptsEnabled: () => true,
|
getTelemetryLogPromptsEnabled: () => true,
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
describe('GeminiChat', () => {
|
describe('GeminiChat', () => {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { Part, Type } from '@google/genai';
|
||||||
|
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
describe('executeToolCall', () => {
|
describe('executeToolCall', () => {
|
||||||
|
|
|
@ -46,7 +46,7 @@ export class ClearcutLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getInstance(config?: Config): ClearcutLogger | undefined {
|
static getInstance(config?: Config): ClearcutLogger | undefined {
|
||||||
if (config === undefined || config?.getDisableDataCollection())
|
if (config === undefined || !config?.getUsageStatisticsEnabled())
|
||||||
return undefined;
|
return undefined;
|
||||||
if (!ClearcutLogger.instance) {
|
if (!ClearcutLogger.instance) {
|
||||||
ClearcutLogger.instance = new ClearcutLogger(config);
|
ClearcutLogger.instance = new ClearcutLogger(config);
|
||||||
|
|
|
@ -71,7 +71,7 @@ describe('loggers', () => {
|
||||||
authType: AuthType.USE_VERTEX_AI,
|
authType: AuthType.USE_VERTEX_AI,
|
||||||
}),
|
}),
|
||||||
getTelemetryEnabled: () => true,
|
getTelemetryEnabled: () => true,
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getTelemetryLogPromptsEnabled: () => true,
|
getTelemetryLogPromptsEnabled: () => true,
|
||||||
getFileFilteringRespectGitIgnore: () => true,
|
getFileFilteringRespectGitIgnore: () => true,
|
||||||
getFileFilteringAllowBuildArtifacts: () => false,
|
getFileFilteringAllowBuildArtifacts: () => false,
|
||||||
|
@ -116,7 +116,7 @@ describe('loggers', () => {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getTelemetryEnabled: () => true,
|
getTelemetryEnabled: () => true,
|
||||||
getTelemetryLogPromptsEnabled: () => true,
|
getTelemetryLogPromptsEnabled: () => true,
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
it('should log a user prompt', () => {
|
it('should log a user prompt', () => {
|
||||||
|
@ -142,7 +142,7 @@ describe('loggers', () => {
|
||||||
getTelemetryEnabled: () => true,
|
getTelemetryEnabled: () => true,
|
||||||
getTelemetryLogPromptsEnabled: () => false,
|
getTelemetryLogPromptsEnabled: () => false,
|
||||||
getTargetDir: () => 'target-dir',
|
getTargetDir: () => 'target-dir',
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
const event = new UserPromptEvent(11, 'test-prompt');
|
const event = new UserPromptEvent(11, 'test-prompt');
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ describe('loggers', () => {
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getTargetDir: () => 'target-dir',
|
getTargetDir: () => 'target-dir',
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getTelemetryEnabled: () => true,
|
getTelemetryEnabled: () => true,
|
||||||
getTelemetryLogPromptsEnabled: () => true,
|
getTelemetryLogPromptsEnabled: () => true,
|
||||||
} as Config;
|
} as Config;
|
||||||
|
@ -270,7 +270,7 @@ describe('loggers', () => {
|
||||||
const mockConfig = {
|
const mockConfig = {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getTargetDir: () => 'target-dir',
|
getTargetDir: () => 'target-dir',
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getTelemetryEnabled: () => true,
|
getTelemetryEnabled: () => true,
|
||||||
getTelemetryLogPromptsEnabled: () => true,
|
getTelemetryLogPromptsEnabled: () => true,
|
||||||
} as Config;
|
} as Config;
|
||||||
|
@ -347,7 +347,7 @@ describe('loggers', () => {
|
||||||
getSessionId: () => 'test-session-id',
|
getSessionId: () => 'test-session-id',
|
||||||
getTargetDir: () => 'target-dir',
|
getTargetDir: () => 'target-dir',
|
||||||
getGeminiClient: () => mockGeminiClient,
|
getGeminiClient: () => mockGeminiClient,
|
||||||
getDisableDataCollection: () => false,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getTelemetryEnabled: () => true,
|
getTelemetryEnabled: () => true,
|
||||||
getTelemetryLogPromptsEnabled: () => true,
|
getTelemetryLogPromptsEnabled: () => true,
|
||||||
} as Config;
|
} as Config;
|
||||||
|
|
Loading…
Reference in New Issue