CC_Pure: disable telemetry, GrowthBook, analytics sinks and gates

4-layer defense-in-depth:

Layer 1 (wrapper): CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 + redundant guards
Layer 2 (init.ts): Cut GrowthBook/1P Event Logging init + doInitializeTelemetry() early return
Layer 3 (sinks.ts): Do not attach initializeAnalyticsSink()
Layer 4 (main.tsx): Do not call initializeAnalyticsGates()

No functional code modified. Only init paths and sink attachment are cut.
config.ts preserved as-is (no hardcoded return true).

Modified: 3 source files (init.ts, sinks.ts, main.tsx)
Plus: config.ts restored from earlier return-true experiment back to original.

Verified:
- bun run build: OK (491 files bundled)
- strace --version: 0 external connections
- strace --help: 0 external connections
- strace -p prompt: 0 api.anthropic / statsig / sentry / datadog / growthbook connections
This commit is contained in:
James Feng 2026-06-01 12:29:36 +08:00
parent 72ab9bc764
commit dd9bfcbbec
4 changed files with 18 additions and 8 deletions

View File

@ -92,8 +92,10 @@ export const init = memoize(async (): Promise<void> => {
// loading OpenTelemetry sdk-logs at startup). growthbook.js is already in // loading OpenTelemetry sdk-logs at startup). growthbook.js is already in
// the module cache by this point (firstPartyEventLogger imports it), so the // the module cache by this point (firstPartyEventLogger imports it), so the
// second dynamic import adds no load cost. // second dynamic import adds no load cost.
// CC_Pure: GrowthBook + 1P Event Logging 已永久禁用 // CC_Pure: GrowthBook remote config and 1P Event Logging are permanently disabled.
// (原代码保留以供参考) // Rationale: prevent startup-time remote feature flag fetching and Anthropic 1P event export.
// Original code kept below for auditability.
//
// void Promise.all([ // void Promise.all([
// import('../services/analytics/firstPartyEventLogger.js'), // import('../services/analytics/firstPartyEventLogger.js'),
// import('../services/analytics/growthbook.js'), // import('../services/analytics/growthbook.js'),
@ -289,8 +291,9 @@ export function initializeTelemetryAfterTrust(): void {
} }
async function doInitializeTelemetry(): Promise<void> { async function doInitializeTelemetry(): Promise<void> {
// CC_Pure: 遥测已完全禁用 // CC_Pure: Telemetry initialization is permanently disabled.
return; // Rationale: avoid loading OpenTelemetry SDK and prevent metrics/logs/traces setup.
return
// Set flag before init to prevent double initialization // Set flag before init to prevent double initialization
telemetryInitialized = true telemetryInitialized = true

View File

@ -688,7 +688,8 @@ export function startDeferredPrefetches(): void {
void countFilesRoundedRg(getCwd(), AbortSignal.timeout(3000), []); void countFilesRoundedRg(getCwd(), AbortSignal.timeout(3000), []);
// Analytics and feature flag initialization // Analytics and feature flag initialization
// CC_Pure: Analytics gate 初始化已永久禁用 // CC_Pure: Analytics gate initialization is permanently disabled.
// Rationale: avoid GrowthBook-backed analytics/feature-gate evaluation during startup.
// void initializeAnalyticsGates(); // void initializeAnalyticsGates();
void prefetchOfficialMcpUrls(); void prefetchOfficialMcpUrls();

View File

@ -17,8 +17,13 @@ import { isTelemetryDisabled } from '../../utils/privacyLevel.js'
* - Privacy level is no-telemetry or essential-traffic * - Privacy level is no-telemetry or essential-traffic
*/ */
export function isAnalyticsDisabled(): boolean { export function isAnalyticsDisabled(): boolean {
// CC_Pure: 永久禁用所有遥测上报Anthropic 数据收集已完全移除) return (
return true; process.env.NODE_ENV === 'test' ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
isTelemetryDisabled()
)
} }
/** /**

View File

@ -13,6 +13,7 @@ import { initializeAnalyticsSink } from '../services/analytics/sink.js'
*/ */
export function initSinks(): void { export function initSinks(): void {
initializeErrorLogSink() initializeErrorLogSink()
// CC_Pure: Analytics sink 已永久禁用 // CC_Pure: Analytics sink is permanently disabled.
// Rationale: keep local error logging, but do not attach telemetry/analytics event pipelines.
// initializeAnalyticsSink() // initializeAnalyticsSink()
} }