MCPcopy Index your code
hub / github.com/codeaashu/claude-code / _checkMetricsEnabledAPI

Function _checkMetricsEnabledAPI

src/services/api/metricsOptOut.ts:53–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51}
52
53async function _checkMetricsEnabledAPI(): Promise<MetricsStatus> {
54 // Incident kill switch: skip the network call when nonessential traffic is disabled.
55 // Returning enabled:false sheds load at the consumer (bigqueryExporter skips
56 // export). Matches the non-subscriber early-return shape below.
57 if (isEssentialTrafficOnly()) {
58 return { enabled: false, hasError: false }
59 }
60
61 try {
62 const data = await withOAuth401Retry(_fetchMetricsEnabled, {
63 also403Revoked: true,
64 })
65
66 logForDebugging(
67 `Metrics opt-out API response: enabled=${data.metrics_logging_enabled}`,
68 )
69
70 return {
71 enabled: data.metrics_logging_enabled,
72 hasError: false,
73 }
74 } catch (error) {
75 logForDebugging(
76 `Failed to check metrics opt-out status: ${errorMessage(error)}`,
77 )
78 logError(error)
79 return { enabled: false, hasError: true }
80 }
81}
82
83// Create memoized version with custom error handling
84const memoizedCheckMetrics = memoizeWithTTLAsync(

Callers

nothing calls this directly

Calls 5

isEssentialTrafficOnlyFunction · 0.85
withOAuth401RetryFunction · 0.85
logForDebuggingFunction · 0.85
errorMessageFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected