Files
memind/docs/local-analytics.md
T
john ed9e23fc07
Memind CI / Test, build, and release guards (pull_request) Successful in 3m11s
fix(analytics): identify Memind users before pageviews
2026-07-17 14:10:36 +08:00

38 lines
1.6 KiB
Markdown

# Local Memind + Umami analytics
The integration is local-only by default. Memind proxies `/analytics/*` to the
local Umami service at `http://127.0.0.1:3100`; it does not contact 103/105.
1. Start `/Users/john/Project/memind-analytics` and verify:
```bash
curl --fail http://127.0.0.1:3100/api/heartbeat
```
2. Create one Umami Website for the local generated-page host. Do not create a
Website per page or per user.
3. Put the Website ID and a local-only pseudonymization secret in Memind's
`.env`:
```dotenv
MEMIND_ANALYTICS_ENABLED=true
MEMIND_ANALYTICS_URL=http://127.0.0.1:3100
MEMIND_ANALYTICS_WEBSITE_ID=<website-id>
MEMIND_ANALYTICS_ID_SECRET=<random-local-secret>
MEMIND_ANALYTICS_DOMAINS=127.0.0.1,localhost
```
4. Restart the local Memind server. Full generated HTML pages will receive a
same-origin `/analytics/script.js` tracker. The tracker identifies the
visitor with a stable pseudonymous owner ID before sending a standard Umami
page view, so Users and Pageviews are populated. The Identify properties
include the readable Memind username and current public page URL for
operational analytics. Click, form, scroll, and engagement events retain the
pseudonymous `owner_id`, `page_id`, and `channel` dimensions.
The integration is fail-open: missing configuration, disabled analytics, or a
down Umami service leaves page generation and page delivery unchanged. User
facing analytics must be queried through a future Memind API that filters by
the authenticated owner; do not expose the Umami dashboard directly to users.