848fde9f59
Adds anonymous usage statistics (commands/tools used, languages indexed, connecting agents) with a strict, auditable allowlist. Never code, paths, file/symbol names, queries, or IPs. - src/telemetry/: zero-dep client — consent resolution (DO_NOT_TRACK > CODEGRAPH_TELEMETRY > stored choice > default-on), random machine UUID, in-memory counters → capped JSONL buffer → completed-day rollups; sync exit-append (survives process.exit) + opportunistic bounded sends; the first-run notice gates the first SEND, never local buffering, so the installer's consent toggle always precedes it. Off is off: no recording, no socket, buffered data deleted. - codegraph telemetry status|on|off; per-command counting via preAction hook. - MCP: tool counting after the reply is on the wire (session + proxy in-process fallback), agent attribution from initialize clientInfo, unref'd daemon flush interval. Zero hot-path cost, zero stdout. - Installer: visible default-on consent toggle (asked once, never re-asked), install/index/uninstall lifecycle events. - telemetry-worker/: public Cloudflare Worker behind telemetry.getcodegraph.com — allowlist validation, IP stripping, per-machine rate limit, forwards to PostHog as anonymous events. Ships nowhere with the npm package. - TELEMETRY.md (field-by-field contract) + README section + design doc. - 20 unit tests; suite-wide CODEGRAPH_TELEMETRY=0 guard so tests never pollute real telemetry. Full suite: 1448 passing. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
globals: true,
|
|
environment: 'node',
|
|
include: ['__tests__/**/*.test.ts'],
|
|
/**
|
|
* Several MCP integration tests (mcp-daemon, mcp-initialize, mcp-ppid-watchdog,
|
|
* mcp-roots) spawn `dist/bin/codegraph.js serve --mcp` with `process.execPath`
|
|
* and rely on the child inheriting `process.env`. On a Node >= 25 dev machine
|
|
* the CLI's hard-block (src/bin/codegraph.ts) would otherwise exit the child
|
|
* before it ever responds, so every spawn-based test times out — see #478.
|
|
*
|
|
* Setting the override here keeps the CLI's runtime guard intact for end
|
|
* users (it's still enforced when `codegraph` is invoked directly) while
|
|
* letting the test suite run on whatever Node the contributor happens to
|
|
* have installed. CI on Node 22/23 is unaffected — the guard doesn't fire
|
|
* there, so the variable is a no-op.
|
|
*/
|
|
env: {
|
|
CODEGRAPH_ALLOW_UNSAFE_NODE: '1',
|
|
/**
|
|
* The suite spawns real CLI/MCP processes; without this they would write
|
|
* telemetry state into the contributor's real ~/.codegraph and count test
|
|
* tool calls as real usage. The telemetry unit tests are unaffected —
|
|
* they inject their own `env` via the Telemetry constructor.
|
|
*/
|
|
CODEGRAPH_TELEMETRY: '0',
|
|
},
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
},
|
|
},
|
|
});
|