Repository navigation
feat(analytics): log visitor requests with a hashed caller - #18
Merged
Merged
Conversation
Cloud Run's request log records Cloudflare's edge address, so visitor counts from logs had to rely on user-agent signatures and ranged from 150 to 1,000 on launch day. src/proxy.ts now writes one JSON line per page or API request carrying the caller digest the /mcp proxy already sends, and tags each line page, api, rsc or prefetch.
jm-rivera
marked this pull request as ready for review
October 20, 2026 15:20
Observe Node HTTP diagnostics from instrumentation so API and MCP request bodies reach their handlers intact. Deduplicate startup response logs and keep raw request data out of logging errors.
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.
Cloud Run's request logs identify Cloudflare's edge address. The website writes one JSON line per page or API request with a hashed visitor address, method, pathname, host, user agent, and a kind of
page,api,rsc, orprefetch. The caller digest uses the existingCALLER_HMAC_KEYandTRUSTED_PROXY_HOPSsettings shared with/mcp. Raw addresses, query strings, cookies, and credentials stay out of the log. Framework assets, images, and fonts are skipped.src/instrumentation.tsregisters Node HTTP diagnostic subscribers before request handling. They read the original headers and leave request bodies unread, preserving complete streaming payloads. A response-finish fallback catches requests accepted during startup, and a sharedWeakSetprevents duplicate entries across events and development reloads. Malformed requests emit a constant logging-error message.Testing: lint, typecheck, and the production build pass, along with all 1,510 tests outside
db/test. The regression tests cover an intact 11 MiB streamed body, receipt of the first chunk before upload completes, startup logging, duplicate registration, and query privacy on malformed URLs. The standalone production smoke test verifies full-body streaming, one startup entry, page/API/RSC/prefetch classification, and skipped assets. CI runs the database tests and production build.