feat: add attributable page analytics

This commit is contained in:
john
2026-07-20 20:49:44 +08:00
parent 175095cbf3
commit a4522854d8
6 changed files with 123 additions and 18 deletions
+9 -7
View File
@@ -14,7 +14,7 @@ local Umami service at `http://127.0.0.1:3100`; it does not contact 103/105.
navigation from inflating generated-page views. Do not create a Website per
page or per user.
3. Put the Website ID and a local-only pseudonymization secret in Memind's
3. Put the Website ID and a local-only identity secret in Memind's
`.env`:
```dotenv
@@ -22,6 +22,7 @@ local Umami service at `http://127.0.0.1:3100`; it does not contact 103/105.
MEMIND_ANALYTICS_URL=http://127.0.0.1:3100
MEMIND_ANALYTICS_WEBSITE_ID=<website-id>
MEMIND_ANALYTICS_ID_SECRET=<random-local-secret>
MEMIND_ANALYTICS_IDENTITY_MODE=raw
MEMIND_ANALYTICS_DOMAINS=127.0.0.1,localhost
MEMIND_PRODUCT_ANALYTICS_ENABLED=true
MEMIND_PRODUCT_ANALYTICS_WEBSITE_ID=<product-website-id>
@@ -29,18 +30,19 @@ local Umami service at `http://127.0.0.1:3100`; it does not contact 103/105.
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.
visitor with the stable Memind user ID when `IDENTITY_MODE=raw` before
sending a standard Umami page view, so Users and Pageviews are populated.
The Identify properties include username, plan, channel, identity mode and
current public page URL. Generated-page events also retain `page_id` and the
precise `generated_at` timestamp. Omit the identity-mode setting outside an
explicitly approved first-party environment to keep the pseudonymous default.
5. The product shell loads its tracker from the same-origin
`/analytics/script.js` endpoint. It records one standard page view per SPA
route transition, `product_click` for links/buttons, and 10/30-second route
engagement events. Query strings are restricted to a small allowlist and
click labels never copy arbitrary chat or generated-page text. Authenticated
product events use the same pseudonymous identity as generated pages, while
product events use the same configured identity as generated pages, while
remaining in the separate product Website.
The integration is fail-open: missing configuration, disabled analytics, or a