spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / telemetry / hooks / is-analytics-off / is-analytics-off.ts
32 lines · 1.2 KBRaw
1import type { Environment } from '../environment'
2import { isEnvSet } from './is-env-set'
3import { isEnvTruthy } from './is-env-truthy'
4
5/**
6 * Whether the CLI's own analytics would be off here, read off the
7 * environment alone: then the plugin sends nothing either.
8 *
9 * Off when DISABLE_TELEMETRY or the nonessential-traffic switch is set at
10 * all or DO_NOT_TRACK is on, on any third-party provider (no first-party
11 * credential rides there), and on a deployment with its own OAuth URL.
12 *
13 * @param environment the variables as read once for the session
14 * @returns true when no row may be sent
15 */
16export function isAnalyticsOff(environment: Environment) {
17 const isPrivate =
18 isEnvSet(environment.disableTelemetry) ||
19 isEnvSet(environment.disableNonessentialTraffic) ||
20 isEnvTruthy(environment.doNotTrack)
21 const isThirdParty = [
22 environment.useBedrock,
23 environment.useVertex,
24 environment.useFoundry,
25 environment.useAnthropicAws,
26 environment.useAnthropicGoogleCloud,
27 environment.useMantle,
28 ].some(isEnvTruthy)
29 const isCustomDeployment = isEnvSet(environment.customOauthUrl?.trim())
30
31 return isPrivate || isThirdParty || isCustomDeployment
32}