UNPKG

@copilotkit/runtime

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

1 lines 2.55 kB
{"version":3,"file":"telemetry-disclosure.cjs","names":[],"sources":["../../src/lib/telemetry-disclosure.ts"],"sourcesContent":["// Runtime-side anonymous telemetry disclosure log.\n//\n// The runtime has shipped anonymous telemetry for some time (see\n// `packages/shared/src/telemetry/telemetry-client.ts`). This file just\n// surfaces a one-line pointer to the opt-out docs on first\n// instantiation so operators don't have to dig through the docs site\n// to discover the existing behavior. Pairs with the inspector's\n// first-run console disclosure for a consistent operator-facing\n// surface.\n//\n// Fires at most once per process — runtime instances may be constructed\n// multiple times (tests, hot-reload), but the disclosure is informational\n// and a single line is enough.\n\n// Canonical telemetry docs page on main.\n// Mirror constant: packages/web-inspector/src/lib/telemetry.ts\nconst TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nfunction isTelemetryDisabled(): boolean {\n const env = process.env as Record<string, string | undefined>;\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n\nlet disclosureLogged = false;\n\n/**\n * Logs a one-line console.info about anonymous telemetry on runtime\n * startup. No-op when telemetry is disabled via `COPILOTKIT_TELEMETRY_DISABLED`\n * or `DO_NOT_TRACK`, or when already logged once in this process.\n *\n * Idempotent — safe to call from multiple constructor paths.\n */\nexport function logRuntimeTelemetryDisclosure(): void {\n if (disclosureLogged) return;\n if (isTelemetryDisabled()) return;\n disclosureLogged = true;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Runtime] anonymous telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`,\n );\n}\n\n// Test-only reset hook so the once-per-process guard doesn't leak between\n// test cases. Not part of the public package surface — used by the runtime\n// disclosure tests.\nexport function _resetRuntimeTelemetryDisclosureForTesting(): void {\n disclosureLogged = false;\n}\n"],"mappings":";;;AAgBA,MAAM,qBAAqB;AAE3B,SAAS,sBAA+B;CACtC,MAAM,MAAM,QAAQ;AACpB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB;;AAIzB,IAAI,mBAAmB;;;;;;;;AASvB,SAAgB,gCAAsC;AACpD,KAAI,iBAAkB;AACtB,KAAI,qBAAqB,CAAE;AAC3B,oBAAmB;AAEnB,SAAQ,KACN,0DAA0D,mBAAmB,uDAC9E"}