feat(telemetry): add analytics collection and runtime signals#95
Draft
Gucc111 wants to merge 9 commits into
Draft
feat(telemetry): add analytics collection and runtime signals#95Gucc111 wants to merge 9 commits into
Gucc111 wants to merge 9 commits into
Conversation
…signals Refine telemetry semantics for multi-instance environments by adding deploymentMode and instanceId while removing projectCommitHash. Expand feature_used into module and loop-stage dimensions, including session loop instrumentation and receiver contract documentation for idempotent ingestion. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove projectPath from outbound events, hash sessionId, and limit error_occurred to classification fields only. Co-authored-by: Cursor <cursoragent@cursor.com>
Only feature_used and error_occurred are emitted; DAU uses any valid event. Co-authored-by: Cursor <cursoragent@cursor.com>
Report normalized provider API base URL after routing on session request_started and router success/error paths. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
Adds a new telemetry/analytics subsystem (analytics.v2) and wires it through gateway, router, always-on, cron, model runtime, and memory flows to emit privacy-conscious runtime signals and diagnostics.
Changes:
- Introduces a telemetry collector/sender with batching, retries, and on-disk queue persistence (
src/telemetry/*). - Emits loop-stage and error signals across session gateway, router (judge/fallback), always-on phases, cron phases, and memory workflows.
- Adds provider base URL normalization + new tests and receiver contract documentation.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 36 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/telemetry/context.test.ts | Tests runtime context fields (deploymentMode/instanceId/etc.). |
| tests/telemetry/collector.test.ts | Tests sending, retries, privacy sanitization, and allowlisted error metadata. |
| tests/router/RouterRuntime.telemetry.test.ts | Tests router telemetry behavior (judge participation, fallback preservation). |
| tests/model/normalizeProviderBaseUrl.test.ts | Tests normalization rules for provider base URLs. |
| src/telemetry/types.ts | Defines analytics schema + telemetry types/enums and client interface. |
| src/telemetry/sender.ts | Implements batching sender, retries, and queue persistence/restore. |
| src/telemetry/index.ts | Exports telemetry public API. |
| src/telemetry/context.ts | Resolves runtime context (installation/instance ids, deployment mode, commit/version). |
| src/telemetry/collector.ts | Implements telemetry client, sanitization, config/env parsing, and event building. |
| src/router/tokenSaver/classifyAndRoute.ts | Adds telemetry emission for judge lifecycle and failures. |
| src/router/RouterRuntime.ts | Threads telemetry through router runtime and emits fallback/retry signals. |
| src/model/streaming/streamModel.ts | Emits providerBaseUrl on request_started model events (normalized). |
| src/model/protocol/canonical.ts | Extends CanonicalModelEvent.request_started to include providerBaseUrl?. |
| src/model/normalizeProviderBaseUrl.ts | Adds base URL sanitizer/normalizer helper. |
| src/model/ModelRuntime.ts | Adds getProviderBaseUrl() to ModelRuntime and implements it. |
| src/model/index.ts | Re-exports normalizeProviderBaseUrl. |
| src/gateway/protocol/types.ts | Extends submitTurn input with optional telemetry attribution context. |
| src/gateway/client/InProcessGateway.ts | Emits session loop telemetry based on agent events and submit context. |
| src/cron/runtime/CronRuntime.ts | Adds cron telemetry signals for phases and failures. |
| src/context/memory/EdgeClawMemoryProvider.ts | Adds telemetry around memory retrieve/capture (loop start/end + errors). |
| src/context/memory/edgeclaw-memory-core/src/core/skills/llm-extraction.ts | Adds telemetry for memory LLM calls (request/response/errors). |
| src/context/memory/edgeclaw-memory-core/lib/core/skills/llm-extraction.js | Same as above for compiled JS output. |
| src/context/memory/createEdgeClawMemoryProviderFromConfig.ts | Wires telemetry into EdgeClaw runtime/provider creation. |
| src/cli/pilotdeck.ts | Creates telemetry collector, passes it through subsystems, adds shutdown/error hooks. |
| src/cli/createLocalGateway.ts | Creates/owns telemetry collector by default and passes it into project runtime registry + gateway. |
| src/always-on/runtime/DiscoveryFire.ts | Emits always-on telemetry events and propagates attribution to gateway turns. |
| src/always-on/runtime/createApplyHandler.ts | Threads telemetry into DiscoveryFire from apply handler. |
| src/always-on/runtime/AlwaysOnRuntime.ts | Threads telemetry into DiscoveryFire via runtime options. |
| src/always-on/runtime/AlwaysOnManager.ts | Threads telemetry into always-on runtime creation. |
| src/always-on/protocol/types.ts | Adds additional always-on phases (workspace/report/apply started/completed). |
| docs/telemetry/receiver-contract.md | Documents analytics.v2 receiver contract, schema, and privacy rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Impact
This adds privacy-conscious analytics signals for deployment visibility and runtime diagnostics while preserving existing application behavior.
Validation
npm test