fix(tools): restore usage stats for runAction, streamAction, etc#5698
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors analytics event tracking by moving route-level analytics from the tRPC router to a new Express middleware (loggedExpressRoute). This middleware measures request duration, determines success or failure, extracts action details for specific routes, and records the event. It is applied to several API endpoints, and corresponding unit tests have been added. Feedback on the changes includes importing analytics utilities directly from their specific module to avoid import resolution issues, explicitly removing event listeners in the middleware to prevent dangling listeners, and enforcing a minimum duration of 1ms for Google Analytics compatibility along with safer optional chaining on res.locals.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
ecef49d to
7990ed0
Compare
730960c to
d4d9a31
Compare
Currently we track analytics for tRPC. However, when we moved runAction to the express server for real time tracing, we lost our metrics. streamAction possibly never had metrics. Add a new middleware that does the same metrics collection for any dev-ui routes directly defined in the express server
d4d9a31 to
022c363
Compare
Currently we track analytics for tRPC. However, when we moved
runActionto the express server for real time tracing, we lost our metrics.streamActionpossibly never had metrics.Add a new middleware that does the same metrics collection for any dev-ui routes directly defined in the express server