@mingfuyun/star-allinone 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  | 弹层 overlays | `import { CustomDrawer, BaseModal, HocModal } from '@mingfuyun/star-allinone'` | 不要从 `@/components/CustomDrawer` 抄一份 |
10
10
  | 错误边界 | `import { ErrorBoundary } from '@mingfuyun/star-allinone'` | — |
11
11
  | Cron | `import { Cron } from '@mingfuyun/star-allinone'` | — |
12
+ | 埋点运行时 | `import { createTracking, getTrackData, TRACKING_REPORT_URLS } from '@mingfuyun/star-allinone'` | SDK 脚本只从 OSS 加载,见 [埋点接入](#-埋点接入) |
12
13
  | 管理列表表格 | `import MFProTable from '@/components/CommonTable/MFProTable'` | **没有** `MFTablePro`。不要从本包 import 表格 |
13
14
  | 请求 | `import Service from '@/services'`(内部 `MFRequest`) | 页面不要直接 axios |
14
15
 
@@ -123,6 +124,10 @@ git commit -m "chore(skill): 接入公共 skill"
123
124
  使用 $shared-publish-test,把当前分支发布到测试环境。
124
125
  ```
125
126
 
127
+ ```text
128
+ 使用 $shared-tracking,为本项目接入埋点并全站补齐按钮埋点。
129
+ ```
130
+
126
131
  公共流程用 `shared-*`,项目专属规则用 `custom-*`。`custom-*` 不能再实现一遍 Service/页面生成/审查。全量契约重建若需要,写成不可调用的脚本,并在 `AGENTS.md` 写命令。业务定制需要复用公共流程时,读取对应的 `.agents/skills/shared-*/SKILL.md`,不要再抛一个入口。
127
132
 
128
133
  ### 业务项目:更新公共 skill
@@ -154,6 +159,138 @@ import { CustomDrawer, HocModal } from '@mingfuyun/star-allinone';
154
159
 
155
160
  完整 props 合同见同步后的 `.agents/skills/shared-project-conventions/references/mfprotable.md`。
156
161
 
162
+ ## 📊 埋点接入
163
+
164
+ 星系管理端统一埋点。运行时依赖本包的 `createTracking`;SDK 从 OSS 加载,**不要**提交进业务仓库或打进 webpack。
165
+
166
+ **能力包要求:** **≥ 0.4.0**(含 `createTracking`、`TRACKING_REPORT_URLS`、`CustomDrawer` 的 `cancelTrack` / `okTrack`)。
167
+
168
+ **Agent Skill:** 业务项目 `skills sync` 后,在对话里触发 `$shared-tracking`。基础设施、全站按钮埋点、验证均由 Agent 完成,**不需要**开发者手工改 `tracking/index.ts`、`app.tsx`、各页 `const.tsx`。
169
+
170
+ 完整 Skill 规范见 [skills/shared/tracking/SKILL.md](skills/shared/tracking/SKILL.md)(同步后为 `.agents/skills/shared-tracking/SKILL.md`)。
171
+
172
+ ### 用户只需做 2 件事
173
+
174
+ **1. 安装能力包并同步 Skill**
175
+
176
+ ```bash
177
+ pnpm add @mingfuyun/star-allinone@^0.4.5
178
+ pnpm exec star-allinone skills sync
179
+ ```
180
+
181
+ **2. 在 Cursor / Codex 触发 Skill**
182
+
183
+ ```text
184
+ 使用 $shared-tracking,为本项目接入埋点并全站补齐按钮埋点。
185
+ ```
186
+
187
+ 之后由 Agent 改代码、跑 `pnpm typecheck`、汇报已覆盖文件。
188
+
189
+ **前置条件(平台侧):** 埋点平台已登记 `appId`(测试 `test-<project>`,生产 `<project>`,与 `.star-allinone.json` 的 `project` 一致)。
190
+
191
+ **提交:** 确认 Agent 改动后,用 `$shared-review-and-submit` 审查并提交。
192
+
193
+ ### `$shared-tracking` 会自动完成
194
+
195
+ | Skill 步骤 | Agent 做什么 |
196
+ | --- | --- |
197
+ | 配置 tracking | 新建 `src/utils/tracking/index.ts`(`createTracking`、`getTrackData` 等) |
198
+ | 加载 SDK | 在 Umi `headScripts` 插入 OSS 内联脚本 |
199
+ | 应用初始化 | 改 `src/app.tsx`:`markTrackingReady`、`syncTrackingRoute` |
200
+ | 接口失败上报 | 改 `src/services/request.tsx`:失败时 `reportApiTracking` |
201
+ | 全站按钮埋点 | 扫描页面,补齐五类按钮以及 **带 `onClick` 的 `a` / `div` / `span` 等** |
202
+ | 验证 | 跑 `pnpm typecheck`;必要时说明浏览器验收项 |
203
+
204
+ 非默认 import 路径时,Agent 可读 `.star-allinone.json` 的 `trackingModule`(如 `@/utils/tracking`)。
205
+
206
+ ### 哪些按钮会自动 / 半自动加上埋点
207
+
208
+ **A. 完全自动(`MFProTable` 组件内)**
209
+
210
+ | 按钮 | 说明 |
211
+ | --- | --- |
212
+ | 列表 **查询** | `filter_query` / `查询` |
213
+ | 列表 **重置** | `filter_reset` / `重置` |
214
+
215
+ 页面 `const.tsx` **不要重复**写查询/重置的 `track`。
216
+
217
+ **B. `gen page` 自动生成**(需已有 `src/utils/tracking/index.ts`)
218
+
219
+ | 位置 | 生成内容 |
220
+ | --- | --- |
221
+ | `const.tsx` 工具栏 | 「新增」→ `track` |
222
+ | `const.tsx` 操作列 | 「编辑」「删除」→ `track` |
223
+ | `*Drawer.tsx` | `cancelTrack` / `okTrack` |
224
+ | `*ConfirmModal.tsx` | 确认框 `data-track` |
225
+
226
+ 跳过:`gen page ... --no-tracking`。不会自动生成:复制、批量、自定义 footer、独立权限按钮、带 submitter 的 ProForm。
227
+
228
+ **C. Agent 全站补齐**(`$shared-tracking` / `$shared-design-to-page`)
229
+
230
+ | # | 按钮类型 | 典型位置 |
231
+ | --- | --- | --- |
232
+ | 1 | 权限相关 | `toolBarRender`、`withAuth(Button)`、`TablePermissionActions` |
233
+ | 2 | 抽屉 / 弹层 | `CustomDrawer`、`BaseModal`(含 `HocModal`) |
234
+ | 3 | 表格操作列 | `actionColumn`、`TableActions` |
235
+ | 4 | 表单提交/重置 | `ProForm` submitter、`Form` 按钮 |
236
+ | 5 | 复制 | 操作列、工具栏、「复制 IP」等 |
237
+ | 6 | 带 `onClick` 的元素 | `a`、`div`、`span`、`Typography.Link`、可点击卡片 |
238
+
239
+ **不上报:** 列设置、表格「更多」省略号 icon(菜单内各项仍要 track)、无权限未渲染的按钮、**没有** `onClick` 的纯展示节点。
240
+
241
+ ### 按钮写法速查
242
+
243
+ ```tsx
244
+ import { getTrackData } from '@/utils/tracking';
245
+
246
+ // 工具栏
247
+ track: getTrackData('create', '新增', { key: 'toolbar', name: '工具栏' })
248
+
249
+ // 操作列
250
+ track: getTrackData('edit', '编辑', { key: 'action', name: '操作' })
251
+
252
+ // 抽屉默认底部
253
+ <CustomDrawer
254
+ cancelTrack={getTrackData('cancel', '取消', { key: 'editor', name: '用户管理' })}
255
+ okTrack={getTrackData('confirm', '确定', { key: 'editor', name: '用户管理' })}
256
+ />
257
+
258
+ // 带 onClick 的 a / div / span
259
+ <a
260
+ data-track={getTrackData('view_detail', '查看详情', { key: 'cell', name: '名称' })}
261
+ onClick={() => handleView(record)}
262
+ >
263
+ {record.name}
264
+ </a>
265
+ ```
266
+
267
+ 点击由 SDK 监听 `data-track`,**不要在** `onClick` 里再调 `track()`。
268
+
269
+ ### 接入流程
270
+
271
+ ```text
272
+ 【用户】pnpm add + skills sync
273
+ ↓
274
+ 【用户】对话:$shared-tracking 接入并全站补齐
275
+ ↓
276
+ 【Skill】tracking 配置 + SDK + app.tsx + request + 全站按钮 track
277
+ ↓
278
+ 【Skill】pnpm typecheck + 汇报改动范围
279
+ ↓
280
+ 【用户】$shared-review-and-submit 确认并提交
281
+ ```
282
+
283
+ 新建列表页可用 `$shared-design-to-page`(内部 `gen page` 带默认 track,Skill 再补复制/批量等)。
284
+
285
+ ### 不要做的事
286
+
287
+ - 不要把 `tracking-sdk.global.min.js` 提交到 Git
288
+ - 不要把 SDK 打进 webpack
289
+ - 不要只接 SDK 不补按钮埋点
290
+ - 不要上报成功请求
291
+
292
+ 更多细节见 [skills/shared/tracking/SKILL.md](skills/shared/tracking/SKILL.md)。
293
+
157
294
  ## 🚀 快速开始
158
295
 
159
296
  ### 基础使用
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingfuyun/star-allinone",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "星系运维前端能力包",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/skills/README.md CHANGED
@@ -127,7 +127,7 @@ git commit -m "chore(skill): 更新公共 skill"
127
127
  | `shared-design-to-page` | 页面:标准列表内部 `gen page`,其余按设计稿实现 |
128
128
  | `shared-review-and-submit` | 审查并提交 |
129
129
  | `shared-publish-test` | 测发 |
130
- | `shared-tracking` | 埋点:升级能力包、加载 OSS 脚本、初始化、失败上报、按钮 `data-track` |
130
+ | `shared-tracking` | 埋点接入与全站可点击补齐(含 onClick 的 a/div/span) |
131
131
 
132
132
  ## 公共规则写在哪里
133
133
 
@@ -137,7 +137,7 @@ git commit -m "chore(skill): 更新公共 skill"
137
137
  | `shared-design-to-page` | SKILL + `page-conventions.md`、`overlays.md`、`list-page-template.md`、`tracking.md` | 页面分层、标准列表 CLI、弹层合同、按钮埋点 |
138
138
  | `shared-review-and-submit` | SKILL + `impact-analysis.md`、`verify.md`、`ai-review.md`、`commit.md` | 影响分析 → 验证(含埋点完整性)→ 确认后提交 |
139
139
  | `shared-publish-test` | SKILL + `scripts/publish-current-branch.sh` | 云效测发;只读 `publishPipelineId` |
140
- | `shared-tracking` | SKILL | 埋点接入:能力包版本、配置文件、脚本、初始化、失败上报、权限按钮、操作列、抽屉弹层、表单按钮 |
140
+ | `shared-tracking` | [SKILL.md](./shared/tracking/SKILL.md) | 埋点接入:业务接入、五类按钮、带 onClick 的 a/div/span |
141
141
  | (非入口)`shared-project-conventions` | `architecture.md`、`mfprotable.md`、`component-contract.md`、`review-checklist.md`(含埋点审查)、`quality-checklist.md` | 架构、导入合同、质量清单 |
142
142
  | (非入口)`shared-i-have-adhd` | `i-have-adhd.md` | 用户输出格式 |
143
143
 
@@ -52,7 +52,7 @@ Add `--permission-create`, `--permission-edit`, `--permission-delete` when codes
52
52
  3. The CLI fills columns and drawer fields from the OpenAPI schema (required, enum → `ProFormSelect`, dates/numbers). Review labels and permission codes; do not recreate the file tree. See [references/list-page-template.md](references/list-page-template.md).
53
53
  4. If `src/components/Page/Container/config.tsx` exists, `gen page` writes a Container `index.tsx`, puts the table in `components/List.tsx`, and registers a Tab with `loader: () => import(...)`. Do not invent a second page shell.
54
54
  5. Do not overwrite existing page files. Tell the user the CLI refused, then edit in place.
55
- 6. **Tracking:** When the project has tracking configured, `gen page` auto-wires default button tracking. Agent must scan and wire **all** in-scope buttons per [references/tracking.md](references/tracking.md) and `$shared-tracking` (permission, drawer/modal footers, action column, ProForm, copy)—do not leave manual steps for the user. If tracking is not set up yet, tell the user to run `$shared-tracking` first; do not invent a second tracking helper.
55
+ 6. **Tracking:** When the project has tracking configured, `gen page` auto-wires default button tracking. Agent must scan and wire **all** in-scope clickables per [references/tracking.md](references/tracking.md) and `$shared-tracking` (permission, drawer/modal footers, action column, ProForm, copy, **`onClick` on `a` / `div` / `span`**)—do not leave manual steps for the user. If tracking is not set up yet, tell the user to run `$shared-tracking` first; do not invent a second tracking helper.
56
56
 
57
57
  ## Design path
58
58
 
@@ -65,7 +65,7 @@ For non-standard layouts:
65
65
  5. API-backed pages include types, `MFRequest` methods, aggregate exports, and page consumption in the same change. Use `.agents/skills/shared-api-to-service/SKILL.md` for missing services. Use `.agents/skills/shared-api-to-service/references/mock.md` for extra mock scenarios. Do not embed production fake data.
66
66
  6. Compare desktop and narrow layouts against the design. Fix structure and spacing before decoration.
67
67
  7. Run focused verification. Do not claim visual fidelity without inspecting the rendered page.
68
- 8. When tracking is enabled, Agent applies [references/tracking.md](references/tracking.md) for every toolbar, action, copy, drawer, confirm, form submit, and standalone permission button on the page.
68
+ 8. When tracking is enabled, Agent applies [references/tracking.md](references/tracking.md) for every toolbar, action, copy, drawer, confirm, form submit, standalone permission button, and **`onClick` on `a` / `div` / `span` / links**.
69
69
 
70
70
  ## Hard rules
71
71
 
@@ -79,7 +79,7 @@ For non-standard layouts:
79
79
  - Do not use `Modal.confirm` or feature-level Ant Design `Modal` / `Drawer` shells.
80
80
  - Do not add a UI library, state library, or CSS-in-JS system without approval.
81
81
  - Do not refactor unrelated code.
82
- - When `src/utils/tracking/index.ts` exists, Agent wires `getTrackData` on every button covered by [references/tracking.md](references/tracking.md) (including copy). Do not call `track()` in handlers. Do not ask the user to add tracks manually.
82
+ - When `src/utils/tracking/index.ts` exists, Agent wires `getTrackData` on every control covered by [references/tracking.md](references/tracking.md), including copy and **any `onClick` on `a` / `div` / `span` / links**. Do not call `track()` in handlers. Do not ask the user to add tracks manually.
83
83
 
84
84
  ## Verification
85
85
 
@@ -90,7 +90,7 @@ pnpm typecheck
90
90
 
91
91
  Run `pnpm lint` for broad or shared changes. Run the project's documented build command when routes, entry, or multiple pages change.
92
92
 
93
- When tracking is configured, scan changed page files: toolbar `track`, action `track`, copy `track`, drawer `cancelTrack` / `okTrack` or custom-footer `data-track`, confirm modal buttons, ProForm submitters, and standalone permission buttons. Agent fixes missing wiring before calling the page done; do not defer to the user.
93
+ When tracking is configured, scan changed page files: toolbar `track`, action `track`, copy `track`, drawer `cancelTrack` / `okTrack` or custom-footer `data-track`, confirm modal buttons, ProForm submitters, standalone permission buttons, and **`onClick` on `a` / `div` / `span` / `Typography.Link`**. Agent fixes missing wiring before calling the page done; do not defer to the user.
94
94
 
95
95
  ## User-facing output
96
96
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Apply when the business project already has `src/utils/tracking/index.ts` (or the path documented in project conventions). Full SDK setup and **Agent 全站批量补齐规则** live in `.agents/skills/shared-tracking/SKILL.md`. This file covers **page / 生成场景**。
4
4
 
5
- **Agent 规则:** 生成或修改页面时,由 Agent 写入全部按钮埋点,**不要**留给用户手工补。与「接入埋点」同一套五类扫描标准(含复制按钮)。
5
+ **Agent 规则:** 生成或修改页面时,由 Agent 写入全部可点击埋点,**不要**留给用户手工补。与「接入埋点」同一套扫描标准:五类按钮 + **任何带 `onClick` 的元素**(`a`、`div`、`span`、`Typography.Link` 等)。
6
6
 
7
7
  Import:
8
8
 
@@ -24,6 +24,7 @@ Click reporting uses `data-track` JSON from `getTrackData`. Do not call `track()
24
24
  | Drawer / Modal custom footer | each `Button` | `data-track={getTrackData(...)}` |
25
25
  | Confirm dialog | `BaseModal` | custom footer + `data-track` when button props unavailable |
26
26
  | Inline form submit | `ProForm` / `Form` | `submitButtonProps` / `resetButtonProps` |
27
+ | Clickable `a` / `div` / `span` / `Typography.Link` | any node with `onClick` | `data-track={getTrackData(...)}` on **that** node |
27
28
 
28
29
  `MFProTable` query and reset are handled inside the table (`filter_query` / `查询`, `filter_reset` / `重置`). Do not duplicate in page code.
29
30
 
@@ -49,15 +50,18 @@ Every business `Button` in custom `footer` needs `data-track`. Do not replace th
49
50
  - Column settings only.
50
51
  - Table overflow 「更多」 ellipsis icon (menu items inside still need `track`).
51
52
  - Buttons hidden by permission (no render → no track).
53
+ - Nodes with **no** `onClick` (plain text, static `href` links).
52
54
 
53
55
  **Copy buttons must be tracked** — see shared-tracking §5.
54
56
 
57
+ **Any `onClick` node must be tracked** — see shared-tracking §6 (`a`, `div`, `span`, `Typography.Link`, clickable cards).
58
+
55
59
  ## After `gen page`
56
60
 
57
- When `src/utils/tracking/index.ts` exists, `gen page` wires toolbar, action edit/delete, drawer, and modal by default. Agent still reviews and adds tracking for extra buttons (copy, batch, custom footer, ProForm). Pass `--no-tracking` only when user explicitly asks.
61
+ When `src/utils/tracking/index.ts` exists, `gen page` wires toolbar, action edit/delete, drawer, and modal by default. Agent still reviews and adds tracking for extra buttons (copy, batch, custom footer, ProForm) and **every `onClick` on `a` / `div` / `span` / links**. Pass `--no-tracking` only when user explicitly asks.
58
62
 
59
63
  For pages **not** from `gen page`, Agent scans and wires the full set per shared-tracking — not a user manual task.
60
64
 
61
65
  ## Verification
62
66
 
63
- Static scan changed files: every toolbar / action / copy / drawer / modal / form button has `track`, `cancelTrack`, `okTrack`, or `data-track`.
67
+ Static scan changed files: every toolbar / action / copy / drawer / modal / form button, plus every `onClick` on `a` / `div` / `span` / `Typography.Link`, has `track`, `cancelTrack`, `okTrack`, or `data-track`.
@@ -33,10 +33,11 @@ Apply when the project has `src/utils/tracking/index.ts` (or the path in project
33
33
  - Toolbar and batch actions in `getToolBarRender` need `track: getTrackData(...)`.
34
34
  - Action column entries need `track` beside `permission` when present.
35
35
  - Standalone permission buttons need `data-track={getTrackData(...)}`.
36
+ - Clickable `a` / `div` / `span` / `Typography.Link` with `onClick` need `data-track` on **that** node.
36
37
  - `CustomDrawer` with the default footer needs `cancelTrack` and `okTrack`; custom footers need `data-track` on each business button.
37
38
  - `BaseModal` confirm dialogs need `cancelButtonProps` / `okButtonProps` with `'data-track'`.
38
39
  - `ProForm` with a visible default submitter needs submit/reset button props; when `submitter={false}`, tracking belongs on the overlay footer only.
39
- - Require tracking on copy actions; do not require tracking on column settings, table overflow ellipsis icon, or buttons hidden by permission.
40
+ - Require tracking on copy actions and **any node with `onClick`** (`a`, `div`, `span`, `Typography.Link`, clickable cards). Do not require tracking on column settings, table overflow ellipsis icon, buttons hidden by permission, or nodes without `onClick`.
40
41
  - Missing in-scope button tracking on a changed page is **P1**.
41
42
 
42
43
  ## Shared components and regression
@@ -30,9 +30,9 @@ Follow [references/impact-analysis.md](references/impact-analysis.md). Output:
30
30
  Follow [references/verify.md](references/verify.md). Output:
31
31
 
32
32
  - P0/P1/P2 blockers
33
- - Completeness of route, permission, API, types, mock, page states, and button tracking when the project has tracking configured
33
+ - Completeness of route, permission, API, types, mock, page states, and click tracking when the project has tracking configured
34
34
  - Async, loading, overlay, and list-reload behavior
35
- - Missing `track` / `data-track` / `cancelTrack` / `okTrack` on in-scope buttons per `shared-tracking` and `shared-design-to-page/references/tracking.md` (P1 when tracking is enabled)
35
+ - Missing `track` / `data-track` / `cancelTrack` / `okTrack` on in-scope clickables (buttons, copy, **`onClick` on `a` / `div` / `span`**) per `shared-tracking` (P1 when tracking is enabled)
36
36
  - Prettier, TypeScript, lint, and build results
37
37
  - Uncovered risks
38
38
 
@@ -15,7 +15,7 @@ If `.agents/project/review-rules.md` exists, apply extra domain checks only; do
15
15
  1. React Hooks: stale closures, incomplete dependencies, request races, updates after unmount, unnecessary rerenders.
16
16
  2. API contracts: method/path/params, response unwrapping, pagination, nullability, enum drift, error handling, DTO mismatch.
17
17
  3. Permissions: route access, button visibility, mutation authorization, client-only enforcement.
18
- 4. **Tracking** (when `src/utils/tracking/index.ts` or project equivalent exists): scan changed pages for missing `track` / `cancelTrack` / `okTrack` / `data-track` on in-scope buttons—toolbar, action column, permission buttons, drawer and confirm footers (default and custom), inline form submitters, and **copy** actions. Flag missing wiring as **P1**. Do not require tracking on column settings, table overflow ellipsis icon, or permission-hidden buttons. Do not flag handlers that call `track()` when `data-track` is the project standard.
18
+ 4. **Tracking** (when `src/utils/tracking/index.ts` or project equivalent exists): scan changed pages for missing `track` / `cancelTrack` / `okTrack` / `data-track` on in-scope buttons—toolbar, action column, permission buttons, drawer and confirm footers (default and custom), inline form submitters, **copy** actions, and **any `onClick` on `a` / `div` / `span` / `Typography.Link`**. Flag missing wiring as **P1**. Do not require tracking on column settings, table overflow ellipsis icon, permission-hidden buttons, or nodes without `onClick`. Do not flag handlers that call `track()` when `data-track` is the project standard.
19
19
  5. Forms/tables: validation, reset, duplicate submit, refresh after mutation, column-state, long text, empty/error.
20
20
  6. Performance (hard checks):
21
21
  - New or changed files must not statically `import 'xlsx'`, `@uiw/react-codemirror`, `@codemirror/*`, `echarts`, `@ant-design/charts`, or `react-json-view` at module top level. Those must be `import()`.
@@ -19,7 +19,7 @@ Do not auto-fix. If `.agents/project/review-rules.md` exists, apply extra domain
19
19
  5. Empty table values, duplicate-submit guards, permission wrappers, and narrow-screen overflow.
20
20
  6. Heavy deps (`xlsx`, editors, charts) are `import()`; nothing new lands in `src/app.ts`.
21
21
  7. No `MFTablePro` / table-from-package imports; overlays come from `@mingfuyun/star-allinone`.
22
- 8. **Tracking** (when tracking is configured): every in-scope button has `track`, `cancelTrack`, `okTrack`, or `data-track` per `.agents/skills/shared-tracking/SKILL.md` and `.agents/skills/shared-design-to-page/references/tracking.md`. Check toolbar items, action column entries, standalone permission buttons, drawer default or custom footers, confirm modals, inline `ProForm` submitters, and **copy** buttons. Missing wiring is **P1** when the button is user-visible and in scope. Excluded controls (column settings, table overflow ellipsis icon) must not be flagged. Permission-hidden buttons may omit tracking.
22
+ 8. **Tracking** (when tracking is configured): every in-scope clickable has `track`, `cancelTrack`, `okTrack`, or `data-track` per `.agents/skills/shared-tracking/SKILL.md` and `.agents/skills/shared-design-to-page/references/tracking.md`. Check toolbar items, action column entries, standalone permission buttons, drawer default or custom footers, confirm modals, inline `ProForm` submitters, **copy** buttons, and **`onClick` on `a` / `div` / `span` / `Typography.Link`**. Missing wiring is **P1** when the control is user-visible and in scope. Excluded controls (column settings, table overflow ellipsis icon, nodes without `onClick`) must not be flagged. Permission-hidden buttons may omit tracking.
23
23
 
24
24
  ## Commands
25
25
 
@@ -16,11 +16,11 @@ description: User-facing. Connect a galaxy admin app to the shared tracking SDK.
16
16
  完成标准:
17
17
 
18
18
  1. 基础设施(SDK、`tracking/index.ts`、`app.tsx`、请求封装)已就绪。
19
- 2. **全站**下列五类可点击按钮均已带 `track` / `cancelTrack` / `okTrack` / `data-track`(无权限未渲染的除外)。
19
+ 2. **全站**带用户点击意图的控件均已带 `track` / `cancelTrack` / `okTrack` / `data-track`(无权限未渲染的除外)。覆盖五类标准按钮,以及 **任何写了 `onClick` / `onClickCapture` 的元素**(`a`、`div`、`span`、`Typography.Link` 等)。
20
20
  3. `pnpm typecheck` 通过。
21
21
  4. 向用户汇报已覆盖的文件范围,而不是留 TODO 让用户自己改。
22
22
 
23
- ### 必须扫描并补齐的五类按钮
23
+ ### 必须扫描并补齐的范围
24
24
 
25
25
  | # | 范围 | 扫描位置 | 写法 |
26
26
  | --- | --- | --- | --- |
@@ -29,6 +29,9 @@ description: User-facing. Connect a galaxy admin app to the shared tracking SDK.
29
29
  | 3 | **MFProTable 操作列** | `actionColumn`、`listActionColumn`、`TableActions`、`TablePermissionActions` | `ActionItem.track` |
30
30
  | 4 | **ProForm / Form** | `submitter` 默认栏、`submitter.render`、antd `Form` 提交/重置 | `submitButtonProps` / `resetButtonProps` 的 `data-track` |
31
31
  | 5 | **复制相关按钮** | 文案含「复制」「一键复制」、`key` 含 `copy`;含复制 IP | `getTrackData('copy', '…', …)` |
32
+ | 6 | **任意带 `onClick` 的可点击元素** | `onClick` / `onClickCapture` 写在 `a`、`div`、`span`、`p`、`li`、`Typography.Link`、`Typography.Text`、antd `Link` 等上 | 该节点加 `data-track={getTrackData(...)}`。不要只给外层容器埋点而漏掉真正被点的子节点 |
33
+
34
+ 硬规则:**只要业务代码给节点绑了点击回调,该节点就要上报。** 不限 `Button`。链接、可点击文字、卡片区域、状态标签、图标容器都算。
32
35
 
33
36
  另需覆盖(同属 Agent 批量任务):
34
37
 
@@ -44,9 +47,11 @@ rg "toolBarRender|actionColumn|listActionColumn|TablePermissionActions" src/page
44
47
  rg "withAuth|AccessButton" src/pages -g "*.tsx"
45
48
  rg "ProForm|submitter" src/pages -g "*.tsx"
46
49
  rg "复制|copy|Copy" src/pages src/components -g "*.tsx"
50
+ rg "onClick(Capture)?=" src/pages src/components -g "*.tsx"
51
+ rg "<a |<div |<span " src/pages -g "*.tsx"
47
52
  ```
48
53
 
49
- 对每个命中文件:**打开、判断是否在五类范围内、补全、保存**。历史页与 `gen page` 新页同一标准。
54
+ 对每个命中文件:**打开、判断是否在范围内、补全、保存**。带 `onClick` 的 `a`/`div`/`span` 与 Button 同一标准。历史页与 `gen page` 新页同一标准。
50
55
 
51
56
  ### 不要做的「半套接入」
52
57
 
@@ -54,8 +59,9 @@ rg "复制|copy|Copy" src/pages src/components -g "*.tsx"
54
59
  - ❌ 只改一两个示例页,告诉用户「其余页按同样方式手动加」
55
60
  - ❌ 在组件层做 track 自动推断(不改 `withAuth` / `TableActions` 自动生成 track)
56
61
  - ❌ 把复制按钮排除在补齐范围外
62
+ - ❌ 只给 `Button` 加埋点,漏掉带 `onClick` 的 `a` / `div` / `span` / `Typography.Link`
57
63
 
58
- 仍不上报:**列设置**、表格 **「更多」省略号**(仅展开菜单的 icon;菜单内各项仍要 track)。
64
+ 仍不上报:**列设置**、表格 **「更多」省略号**(仅展开菜单的 icon;菜单内各项仍要 track)、纯展示且**没有** `onClick` 的节点。
59
65
 
60
66
  ---
61
67
 
@@ -260,6 +266,45 @@ Umi:
260
266
  track: getTrackData('copy', '复制IP', { key: 'toolbar', name: '群看板' })
261
267
  ```
262
268
 
269
+ #### 6. 带 `onClick` 的 `a` / `div` / `span` 等
270
+
271
+ 业务点击绑在哪个节点,`data-track` 就写在哪个节点上。不要依赖父级冒泡来代替。
272
+
273
+ ```tsx
274
+ <a
275
+ data-track={getTrackData('view_detail', '查看详情', { key: 'cell', name: '名称' })}
276
+ onClick={() => handleView(record)}
277
+ >
278
+ {record.name}
279
+ </a>
280
+
281
+ <div
282
+ className={styles.card}
283
+ data-track={getTrackData('open_card', '打开卡片', { key: 'board', name: '看板' })}
284
+ onClick={handleOpenCard}
285
+ >
286
+ {title}
287
+ </div>
288
+
289
+ <span
290
+ data-track={getTrackData('toggle_status', '切换状态', { key: 'cell', name: '状态' })}
291
+ onClick={() => handleToggle(record)}
292
+ >
293
+ {record.status}
294
+ </span>
295
+
296
+ <Typography.Link
297
+ data-track={getTrackData('open_doc', '打开文档', { key: 'link', name: '文档' })}
298
+ onClick={handleOpenDoc}
299
+ >
300
+ 文档
301
+ </Typography.Link>
302
+ ```
303
+
304
+ `onClick` 写在包裹组件上时,把 `data-track` 也写在同一组件。子节点没有独立点击时不要重复上报。
305
+
306
+ 路由跳转用 `history.push` / `navigate` 且绑了 `onClick` 的,同样要 `data-track`。纯 `href`、没有 `onClick` 的外链可以不上报。
307
+
263
308
  ## 不要做的事
264
309
 
265
310
  - 不要把 `tracking-sdk.global.min.js` 提交到业务仓库。
@@ -277,6 +322,6 @@ track: getTrackData('copy', '复制IP', { key: 'toolbar', name: '群看板' })
277
322
  1. 页面请求了 OSS 上的脚本,并且出现 `window.TrackingSDK`。
278
323
  2. 进入业务页、初始状态完成后存在 `window.__tracker`。`/` 上可以还没有。
279
324
  3. 一次失败请求发出事件名 `api_request`。
280
- 4. 五类按钮(含复制)带 `data-track` / `cancelTrack` / `okTrack`。
325
+ 4. 五类标准按钮(含复制),以及带 `onClick` 的 `a` / `div` / `span` / `Typography.Link` 等,带 `data-track` / `cancelTrack` / `okTrack`。
281
326
 
282
327
  `appId` 与平台不一致时,只改 `src/utils/tracking/index.ts`。