Repository navigation
feat(dispatch): record page-view fields on the usage row - #1066
Brooooooklyn wants to merge 3 commits into
Conversation
Dispatch now marks a request as a page view and adds blobs 7-15 (kind, path, host, referrer host, country, device, browser, bot label, bot group) and doubles 4-5 ([.., 0, 1]) to the one usage row it already writes. Rows that are not views keep the 6-blob, 3-double shape, so billing is unchanged. - page-view.ts: classifyPageView (GET only, no previews, no prefetch markers, 2xx except 204/206 or 304, HTML document loads and Void Pages client navigations incl. /_void/pages/*.json, monitors dropped). - analytics-setting.ts: per-project off switch read from the project-analytics-off:<id> ROUTING key, cached 60s per isolate; a read error counts as off. - metering.ts: optional view; path capped at 512 bytes; path and referrer blank in minimal runtime-logs mode. - index.ts: still exactly one row per request; written from waitUntil only when the setting read is still pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tic deploys - A Void Pages client navigation that hits a redirect gets a 200 with X-VoidPages-Redirect and Location; the client then fetches the target. Do not count that 200 as a view of the source page. - output: "static" apps with no backend deploy as routing type static. Count their /_void/pages/*.json page-data fetches as nav views too. The X-VoidPages rule stays void-only: a static deploy answers it with HTML and the client follows with the page-data file. - Skip classifyPageView when the project is known to have analytics off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… page data An X-VoidPages request answered with HTML or the stale-build reload answer is followed by a page-data file fetch or a full page load, which is the counted view. Counting both counted one visit twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Cloudflare builds and deploys previews for this pull request. Learn more about Cloudflare previews.
Updated: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9c78a1f5a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (pageDataPath !== null) { | ||
| kind = 'nav'; | ||
| path = pageDataPath; |
There was a problem hiding this comment.
Mark static page-data prefetches before counting them as views
For output: "static" apps with the static-data fast path enabled, fetchPrefetchPageData() calls loadStaticPageDataFile() directly (packages/void/src/pages/navigation-engine.ts:722-724), whose fetch sends only Accept: application/json (lines 649-651), not the Purpose: prefetch header. Consequently, the prefetch filter does not recognize these requests, and this branch records hovering over or observing a prefetched link as a page view even if the visitor never opens it. Propagate a prefetch marker through the static-data loader and cover the actual client-generated request headers in a regression test.
Useful? React with 👍 / 👎.
| // Only a page-data answer carries `X-VoidPages`. Without it (HTML, or the | ||
| // stale-build reload answer) the client follows up with a page-data file | ||
| // fetch or a full page load, and that request is the counted view. | ||
| kind = 'nav'; | ||
| } else if (!request.headers.has('X-VoidPages') && isDocumentRequest(request, response)) { |
There was a problem hiding this comment.
Account for static navigations that consume inline HTML page data
When an output: "static" app has routing rules, resolveStaticPageDataBuildOptions() disables the static-data fast path. Its client navigation can then receive HTML and successfully consume the embedded page data: loadNavigationShell() calls loadStaticPageData() with verification enabled (packages/void/src/pages/navigation-engine.ts:971-977), and that helper returns immediately without fetching a JSON file when there are no deferred props (lines 688-695). Thus the assumed follow-up request never occurs, while this classifier rejects the HTML response because the request carries X-VoidPages; successful client navigations in this supported flow produce no page-view row. Account for this flow rather than assuming every HTML answer results in a second request.
Useful? React with 👍 / 👎.
|
Combined into #1067 (visit analytics, one PR). All commits from this PR are on that branch. |
Step 3 of visit analytics. Stacked on #1064 (the user-agent parser), so review and merge that first.
Dispatch now adds page-view fields to the
void_requestsrow it already writes. There is still exactly one row per request, so billing and usage queries don't change.Row layout (new slots only)
document/nav''in minimal mode)/blog/helloshop.example.com''in minimal mode)news.ycombinator.comrequest.cf.country)DEmobile,SafariGPTBot,ai01What counts as a view
X-VoidPagesresponse)Purpose,Sec-Purpose,X-Moz,X-Purpose)/_void/pages/*.jsononvoidorstaticapps, mapped back to its pageX-VoidPages-Redirect)The view uses the visitor's URL before any rewrite, so rewrites and SPA fallbacks are counted under the page the visitor opened.
Off switch
Dispatch reads the ROUTING key
project-analytics-off:<projectId>(projectAnalyticsOffKey), caches it for 60s per isolate, and treats a read error as off. Nothing writes the key yet; the API route comes in the next PR, so analytics is on for everyone by default.Tests
page-view.test.tscovers methods, statuses, Sec-Fetch, prefetch markers, X-VoidPages answers, page-data path mapping, redirects, static deploys and referrers.metering.test.ts: the old row shape is unchanged; checks the view row shape, minimal-mode blanking and the cut of a long CJK path.index.test.ts: ISR JSON hit, redirect rule, rewrite, SPA fallback, workers.dev alias, off marker, a KV or classifier error still writes one base row, private preview, and "meters exactly once".Results:
vp test run platform/packages/dispatch: 913 passedvp check: cleanvp run test: 200/200 tasks🤖 Generated with Claude Code