Add public PageView tracking for portal analytics (#4)
## Summary Closes #3. - Add `PageView` model + migration for successful public marketing GET hits - Wire `PublicPageViewMiddleware` (skips portal/admin/accounts/api/static/health/etc.; fails soft on DB errors) - Portal analytics report: last-30-day views + top pages table - Admin registration and tests ## Test plan - [ ] Apply migration `analytics.0002_pageview` - [ ] Hit `/` and `/about/` → rows in `PageView` / admin - [ ] Hit `/healthz/`, `/portal/`, `/admin/` → no new pageviews - [ ] Open portal Analytics → views count + Top pages look right - [ ] `uv run python site/manage.py test analytics.tests` Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
+10
-1
@@ -1,6 +1,15 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from analytics.models import Attribution, UTMVisit
|
||||
from analytics.models import Attribution, PageView, UTMVisit
|
||||
|
||||
|
||||
@admin.register(PageView)
|
||||
class PageViewAdmin(admin.ModelAdmin):
|
||||
list_display = ("path", "created_at")
|
||||
list_filter = ("created_at",)
|
||||
search_fields = ("path",)
|
||||
date_hierarchy = "created_at"
|
||||
readonly_fields = ("id", "path", "created_at", "updated_at")
|
||||
|
||||
|
||||
@admin.register(UTMVisit)
|
||||
|
||||
Reference in New Issue
Block a user