/ services / analytics / config.ts
config.ts
 1  /**
 2   * Shared analytics configuration
 3   *
 4   * Common logic for determining when analytics should be disabled
 5   * across all analytics systems (Datadog, 1P)
 6   */
 7  
 8  import { isEnvTruthy } from '../../utils/envUtils.js'
 9  import { isTelemetryDisabled } from '../../utils/privacyLevel.js'
10  
11  /**
12   * Check if analytics operations should be disabled
13   *
14   * Analytics is disabled in the following cases:
15   * - Test environment (NODE_ENV === 'test')
16   * - Third-party cloud providers (Bedrock/Vertex)
17   * - Privacy level is no-telemetry or essential-traffic
18   */
19  export function isAnalyticsDisabled(): boolean {
20    return (
21      process.env.NODE_ENV === 'test' ||
22      isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
23      isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
24      isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
25      isTelemetryDisabled()
26    )
27  }
28  
29  /**
30   * Check if the feedback survey should be suppressed.
31   *
32   * Unlike isAnalyticsDisabled(), this does NOT block on 3P providers
33   * (Bedrock/Vertex/Foundry). The survey is a local UI prompt with no
34   * transcript data — enterprise customers capture responses via OTEL.
35   */
36  export function isFeedbackSurveyDisabled(): boolean {
37    return process.env.NODE_ENV === 'test' || isTelemetryDisabled()
38  }