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:
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 6.1 on 2026-08-13 12:38
|
||||
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PageView',
|
||||
fields=[
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('path', models.CharField(db_index=True, max_length=512)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
'indexes': [models.Index(fields=['created_at', 'path'], name='analytics_p_created_9e8b64_idx')],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user