Skip to content

Add visitor analytics panel to /admin - #25

Closed
JonasFocus wants to merge 2 commits into
mainfrom
claude/admin-activity-analytics-ijzqya
Closed

JonasFocus wants to merge 2 commits into
mainfrom
claude/admin-activity-analytics-ijzqya

Conversation

@JonasFocus

Copy link
Copy Markdown
Owner

Requested by Jonas · project thread

Before: /admin had no way to see what visitors do on jonasinfocus.com.

After: a new Analytics tab in /admin shows visits, visitors, page views, average and median time on site, pages per visit, bounce rate, a visits-per-day chart, top pages, sources, clicks and form submits, countries, devices, browsers, a live log of recent events, and a list of visits that opens a per-visit timeline. A range filter switches between 24 hours, 7, 30 and 90 days.

Time on site counts only while the tab is open and visible (engaged time), so a tab left in the background does not inflate the average.

How: a small client tracker in the root layout (skipped on /admin) sends batched beacons to /api/track on each page view, click, scroll milestone, form submit and every 15 seconds while visible. The route drops bots, checks the origin, and calls a track_visit function (service role only) that writes visitor_sessions and visitor_events. Both tables are owner-read only under RLS; visitor_stats builds the dashboard summary in SQL. Privacy: no cookies, no raw IPs (visitors are a daily-rotating HMAC of IP and user agent), no form contents, GPC/Do Not Track respected, the owner's own browser is skipped after opening /admin, and data older than 180 days is pruned. The privacy page now describes this. Abuse limits: 30 events per beacon, 1000 events per session, sessions end after 12 hours, 30 new sessions per visitor per hour.

Also includes a lockfile-only npm audit fix for two new high advisories (sharp GHSA-wq5f-xc86-pv6w, source-map-js GHSA-68fv-2mgg-jv7q) that currently fail the audit step on main too.

Deploy note: apply supabase/migrations/20261007180000_visitor_analytics.sql to production before merging, or the tracker beacons are silently dropped and the Analytics tab errors. Access uses the existing owner sign-in.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HLGs668b9KBEBwBxa7zFNh


Generated by Claude Code

claude added 2 commits October 7, 2026 18:11
npm audit --omit=dev --audit-level=high fails on main for
GHSA-wq5f-xc86-pv6w (sharp) and GHSA-68fv-2mgg-jv7q (source-map-js).
Lockfile-only change from npm audit fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLGs668b9KBEBwBxa7zFNh
Adds a cookieless first-party tracker (page views, clicks, scroll depth,
form submits, engaged time), a /api/track beacon route, an owner-only
Analytics tab in /admin with daily visits, average and median time on
site, top pages, sources, clicks, devices, a live event log and a
per-visit timeline. No raw IPs are stored; visitors are counted with a
daily rotating HMAC key. Data is kept for 180 days.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLGs668b9KBEBwBxa7zFNh
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
jonas-dev Ready Ready Preview Oct 7, 2026 6:12pm UTC

This branch was successfully deployed

1 active deployment
Preview — 363f7c40 Deployed Oct 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants