Repository navigation
Add Exit pages panel to project stats - #61
Merged
Merged
Conversation
Adds a durable 30-day "Exit pages" breakdown next to "Top pages" on the project stats page. The exit page of a session is its most recent pageview; since we can't know at ingest time whether a pageview is the last one, /api/track keeps a per-session "current last page" record (tracker_exit_sessions) and moves the +1 exit marker forward as the session advances — decrement the previous page, increment the new one — so tracker_exit_daily_stats always holds exactly one exit page per session. Works for both multi-page and SPA sites since the tracker already sends sessionId on every pageview. - migration: tracker_exit_daily_stats (RLS like the other rollups) + tracker_exit_sessions (service-role-only bookkeeping) - lib/tracker/exit.ts: bumpExit / updateExitRollup / pruneExitSessions, with counts clamped at 0 against decrement/increment races - stats page + TrackerAnalytics: new "Exit pages" ranked-list panel - tests: marker-moving, repeat-page, multi-session, below-zero guard Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
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.
What
Adds an Exit pages breakdown next to Top pages on the project stats page, over the same durable 30-day window as the other panels.
The exit page of a session is its most recent pageview — the last page a visitor was on before leaving. Since we can't know at ingest time whether a given pageview is the last one,
/api/trackkeeps a small per-session "current last page" record and moves the+1exit marker forward as the session advances (decrement the previous page, increment the new one), sotracker_exit_daily_statsalways reflects exactly one exit page per session.Works for both multi-page and SPA sites — the tracker already sends
sessionIdon every pageview (includingpushState/popstateroute changes), so no/stats.jschange was needed.Changes
20260704120000_tracker_exit_rollups.sqltracker_exit_daily_stats— daily exit-page counts, RLS mirroring the othertracker_*_daily_statstables (owner + member select)tracker_exit_sessions— service-role-only session→last-page bookkeeping; pruned 24h past the client-side 30-min session TTL so a session id can't be resurrected and double-countedlib/tracker/exit.ts—bumpExit/updateExitRollup/pruneExitSessions; counts clamped at 0 so a decrement racing ahead of its increment can't go negative (extracted to a lib module so it's unit-testable, mirroringdevice.ts/geo.ts)/api/track— calls the rollup for pageviews carrying asessionId, best-effort so it never affects the 204TrackerAnalytics— new "Exit pages" ranked-list panel; grid re-paired to stay two-uptracker-exit.test.ts: marker-moving, repeat-page no-op, multi-session independence, below-zero guard (5 passing)Verification
tsc --noEmitcleantracker-exit,track-cors,stats-js,tracker-devicecontract tests passtracker-geofails in the worktree only because the GeoLite2.mmdbdata file isn't present in the worktree'snode_modules(lookupGeoreturns undefined); it passes on the main checkout and this PR touches no geo code🤖 Generated with Claude Code