Repository navigation
feat(web): add passive semantic analytics attributes across frontend workflows - #1010
Conversation
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Move the collector example test alongside existing root-level web tests so the web-only Docker context does not require repository documentation. Preserve all assertions and default Vitest discovery; document the boundary. Verified 1217 tests, focused 12 tests, typecheck, lint, build and a fresh web-only build without repository docs. Original snapshot reproduced TS2307. Independent review passed. Full local image build was blocked by an uncached pnpm download with network disabled; remote image CI remains authoritative. Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
|
Fixed the web-image build failure in 66c1dcf. The new docs-example test was inside the production TypeScript inputs, but the existing image builds from Verified locally: 1,217 tests; focused 12 cases; typecheck, lint and build. A fresh web-only snapshot reproduced the original TS2307, then passed after the move with repository docs absent. Independent review found no blocking issue. The full local Docker build attempt stopped at an uncached package-manager download with network disabled, so it is not counted as a passing image build. The new head's GitHub CI is now rerunning. 中文:容器构建失败已定位并修正,只调整文档示例测试的位置及相对路径,保留全部断言;新提交的远端 CI 结果以 Checks 为准。 |
|
我们认可当前的整体方案:SkillHub 提供稳定的页面动作标签,部署方按需加载采集脚本、自选统计平台,默认不采集、不外发、不绑定厂商 SDK。 参考成熟方案并核对当前实现后,建议进一步完善以下几点,主要集中在采集示例、配置、文档和测试,无需重做整体架构。 1. 支持通过配置启用新的普通动作当前示例把 12 个动作及其识别规则写在脚本中。希望允许部署方配置“动作名称对应哪种已有规则”,例如: 目标是:新增普通按钮或表单时,添加页面标签并更新配置即可,不需要重复编写监听逻辑。 需要允许新动作复用已有规则,不只是从原有 12 个动作中选择开启哪些。规则类型保持明确、有限;特殊选择器、拖拽等交互可以后续单独扩展,本期不要求覆盖全部标签。 2. 明确字段含义和兼容规则请简要说明:
继续保持字段白名单,不自动抓取输入内容、Token、完整 URL 等信息,无需引入复杂的协议框架。 3. 补齐一个能跑通的接入示例目前文档允许入口脚本导入 helper,但 Nginx 示例只开放入口文件,同目录其他模块会返回 404。请明确采用打包方式,或补充 helper 的精确静态路由。 建议选择一个成熟统计平台,跑通: 用户操作 → 采集回调 → 平台适配 → 接收端收到预期事件。 同时检查最终发送的数据。部分 SDK 会自动附加 URL、标题、来源等字段,不能只检查回调参数。 4. 补充必要测试并同步文档测试重点覆盖配置生效、未知规则、重复初始化、表单和键盘重复计数,以及关闭采集和发送失败的情况,确保不影响正常操作。 请同步更新现有接入文档,说明如何配置规则、新增标签、接入统计平台及关闭采集,提供一个可复现的完整示例即可,无需另建一套文档体系。 继续明确:点击下载不代表下载或安装成功,提交发布不代表发布成功。 整体希望达到:普通新增动作加标签、改配置即可;特殊交互扩展规则;更换统计平台主要修改适配器。 本期无需增加后台配置页、统计数据库、持久化队列或多厂商 SDK 集成。 以上是我们的初步建议,不代表实现方式必须如此。如果你认为有更简单、成熟或更适合当前架构的方案,欢迎按你的判断提出替代设计,说明取舍后我们一起确认。重点是保持厂商中立、默认不采集、易于接入和扩展。 |
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
|
Thanks for the review. All four points are addressed in four append-only commits on top of the previously green head: 1. Config-driven rules
There are three finite rule types:
Special interactions such as select, file, drop and crop are left for a future rule type, and the docs say not to map them to 2. Field meaning and compatibility The doc now covers:
3. Runnable integration (Umami v3.4.1, MIT, self-hosted)
The helper 404 is fixed. One versioned prefix, The edge proxies exactly two Umami endpoints, the tracker script and Swapping platforms means replacing only the adapter and these two edge routes. To check the final data, the sanitizer works on the payload Umami is about to send, not on our callback. Only The doc also discloses what still leaves the browser or is derived on the server: IP, User-Agent and Origin; Umami's Consent withdrawal: End-to-end check, run locally and outside CI. The setup was this branch's built frontend behind the example edge, real Chrome, Umami 3.4.1 and Postgres; only the SkillHub API responses were synthetic. 18/18 checks passed:
One upstream detail: Umami 3.4.1 stores an omitted query as an empty string rather than NULL. Nothing is transmitted for it. We documented it instead of patching Umami. 4. Tests
They use no real network. Verified locally on the final head: 1,282 web tests, typecheck, lint, build, manifest freshness and Trade-offs, open to adjustment:
The integration doc is still the single existing 中文感谢评审。四点都已处理,在原先 CI 全绿的 head 上追加了四个提交 1. 配置规则
规则类型只有三种:
下拉、文件、拖拽、裁剪等特殊交互留待以后单独扩展规则,文档注明不要配成 2. 字段含义与兼容 文档现在写明:
3. 可跑通的接入示例(Umami 3.4.1,MIT,可自托管)
helper 的 404 已修复:用一个带版本号的前缀 入口只代理 Umami 的两个接口(采集脚本和 更换统计平台只需替换适配器和这两条入口路由。 为了核验最终发出的数据,过滤器检查的是 Umami 即将发送的最终 payload,不是我们的回调参数。只放行 文档也如实列出仍会离开浏览器、或在服务端推导出的信息:IP、User-Agent、Origin;Umami 的 撤回同意: 端到端验证在本地进行,不在 CI 中:使用本分支构建出的前端、示例入口、真实 Chrome、Umami 3.4.1 和 Postgres,只有 SkillHub 的 API 响应是合成的。18 项全部通过:
另有一个 Umami 的上游细节:3.4.1 在没传查询串时会存成空字符串而不是 NULL,实际上并没有发送任何查询内容。我们如实写进文档,没有修改 Umami。 4. 测试
测试不访问真实网络。最终 head 上本地验证通过:1,282 个前端测试、typecheck、lint、构建、清单新鲜度检查、 可以再调整的取舍:
接入文档仍是原有的 |
…urable-analytics Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> # Conflicts: # web/src/app/layout.tsx # web/src/pages/login.tsx
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
|
前面四项返修已基本落实,现有“被动标签+通用 helper+平台适配器”的分层可以保留。进一步考虑生产接入后,我们新增以下交付目标,不视为原返修遗漏。 1. 部署体验
2. 建议方向与边界建议评估复用现有 通用层管理开关、规则、授权和生命周期;平台参数留在适配器。Umami 只是一个验证实现,第一版不要求集成多个平台。业务页面继续只提供标签,不调用厂商 SDK。 需要验证:默认关闭时不加载采集模块或发送事件;配置错误、脚本失败、统计服务或 DNS 不可用不阻塞 Web 和业务;保留上传、登录、下载、CSP、缓存及根/子路径行为。继续检查实际发送字段、启停和重复初始化边界,明确点击不代表业务成功。 3. 现有示例需要修正的两点
可在最终接入方案中一并解决;若保留旧示例,也应修正。 请先反馈可行性、影响范围和建议拆分,再确定实现。以上不限定技术方案,若有更简单、可靠的方式,欢迎提出。新增接入能力超出原 PR 范围时,也可以作为后续 PR。 OpenSpec 讨论草案仅供参考,字段和组织方式尚可调整。 |
|
@XiaoSeS 谢谢这么细的补充,也谢谢帮忙合了 main、写了 OpenSpec 草案 🙏 先说说我们的想法,看看方向对不对,再动手。 关于部署体验复用 不同团队用的埋点平台差别挺大,比如自建的 Umami、Plausible,还有 GA、神策、火山 DataFinder 等。它们加载 SDK 的方式、上报格式、合规要求都不太一样。 如果 SkillHub 内置一个 Umami 适配器,用 Umami 的团队会很方便;用其他平台的团队,还是得自己写适配和代理。而适配器、代理路由、Compose/Helm 配置这些,之后都要由 SkillHub 长期维护。 所以我们更倾向于两步走:
当然,如果你们更希望现在就做配置化入口,我们也可以按草案来。草案里定的几条边界我们都认同:默认关闭、不加载;配置写错只是不采集,不影响 Web;业务页面只放标签;不允许加载任意远程脚本。我们只建议第一版先做一个平台。 两处示例问题你说得对,这个 PR 里会一起修:
拆分建议
看看这样可以吗?有不同意见随时说~ EnglishThanks for the detailed follow-up, and for merging main and drafting the OpenSpec change. Here are our thoughts before implementing. Deployment experience. Reusing So we'd suggest two steps:
If you'd rather build the config-driven loader now, we're happy to follow the draft. We agree with its boundaries: off and not loaded by default, bad config only disables collection without affecting Web, pages only carry markers, no arbitrary remote scripts. We'd just suggest starting with one platform. Example fixes (in this PR): set the edge body limit to 100 MiB to match Web; point the default upstream to the standard Web entry and document Proposed split: this PR = markers, helper, example fixes, guide; follow-up PR (depending on the choice) = config-driven loading, one platform adapter, Compose/Helm wiring. |
|
可以按你建议拆成两个 PR。当前 PR 先完成基础埋点、通用采集能力及已知示例问题修复,并补齐接入指南。 后续 PR 的配置化接入方向也一并确定:部署方使用已支持的平台时,通过 Docker/Compose 或 Helm 配置即可开启,不需要修改 JS、复制采集文件或手工调整 Nginx。默认关闭,开启后按需加载;配置错误或采集服务故障不影响 SkillHub 正常使用。 第一版适配器可以沿用 Umami,但通用配置和加载机制不要绑定该平台,其他平台以后按需扩展,不要求任意平台都能纯配置接入。 请同步在 OpenSpec 中拆分任务,提前对齐两个 PR 的接口,并补齐部署文档和验收场景。两个 PR 可以分别合并,#989 保留到配置化接入完成并验证后再关闭,当前 PR 请避免自动关闭该 Issue。 若实现过程中发现更简单的方案,也欢迎提出讨论。 |
The merge of latest main shifted source lines in router and pages. Only line numbers change; routes, IDs and sites are identical. Refs iflytek#989 Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Refs iflytek#989 Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Export the upstream override so later compose commands keep it, and tell operators to bypass the immutable module cache when re-checking an edited local entry. Refs iflytek#989 Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
|
@XiaoSeS 谢谢拍板 🙏 已按拆分方案把本 PR 这一步做完,麻烦有空再看看。 这次改了什么1. 两个示例问题
2. 中文接入指南 新增 3. OpenSpec 拆分 在你的草案上直接改:
本地没有 OpenSpec CLI,结构是对照 4. 不会自动关闭 #989 PR 正文的 顺带说一下合入最新 main 后,源码行号整体往下移了两行, 验证
有哪里不对或者想调整的,随时说~ EnglishThanks for the decision. This PR now covers the first step of the split.
Note: after the main merge, source lines shifted, leaving 66 stale line numbers in Validation: 1,357 frontend tests and 80 example tests, typecheck, lint, build, manifest and Compose config pass; a local real Chrome/Nginx/Umami/Postgres run passed 21 checks, including a 5 MiB upload passing and >100 MiB rejected, and the guide was followed end to end. API responses were synthetic. |
|
已完成复核并合并,感谢这轮补充。 我们在合入当前 main 的版本上完成了前端 1,357 项测试、14 项验收场景及真实服务验证:使用真实 SkillHub 后端、浏览器、Nginx、Umami 和 PostgreSQL,确认事件实际入库,并验证默认关闭、停止采集、重复初始化、撤回同意及采集服务故障不影响业务。维护者也已用正常浏览器人工操作,并在 Umami 图表中确认数据。相关 CI 已通过。 第一阶段按约定完成,#989 继续保持开放。后续请按 OpenSpec 中 PR-2 的方向推进配置化接入:复用运行时配置,Docker/Compose 和 Helm 用户通过配置即可开启;默认关闭、按需加载,配置错误或采集故障不影响主业务。首个适配器可用 Umami,通用配置和加载机制保持可扩展,并同步补齐部署文档及验收场景。若实现中有更简单、维护成本更低的方案,也欢迎讨论。 |
Summary
Refs #989(本 PR 是两步交付中的第一步,合并后 #989 继续保持打开,等后续配置化接入 PR 完成并验证后再关闭)
给前端业务操作提供稳定、被动的 HTML 语义属性,外部采集器无需依赖中文/英文文案、CSS 或 DOM 层级。产品默认不加载采集脚本、不采集、不外发数据。
data-analytics-id使用静态业务类别,必要时用字面量条件区分冻结/解冻/删除、申请/直接撤销等动作。资源、身份、Token、输入内容不进入属性。docs/examples/analytics/),默认关闭、需显式同意,产品本身仍不加载任何采集脚本。openspec/changes/add-configurable-frontend-analytics/。当前源码清单为 54 个注册路由、804 个唯一静态 ID、821 处 literal JSX 属性位置(975 个条件字面量值、29 个导航定义、36 个透传位置)。这些是源码口径,不是运行时元素、业务成功事件、用户数或完整采集覆盖承诺。
Validation
.trellis/spec/testing/index.md; exclusions explained验证工具链:Node 24.13.0、pnpm 10.33.0。本轮验证 HEAD 为
57275a6bfb53875cee7dc0d83f78b182627c8a14,开发基线仍冻结于e88ebf57c2e9123ef9697ce9a08492fd7e18b7a8。/skillhub/子路径);这是首发证据,本轮没有重新跑子路径浏览器验收。66c1dcf6到当前 head,只有示例、文档和示例测试变化;产品代码、生成清单、Docker、CI 和依赖不变。Risk
Notes
skill.*前缀推断宿主资源类型。/fonts/)也可能沿该缓存策略。正文过滤仍仅 text/html,部署方可按实际静态文件路由进一步保留缓存。docs/frontend-analytics-integration.md(中文接入指南)、docs/frontend-analytics.md(英文契约)、docs/frontend-analytics-manifest.json、docs/examples/analytics/(原docs/examples/nginx-analytics.conf与skillhub-intents.mjs已移入此目录)。361a4d47、1936cee3、2aecb618、57275a6b)逐条说明见 PR 评论;后端提案 [Feature] RFC:默认关闭的厂商中立后端业务事件出口 / Opt-in backend business-event export #1009 独立,不在本轮实现范围。900faf7d(合入 main 后刷新清单行号,内容不变)、238b7841(示例 edge 上传上限 100 MiB、默认上游对齐正式 Web 入口并补 host-gateway)、688b7ce1与3527a5ac(中文接入指南与 OpenSpec 拆分)。本轮验证:全量 1,357 项、示例 80 项测试及 typecheck/lint/build/清单/Compose 通过;真实 Chrome + Nginx + Umami + Postgres 21 项检查通过,包含 5 MiB 上传可通过、超过 100 MiB 被拒。English summary
This frontend-only contribution provides passive semantic HTML attributes across the registered UI, including meaningful conditional actions, confirmations, cancellations and retries. Collection remains deployment-owned and opt-in: no SDK, reporting, app loader or runtime analytics dispatch is added. Static attributes never include resource/identity/credential/input contents.
The generated source inventory contains 54 registered routes, 804 unique static categories and 821 literal JSX attribute sites. These are source counts, not runtime elements, users, successful operations or exhaustive event coverage. Wrapper properties are explicitly forwarded to real controls and portal close buttons; existing interactions and permissions remain unchanged.
Split into two PRs per maintainer decision: this PR delivers passive markers, the generic helper, example fixes and a Chinese integration guide (
docs/frontend-analytics-integration.md); configuration-only deployment follows in a separate PR, with tasks and interfaces aligned inopenspec/changes/add-configurable-frontend-analytics/. Issue #989 stays open until that follow-up is verified. Validation at3527a5ac: 1,357 frontend tests and 80 example-focused tests, typecheck, lint, build, manifest and Compose config passed; real Chrome/Nginx/Umami/Postgres passed 21 checks, including a 5 MiB upload passing and >100 MiB rejected. Earlier at57275a6b: 1,282 frontend tests, 77 example-focused tests, typecheck, lint, build, manifest freshness and Compose config passed. Three sets of pinned-Umami-source integration probes (6, 11 and 12) passed and were replayed independently. The latest real Chrome/Nginx/Umami/Postgres integration passed 18 checks; only SkillHub API responses were synthetic. Earlier 25 HTTP and 28 Chrome checks, including sub-path adaptation, remain first-publication evidence; sub-path browser acceptance was not rerun this round. Current hosted CI is reported separately in Checks.The optional deployment example documents compression, cache validators, MIME/404, CSP, root/sub-path URI handling, consent and rollback. Collection stays off by default. The default rule map contains the original 12 actions; deployers map other published IDs to the finite click/submit/card rules by config. A runnable local Umami example (
docs/examples/analytics/) was added after maintainer review; it is off by default and requires explicit consent. See the review follow-up comment for per-request changes and current Checks for the reworked head. Shared content-browser categories can cross resource domains; the sample fallback's conservative no-store also affects some root public assets. Backend export stays separate in #1009; UI intent is not a completion receipt.Infographic
概念示意,不代表生产部署或业务成功回执。Conceptual illustration, not deployment or completion evidence.