Restore GrowthBook analytics gates

This commit is contained in:
James Feng 2026-06-01 19:32:21 +08:00
parent 8f7e642d88
commit 7bf798d131
3 changed files with 28 additions and 22 deletions

View File

@ -92,19 +92,18 @@ 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 remote config and 1P Event Logging are permanently disabled. void Promise.all([
// Rationale: prevent startup-time remote feature flag fetching and Anthropic 1P event export. import('../services/analytics/firstPartyEventLogger.js'),
// Original code kept below for auditability. import('../services/analytics/growthbook.js'),
// ]).then(([fp, gb]) => {
// void Promise.all([ fp.initialize1PEventLogging()
// import('../services/analytics/firstPartyEventLogger.js'), // Rebuild the logger provider if tengu_1p_event_batch_config changes
// import('../services/analytics/growthbook.js'), // mid-session. Change detection (isEqual) is inside the handler so
// ]).then(([fp, gb]) => { // unchanged refreshes are no-ops.
// fp.initialize1PEventLogging() gb.onGrowthBookRefresh(() => {
// gb.onGrowthBookRefresh(() => { void fp.reinitialize1PEventLoggingIfConfigChanged()
// void fp.reinitialize1PEventLoggingIfConfigChanged() })
// }) })
// })
profileCheckpoint('init_after_1p_event_logging') profileCheckpoint('init_after_1p_event_logging')
// Populate OAuth account info if it is not already cached in config. This is needed since the // Populate OAuth account info if it is not already cached in config. This is needed since the
@ -291,9 +290,20 @@ export function initializeTelemetryAfterTrust(): void {
} }
async function doInitializeTelemetry(): Promise<void> { async function doInitializeTelemetry(): Promise<void> {
// CC_Pure: Telemetry initialization is permanently disabled. if (telemetryInitialized) {
// Rationale: avoid loading OpenTelemetry SDK and prevent metrics/logs/traces setup. // Already initialized, nothing to do
return return
}
// Skip entire OTel initialization when telemetry is not enabled.
// Prevents PerformanceMeasure accumulation in long-running sessions.
if (!isEnvTruthy(process.env.CLAUDE_CODE_ENABLE_TELEMETRY)) {
telemetryInitialized = true
logForDebugging(
'[3P telemetry] Skipped — CLAUDE_CODE_ENABLE_TELEMETRY not set',
)
return
}
// Set flag before init to prevent double initialization // Set flag before init to prevent double initialization
telemetryInitialized = true telemetryInitialized = true

View File

@ -688,9 +688,7 @@ 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 initialization is permanently disabled. void initializeAnalyticsGates();
// Rationale: avoid GrowthBook-backed analytics/feature-gate evaluation during startup.
// void initializeAnalyticsGates();
void prefetchOfficialMcpUrls(); void prefetchOfficialMcpUrls();
void refreshModelCapabilities(); void refreshModelCapabilities();

View File

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