You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Next.js websites cannot report page requests for server-side collection #34
Next.js websites should be able to report page requests for server-side collection with this package, instead of code written by a prompt (spec §11).
A new function trackRequest for proxy.ts (middleware.ts before Next.js 16), separate from trackPageview.
It does nothing until a setting is on. The setting is off by default. Its name is public and cannot change after release (spec §14.5).
It sends the payload of spec §3 and the address headers of spec §4. It runs before the response exists, so it sends no status or content type, skips assets by path and also reports 404s.
It never slows or breaks a page: it sends alongside the response, gives up after 2 seconds, never retries, swallows errors, and never sends cookies or authorization headers (spec §2).
Why
Next.js and Vercel run proxy code before the cache and for static files, so cached pages are counted there (spec §11.4). A package can be updated; prompt-written code cannot.
Notes
Agreed design: simpleanalytics/ide-config#22, sections 2, 3, 4, 11 and 14.5.
The package build lists an entry src/middleware/index.ts that does not exist.
Landed on feat/server-side-collection (2595701) in draft #35. This issue closes when that PR merges.
What the code does now: trackRequest in @simpleanalytics/next/server 1.2.0 reports GET page requests from proxy.ts/middleware.ts with the v1 payload. It is off unless SIMPLE_ANALYTICS_SERVER_SIDE_COLLECTION=1 or serverSideCollection is set. Test mode is SIMPLE_ANALYTICS_TEST_MODE=1.
Validation: one round, passed. The review covered cookies and authorization, hostile query strings, uppercase asset extensions, a hanging queue, a queue answering 500, and each value of the setting. It ran on Next 15 and 16.
Numbers: 13 payload tests. Page response about 25 ms with the queue slow or down.
Open decisions: (a) the setting is an environment variable plus a per-call option; the alternatives are a per-call option only or a plugin option. (b) the names SIMPLE_ANALYTICS_SERVER_SIDE_COLLECTION and SIMPLE_ANALYTICS_TEST_MODE are permanent after release. (c) App Router navigations and prefetches are reported as page requests. (d) the stale src/middleware/index.ts tsup entry is left, as it does not block the build.
Not run: anything against the real queue, which does not have /requests yet.
Later: no workflow runs pnpm test before publishing.
Activity
Merge ticket 7: report page requests from proxy.ts with trackRequest (#…
simpleanalytics-agent commentedon Nov 18, 2026
Landed on
feat/server-side-collection(2595701) in draft #35. This issue closes when that PR merges.What the code does now:
trackRequestin@simpleanalytics/next/server1.2.0 reports GET page requests fromproxy.ts/middleware.tswith the v1 payload. It is off unlessSIMPLE_ANALYTICS_SERVER_SIDE_COLLECTION=1orserverSideCollectionis set. Test mode isSIMPLE_ANALYTICS_TEST_MODE=1.SIMPLE_ANALYTICS_SERVER_SIDE_COLLECTIONandSIMPLE_ANALYTICS_TEST_MODEare permanent after release. (c) App Router navigations and prefetches are reported as page requests. (d) the stalesrc/middleware/index.tstsup entry is left, as it does not block the build./requestsyet.pnpm testbefore publishing.