Skip to content

feat: telemetry with privacy, consent & reliability fixes#16

Open
dheerajreddy-ui wants to merge 7 commits intosinewaveai:mainfrom
dheerajreddy-ui:feature/telemetry
Open

feat: telemetry with privacy, consent & reliability fixes#16
dheerajreddy-ui wants to merge 7 commits intosinewaveai:mainfrom
dheerajreddy-ui:feature/telemetry

Conversation

@dheerajreddy-ui
Copy link
Contributor

@dheerajreddy-ui dheerajreddy-ui commented Feb 19, 2026

Summary

  • Privacy: Replace deterministic SHA-256 machine ID with crypto.randomUUID(). Legacy 64-char hex IDs are auto-migrated with _legacy_id_migrated flag.
  • Consent: track() calls showFirstRunNotice() before queuing any event — no telemetry fires before the user sees the notice.
  • Reliability: New flushAsync() awaits batch send with timeout aligned to FETCH_TIMEOUT_MS + 500ms. All CLI process.exit() calls replaced with cliExit() that flushes first.
  • Endpoint: Configurable via SCANNER_TELEMETRY_ENDPOINT env var; shown in --status output.
  • Wording: All user-facing text aligned from "anonymous" to "pseudonymous" / neutral.
  • Docs: TELEMETRY.md rewritten — UUID machine ID, migration notes, endpoint section.
  • Tests: 84 tests pass (10 new/updated covering UUID format, legacy migration, flushAsync timeout, notice-before-track, endpoint override).

Test plan

  • npx vitest run tests/telemetry.test.js — 84/84 pass
  • Manual: node index.js scan-security tests/fixtures/vulnerable.py — notice appears on first run, events flush before exit
  • Manual: DO_NOT_TRACK=1 node index.js scan-security tests/fixtures/vulnerable.py — no notice, no telemetry
  • Manual: node index.js telemetry --status — shows UUID machine ID, endpoint URL
  • Manual: Write legacy 64-char hex machine_id to state file, run any command, verify UUID migration
  • Manual: SCANNER_TELEMETRY_ENDPOINT=https://example.com/events node index.js telemetry --status — shows custom endpoint

🤖 Generated with Claude Code

dheerajreddy-ui and others added 5 commits February 19, 2026 09:42
…rdown, add benchmark script

- CI: Parameterize Python version in matrix (3.10, 3.11, 3.12)
- Doctor: Live daemon health check with start/verify/shutdown
- Tests: Race timeout on garak afterAll teardown to prevent hangs
- Scripts: benchmark-daemon.js for cold/warm/sync throughput comparison

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactored _resetForTesting() to accept a test directory parameter so
tests use os.tmpdir() instead of the real ~/.agent-security-scanner-mcp/.
Added tests verifying state dir isolation and no real directory access.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ing, beforeExit hook

Tasks 3-10 from telemetry stress test plan:
- 48 new tests (75 total): opt-out, machine ID, batching, network, integration, privacy
- Fix TELEMETRY.md: IP claim, retention, machine ID reset, engine_available values, CI docs
- Cache isEnabled() per-session to avoid disk reads
- Add process.on('beforeExit', flush) for CLI telemetry
- Await trackInstall() in postinstall.js with 200ms grace period

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wrap all tool handlers with withTelemetry() for automatic tool.invoked/error events
- Add domain-specific track() calls: scan.completed, prompt.scanned, package.checked
- Add CLI `telemetry --on|--off|--status` command routing
- Show first-run notice on MCP server startup, flush on close/signal
- Add telemetry status to `doctor` output
- Track daemon usage in runAnalyzerAsync via lastAnalyzerUsedDaemon()
- Add GCP Cloud Function backend (BigQuery ingestion, field allowlisting)
- Add BigQuery schema (90-day partitioned, clustered by event+machine_id)
- Add aggregate views: daily tool usage, daily scan stats, weekly installs, MAU

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Machine ID: replace deterministic SHA-256 with random UUID, auto-migrate legacy IDs
- Consent: call showFirstRunNotice() in track() before any event is queued
- Reliability: add flushAsync() with timeout aligned to FETCH_TIMEOUT_MS, replace
  process.exit() with cliExit() in all CLI tool branches
- Endpoint: configurable via SCANNER_TELEMETRY_ENDPOINT env var, shown in --status
- Wording: align all user-facing text from "anonymous" to "pseudonymous"
- Docs: rewrite TELEMETRY.md machine ID section, add endpoint section
- Tests: 10 new/updated tests covering UUID format, legacy migration, flushAsync,
  notice-before-track, and endpoint override

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dheerajreddy-ui dheerajreddy-ui changed the title feat: anonymous usage telemetry with opt-out, 75 tests, GCP backend feat: telemetry with privacy, consent & reliability fixes Feb 19, 2026
- Rewrite deploy.sh for gen2 Cloud Functions with dedicated SA,
  API enabling, and --source path resolution
- Add engines.node >= 20 to cloud-function package.json
- Update telemetry endpoint from prooflayer.com to proof-layer.com
- Update TELEMETRY.md endpoint and operator references

Deployed infrastructure:
- Cloud Function gen2 (us-central1) with scanner-telemetry-ingest SA
- BigQuery dataset scanner_telemetry with events table + 4 views
- Custom domain telemetry.proof-layer.com (cert provisioning)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant