summaryrefslogtreecommitdiff
path: root/packages/core/src
diff options
context:
space:
mode:
authorJerop Kipruto <[email protected]>2025-06-23 17:19:40 -0400
committerGitHub <[email protected]>2025-06-23 21:19:40 +0000
commit98f3a7066e1aa9701fe1d4c89b046fe03b2420e5 (patch)
treeabf73fc75e63121dd04093e8b57db24eb39f0321 /packages/core/src
parent4d88054d3526285666f7377875d4774fd6291442 (diff)
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
Diffstat (limited to 'packages/core/src')
-rw-r--r--packages/core/src/config/config.ts10
-rw-r--r--packages/core/src/core/coreToolScheduler.test.ts2
-rw-r--r--packages/core/src/core/geminiChat.test.ts2
-rw-r--r--packages/core/src/core/nonInteractiveToolExecutor.test.ts2
-rw-r--r--packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts2
-rw-r--r--packages/core/src/telemetry/loggers.test.ts12
6 files changed, 15 insertions, 15 deletions
diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts
index d9161fae..65d69a41 100644
--- a/packages/core/src/config/config.ts
+++ b/packages/core/src/config/config.ts
@@ -57,7 +57,7 @@ export interface TelemetrySettings {
target?: TelemetryTarget;
otlpEndpoint?: string;
logPrompts?: boolean;
- disableDataCollection?: boolean;
+ usageStatisticsEnabled?: boolean;
}
export class MCPServerConfig {
@@ -181,7 +181,7 @@ export class Config {
target: params.telemetry?.target ?? DEFAULT_TELEMETRY_TARGET,
otlpEndpoint: params.telemetry?.otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT,
logPrompts: params.telemetry?.logPrompts ?? true,
- disableDataCollection: params.telemetry?.disableDataCollection ?? false,
+ usageStatisticsEnabled: params.telemetry?.usageStatisticsEnabled ?? true,
};
this.fileFiltering = {
@@ -205,7 +205,7 @@ export class Config {
initializeTelemetry(this);
}
- if (!this.getDisableDataCollection()) {
+ if (this.getUsageStatisticsEnabled()) {
ClearcutLogger.getInstance(this)?.logStartSessionEvent(
new StartSessionEvent(this),
);
@@ -385,8 +385,8 @@ export class Config {
return this.fileDiscoveryService;
}
- getDisableDataCollection(): boolean {
- return this.telemetrySettings.disableDataCollection ?? false;
+ getUsageStatisticsEnabled(): boolean {
+ return this.telemetrySettings.usageStatisticsEnabled ?? true;
}
getExtensionContextFilePaths(): string[] {
diff --git a/packages/core/src/core/coreToolScheduler.test.ts b/packages/core/src/core/coreToolScheduler.test.ts
index 656f8952..f80a1e37 100644
--- a/packages/core/src/core/coreToolScheduler.test.ts
+++ b/packages/core/src/core/coreToolScheduler.test.ts
@@ -77,7 +77,7 @@ describe('CoreToolScheduler', () => {
const mockConfig = {
getSessionId: () => 'test-session-id',
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
} as Config;
const scheduler = new CoreToolScheduler({
diff --git a/packages/core/src/core/geminiChat.test.ts b/packages/core/src/core/geminiChat.test.ts
index 45c9b06e..0ba8b053 100644
--- a/packages/core/src/core/geminiChat.test.ts
+++ b/packages/core/src/core/geminiChat.test.ts
@@ -27,7 +27,7 @@ const mockModelsModule = {
const mockConfig = {
getSessionId: () => 'test-session-id',
getTelemetryLogPromptsEnabled: () => true,
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
} as unknown as Config;
describe('GeminiChat', () => {
diff --git a/packages/core/src/core/nonInteractiveToolExecutor.test.ts b/packages/core/src/core/nonInteractiveToolExecutor.test.ts
index c6874c6e..5f22c3b8 100644
--- a/packages/core/src/core/nonInteractiveToolExecutor.test.ts
+++ b/packages/core/src/core/nonInteractiveToolExecutor.test.ts
@@ -18,7 +18,7 @@ import { Part, Type } from '@google/genai';
const mockConfig = {
getSessionId: () => 'test-session-id',
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
} as unknown as Config;
describe('executeToolCall', () => {
diff --git a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
index 5933de13..b29f4133 100644
--- a/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
+++ b/packages/core/src/telemetry/clearcut-logger/clearcut-logger.ts
@@ -46,7 +46,7 @@ export class ClearcutLogger {
}
static getInstance(config?: Config): ClearcutLogger | undefined {
- if (config === undefined || config?.getDisableDataCollection())
+ if (config === undefined || !config?.getUsageStatisticsEnabled())
return undefined;
if (!ClearcutLogger.instance) {
ClearcutLogger.instance = new ClearcutLogger(config);
diff --git a/packages/core/src/telemetry/loggers.test.ts b/packages/core/src/telemetry/loggers.test.ts
index 2659f398..2d7835bf 100644
--- a/packages/core/src/telemetry/loggers.test.ts
+++ b/packages/core/src/telemetry/loggers.test.ts
@@ -71,7 +71,7 @@ describe('loggers', () => {
authType: AuthType.USE_VERTEX_AI,
}),
getTelemetryEnabled: () => true,
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
getTelemetryLogPromptsEnabled: () => true,
getFileFilteringRespectGitIgnore: () => true,
getFileFilteringAllowBuildArtifacts: () => false,
@@ -116,7 +116,7 @@ describe('loggers', () => {
getSessionId: () => 'test-session-id',
getTelemetryEnabled: () => true,
getTelemetryLogPromptsEnabled: () => true,
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
} as unknown as Config;
it('should log a user prompt', () => {
@@ -142,7 +142,7 @@ describe('loggers', () => {
getTelemetryEnabled: () => true,
getTelemetryLogPromptsEnabled: () => false,
getTargetDir: () => 'target-dir',
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
} as unknown as Config;
const event = new UserPromptEvent(11, 'test-prompt');
@@ -164,7 +164,7 @@ describe('loggers', () => {
const mockConfig = {
getSessionId: () => 'test-session-id',
getTargetDir: () => 'target-dir',
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
getTelemetryEnabled: () => true,
getTelemetryLogPromptsEnabled: () => true,
} as Config;
@@ -270,7 +270,7 @@ describe('loggers', () => {
const mockConfig = {
getSessionId: () => 'test-session-id',
getTargetDir: () => 'target-dir',
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
getTelemetryEnabled: () => true,
getTelemetryLogPromptsEnabled: () => true,
} as Config;
@@ -347,7 +347,7 @@ describe('loggers', () => {
getSessionId: () => 'test-session-id',
getTargetDir: () => 'target-dir',
getGeminiClient: () => mockGeminiClient,
- getDisableDataCollection: () => false,
+ getUsageStatisticsEnabled: () => true,
getTelemetryEnabled: () => true,
getTelemetryLogPromptsEnabled: () => true,
} as Config;