Files
memind/.cursor/rules/mindspace-analytics-creator-username.mdc
T
john b300cb5e04
Memind CI / Test, build, and release guards (pull_request) Successful in 5m34s
fix(analytics): include username on page_generated events
Umami creator labels read event_data.username; server events only sent
owner_label, so dashboards fell back to MindSpace UUID path segments.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 15:25:09 +08:00

27 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: MindSpace 生成页埋点必须上报创建者 username,且不得用 owner_id identify 匿名访客
globs: mindspace-analytics.mjs,mindspace-rybbit.mjs,mindspace-analytics.test.mjs,mindspace-rybbit.test.mjs,server/portal-session-routes.mjs,server/portal-integration-services-bootstrap.mjs
alwaysApply: false
---
# MindSpace Analytics — 创建用户昵称与 Public 身份
Umami「创建用户」依赖 `event_data.username` / session `username`。路径里的 MindSpace UUID **不是**昵称。
## 必须
- 服务端 `page_generated``sendMindSpaceAnalyticsEvent` / `sendMindSpaceRybbitEvent`)的事件属性 **必须**包含 `username`(创建者展示名,来自 `resolveAnalyticsOwnerLabel`
- 可同时保留 `owner_label` 作兼容,值与 `username` 相同
- Public HTML 内嵌脚本的 `metadata` **必须**继续带 `username`(给 scroll/click 等客户端事件)
## 禁止(避免破坏访客统计)
- Public **匿名**访问路径 **禁止** `umami.identify(owner_id, …)` / 把创建者 ID 当作访客 `id`
- 仅已登录 viewer 可 `identifyViewer()`;不得为了补创建用户昵称而恢复「全员 identify 创建者」
## 改完必跑
```bash
node --test mindspace-analytics.test.mjs mindspace-rybbit.test.mjs
```