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.53 kB
{"version":3,"file":"telemetry-disclosure.mjs","names":[],"sources":["../../../src/v1-deprecated/lib/telemetry-disclosure.ts"],"sourcesContent":["// Runtime-side telemetry disclosure log.\n//\n// The runtime has shipped telemetry for some time (see\n// `packages/shared/src/telemetry/telemetry-client.ts`). Sends are anonymous by\n// default but can carry a configured standalone or legacy identity. This file\n// surfaces a neutral one-line pointer to the opt-out docs on first\n// instantiation so the disclosure stays true for every identity mode. It pairs\n// with the inspector's first-run console disclosure.\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 telemetry notice on Runtime startup. No-op when telemetry is\n * disabled via `COPILOTKIT_TELEMETRY_DISABLED` or `DO_NOT_TRACK`, or when\n * 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] 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":";;AAeA,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,gDAAgD,mBAAmB,uDACpE"}