Context
Issue #618 adds the visitor analytics schema. Before request collection is wired into middleware, AWCMS-Mini needs small, testable helpers for visitor identity, path sanitization, user-agent parsing, and human/bot classification.
These helpers must be privacy-first and safe for offline/LAN operation.
Objective
Add reusable domain helpers for visitor keys, IP/user-agent hashing, user-agent parsing, route/path sanitization, referrer extraction, and human/bot classification.
Scope
Add helper modules under:
src/modules/visitor-analytics/domain/
Suggested files:
visitor-key.ts
user-agent.ts
human-classifier.ts
path-sanitizer.ts
referrer.ts
Required capabilities:
- Generate or resolve an anonymous visitor key/cookie value.
- Hash anonymous visitor key.
- Hash IP address using a deployment salt.
- Hash user-agent where needed for deduplication.
- Parse browser name.
- Parse browser major version.
- Parse OS name.
- Detect device type:
desktop, mobile, tablet, bot, unknown.
- Detect common bot/crawler user-agents.
- Sanitize paths and query strings.
- Remove sensitive query parameters.
- Extract referrer domain safely.
- Identify static assets and internal framework paths that should not count as pageviews.
Sensitive query parameters to remove at minimum:
token
code
password
secret
email
phone
authorization
access_token
refresh_token
reset_token
mfaChallengeToken
Paths/patterns to skip at minimum:
/_astro/*
- favicon
- images
- CSS
- JavaScript
- font files
- health endpoints
- OpenAPI/AsyncAPI/static spec files
- internal build/runtime assets
Out of scope
- Middleware collector.
- Database writes.
- API endpoints.
- Dashboard UI.
- External bot intelligence providers.
- Device fingerprinting beyond ordinary visitor cookie/hash and user-agent parsing.
Acceptance criteria
Security and privacy notes
- Do not implement aggressive fingerprinting.
- Do not store or parse request bodies.
- Do not store raw query strings containing tokens or secrets.
- Human/bot classification is for analytics only and must not be used as an authorization control.
- Prefer deterministic, minimal classification over invasive tracking.
Dependencies
Depends on #617 and should be implemented before request collection in middleware. Works best after #618 schema is available.
Context
Issue #618 adds the visitor analytics schema. Before request collection is wired into middleware, AWCMS-Mini needs small, testable helpers for visitor identity, path sanitization, user-agent parsing, and human/bot classification.
These helpers must be privacy-first and safe for offline/LAN operation.
Objective
Add reusable domain helpers for visitor keys, IP/user-agent hashing, user-agent parsing, route/path sanitization, referrer extraction, and human/bot classification.
Scope
Add helper modules under:
Suggested files:
visitor-key.tsuser-agent.tshuman-classifier.tspath-sanitizer.tsreferrer.tsRequired capabilities:
desktop,mobile,tablet,bot,unknown.Sensitive query parameters to remove at minimum:
tokencodepasswordsecretemailphoneauthorizationaccess_tokenrefresh_tokenreset_tokenmfaChallengeTokenPaths/patterns to skip at minimum:
/_astro/*Out of scope
Acceptance criteria
bot.unknown, not blindly trusted.bun testpasses.bun run checkpasses.Security and privacy notes
Dependencies
Depends on #617 and should be implemented before request collection in middleware. Works best after #618 schema is available.