MCPcopy Create free account
hub / github.com/Noumena-Network/code / _checkMetricsEnabledAPI

Function _checkMetricsEnabledAPI

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

Source from the content-addressed store, hash-verified

70}
71
72async function _checkMetricsEnabledAPI(): Promise<MetricsStatus> {
73 // Incident kill switch: skip the network call when nonessential traffic is disabled.
74 // Returning enabled:false sheds load at the consumer (bigqueryExporter skips
75 // export). Matches the non-subscriber early-return shape below.
76 if (isEssentialTrafficOnly()) {
77 return { enabled: false, hasError: false }
78 }
79
80 try {
81 const data = await withOAuth401Retry(_fetchMetricsEnabled, {
82 also403Revoked: true,
83 })
84
85 logForDebugging(
86 `Metrics opt-out API response: enabled=${data.metrics_logging_enabled}`,
87 )
88
89 return {
90 enabled: data.metrics_logging_enabled,
91 hasError: false,
92 }
93 } catch (error) {
94 logForDebugging(
95 `Failed to check metrics opt-out status: ${errorMessage(error)}`,
96 )
97 logError(error)
98 return { enabled: false, hasError: true }
99 }
100}
101
102// Create memoized version with custom error handling
103const memoizedCheckMetrics = memoizeWithTTLAsync(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected