Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(tools): restore usage stats for runAction, streamAction, etc#5698

Merged
MichaelDoyle merged 1 commit into
mainfrom
md/restore-metrics
Jul 7, 2026
Merged

fix(tools): restore usage stats for runAction, streamAction, etc#5698
MichaelDoyle merged 1 commit into
mainfrom
md/restore-metrics

Conversation

@MichaelDoyle

Copy link
Copy Markdown
Contributor

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread genkit-tools/common/src/server/server.ts Outdated
Comment thread genkit-tools/common/src/server/server.ts
Comment thread genkit-tools/common/src/server/server.ts Outdated
@MichaelDoyle MichaelDoyle force-pushed the md/restore-metrics branch 2 times, most recently from ecef49d to 7990ed0 Compare July 7, 2026 02:06
Comment thread genkit-tools/common/src/server/server.ts
Comment thread genkit-tools/common/tests/server_test.ts
@MichaelDoyle MichaelDoyle force-pushed the md/restore-metrics branch 4 times, most recently from 730960c to d4d9a31 Compare July 7, 2026 13:33
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
@MichaelDoyle MichaelDoyle merged commit 49b4ee6 into main Jul 7, 2026
26 checks passed
@MichaelDoyle MichaelDoyle deleted the md/restore-metrics branch July 7, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants