Repository navigation
feat(server): count which product features people use - #15921
juliusmarminge wants to merge 1 commit into
Conversation
Records an anonymous feature.used event for allowlisted feature RPCs and user commands (checkpoint restore, fork, provider switch, terminal, preview, worktrees, git actions, PR actions, scheduled tasks, ...), with a closed-enum variant and the client surface. Recorded from the RPC authorization middleware so no handler changes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds production feature-usage telemetry to authorized WebSocket requests and modifies shared authentication middleware. Because files under the auth directory are changed, the mandatory sensitive-package review rule requires human review. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (2)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe server classifies selected WebSocket RPC requests as feature usage. After an authorized request succeeds, the server records classified usage with the connecting client’s surface when available. Tests cover classification and callback behavior. ChangesFeature Usage Analytics
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant WebSocketRpcRoute
participant rpcScopeAuthorizationLayer
participant featureUsage
participant FeatureUsedRecorder
WebSocketRpcRoute->>rpcScopeAuthorizationLayer: Pass RPC method and payload
rpcScopeAuthorizationLayer->>rpcScopeAuthorizationLayer: Authorize and run request
rpcScopeAuthorizationLayer->>featureUsage: Classify successful request
featureUsage-->>rpcScopeAuthorizationLayer: Return feature data or undefined
rpcScopeAuthorizationLayer->>FeatureUsedRecorder: Record feature.used when classified
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue is established for this change. Stream completion timing remains unverified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the problem, implementation, telemetry exclusions, and tests. However, it does not provide the required scope and approval information for this feature change. Mentioning companion PR Resolution Add a Scope and approval section with a link to the triaged issue or discussion and the maintainer’s explicit approval of this direction and scope. If this change qualifies for an exemption, explain why it is a very small, focused fix of an obvious bug; otherwise, provide the required approval evidence.
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Today analytics only counts connections, threads and turns. We can't tell which product features are used, such as checkpoint restore, fork, provider switch, the terminal, the preview browser, worktrees, git and PR actions, or scheduled tasks.
This adds one anonymous PostHog event,
feature.used{ feature, variant?, surface? }. It's recorded from the RPC authorization middleware, which every WebSocket request already passes through, after the request succeeds (for a stream RPC, when the stream completes). No handler changes.rpcScopeAuthorizationLayergains an optionalonAuthorizedcallback, andws.tspasses one that maps the request throughFeatureUsage.ts.FeatureUsage.tsis an allowlist:dispatchCommand:checkpoint.rollback(with_files/conversation_only),thread.fork,thread.merge_back,provider.switch, archive, snooze, pin, settle, PR link and watch, runtime and interaction mode changes (mode as variant), interrupt, queue steer and edit.message.dispatchis left out becauseclient.turn.requestedalready counts it. Housekeeping commands such as visits and reorders are left out too.thread.launch(workspace strategy as variant), terminal, preview and device open,editor.open(editor id), worktree create,git.stacked_action(action),pull_request.action(action), PR review and comment, scheduled task save and run-now, agent session import, project clone, repository publish, keybinding customize.Anonymity: variants come only from closed contract enums. No paths, ids, titles, prompts or free text, and the only client dimension is
surface. Hot paths such asterminal.writedon't map to a feature and return right away.T3CODE_TELEMETRY_ENABLED=falsestill disables everything.Tests:
FeatureUsage.test.tschecks the mapping, including that paths, prompts and ids never appear.RpcAuthorization.test.tschecks that only authorized, successful requests are reported. The existingwstests pass.Companion to #15913, which covers the agent side (MCP tools and delegation). The two branches are independent.
Done by Claude Opus 5.5 in Claude Code (via T3 Code).
🤖 Generated with Claude Code