--- name: ae-generate-tracking-plan description: "Interactive generation of an AE tracking plan and upload. Trigger words: 埋点方案、埋点模板、tracking plan、AE 方案生成、create tracking plan、トラッキングプラン、트래킹 플랜. Follows anchor → draft → refine → token → upload five-phase workflow. Deliverable is a real tracking plan created in the AE platform." --- # ae-generate-tracking-plan ## Cross-skill collaboration When remaining work is outside this skill's scope, or a necessary prerequisite needs another capability, follow [the collaboration protocol](references/collaboration.md). Choose from the skills available in this run by capability, preserve verified context, and continue the remaining task. Reuse this protocol if already loaded. > **Conversation language**: This skill document is in English, but **all output to the user MUST be in the user's input language**. > English input → English reply; Chinese input → Chinese reply; Japanese input → Japanese reply. > If uncertain, default to English. > This applies to all output: section titles, phase names, template prompts, example text, option lists, etc. > **⚠️ CRITICAL: Template localization is CLI-owned. Do NOT manually translate imported template content with the model. Use the `src/tracking/i18n` module as the source of truth by setting `AE_LANG=`, writing `draft.meta.lang`, and regenerating through `ae-cli tracking code import-template` / `ae-cli tracking plan draft`.** > **Before changing any template-owned localized label, first look up the corresponding translation in `src/tracking/i18n` (for example `resources/xlsx/sheets.ts`, `resources/xlsx/headers.ts`, `resources/xlsx/types.ts`, and `resources/cli/*.json`). If no matching translation exists there, preserve the imported text and ask before rewriting business semantics.** > Do NOT copy Chinese text verbatim from this document into English/Japanese replies unless it is an identifier, template name needed for CLI import, or original source material quoted for traceability. ## Terminology Glossary | 中文 | English | Notes | |------|---------|-------| | 埋点方案 | Tracking Plan | AE project-level event & property definitions | | 埋点模板 | Tracking Plan Template | Pre-built industry/genre xlsx templates | | 方案名称 | Plan Name | User-facing plan identifier | | 应用场景 | Application Scenario | One-sentence description of what the app does | | 素材来源 | Source Material Type | prd / chat / codebase / template / data | | 数据样本 / 文件画像 | Data Sample / File Profile | Column→property mapping source from an `ae-data-integration` inspect profile (`source_type: data`) | | 业务维度 | Business Dimension | Revenue model, core loop, functional entries, currency system | | 收入模型 | Revenue Model | IAA / IAP / mixed / subscription / commission | | 核心循环 | Core Loop | Core gameplay loop (e.g. "grind stages → earn coins → gacha for heroes") | | 功能入口 | Functional Entry | Stage, shop, guild, leaderboard, task, achievement, etc. | | 货币体系 | Currency System | Hard currency (diamonds), soft currency (gold), etc. | | 事件 | Event | Named user action or system occurrence (`event_name`) | | 事件属性 | Event Property | Data attached to an event (`prop_names`) | | 公共事件属性 | Common/Super Property | Property attached to every event automatically. ⚠️ The correct Chinese AE term is "公共事件属性" or "公共属性". Never translate "Super Property" as "超级属性" — that is NOT a valid AE term. | | 用户属性 | User Property | Property on the user profile (persistent state) | | 预置属性 | Preset Property | System property prefixed with `#` (`#device_id`, `#time`, etc.) | | 自动采集事件 | Auto-track Event | SDK auto-collected events (`ta_app_start`, `ta_page_show`, etc.) | | 系统事件 | System Event | event_tag value reserved for SDK auto-track events (`ta_*`). One of two non-module tags (together with 基础事件). | | 基础事件 | Basic | event_tag value for account-level lifecycle/progression events (register, login, level_up, create_role, etc.). Not tied to any functional module. | | 功能模块 | Functional Module | event_tag value for feature-specific business events; identifies which module the event belongs to (e.g. Battle, Shop, Ads, Payment, Basic) | | SDK 集成模式 | SDK Integration Mode | `client_only` / `server_only` / `both` / `none` | | 客户端平台 | Client Platform | Android, iOS, Web, Unity, Mini-program, etc. | | 服务端语言 | Server Language | Java, Python, Go, Node.js, PHP, etc. | | 用户体系 | User Identity System | distinct_id strategy + account_id source | | 访客 ID | Visitor ID / Distinct ID | Anonymous identity before login | | 账号 ID | Account ID | Identified user after login | | 插入 | Insert | Direct code injection into project | | 片段 | Snippet | Code delivered as standalone files | | 对象组 | Object Array (`array_row`) | `[{...}]` — variable-length list of related entities | | 对象 | Object (`object`) | `{...}` — fixed-structure single entity | | 校验 | Validation | Draft rule checking before xlsx generation | | 上传 | Upload | Pushing the xlsx tracking plan to AE | | 追加 | Append | Adding new events/properties to an existing plan | | 替换 | Replace | Deleting existing plan and uploading a new one | | 冲突检测 | Conflict Detection | Detecting type mismatches and duplicate events before upload | | 归档 | Archive | Copying final draft.xlsx to `plans/` directory | | xlsx 格式契约 | xlsx Format Contract | Column rules for AE-compatible Excel generation | | draft.json | draft.json | Internal intermediate representation (JSON) of the tracking plan | | display_name | Display Name | Human-readable name in the user's language | | event_tag | Event Tag | Functional module the event belongs to (e.g. Battle, Shop, Ads, Payment). Auto-track events use "System Event". | | snake_case | snake_case | Canonical naming format: `lowercase_with_underscores` | ## When to Trigger Trigger when user mentions: "tracking plan / tracking template / AE plan / help me create tracking" etc. App types covered: H5 / Web / iOS / Android / Mini-program / Unity. Follow strictly Phase 0 → 1 → 2 → 3 → 4, do not skip steps. > Phase 1 / 3 / 4 are executed via `ae-cli tracking` CLI (`ae-cli tracking plan draft` > / `ae-cli auth login` / `ae-cli tracking plan upload` / `ae-cli tracking plan delete`). > **All CLI commands must be prefixed with `AE_LANG=`** (e.g. `AE_LANG=en ae-cli tracking plan draft ...`), > ensuring CLI output messages and generated xlsx headers match the user's language. > Upload commands MUST also pass `--lang ` so the server parses the uploaded xlsx with the same sheet/header language. > > **Language rules**: For newly generated content, user-facing fields in draft.json (`display_name`, `event_desc`, `event_tag`, > property `display_name`, property `desc`, etc.) should be generated in the **user's input language**. > Every event, event property, common event property, and user property must have a non-empty `display_name`. > A canonical snake_case identifier is not a substitute for a user-facing display name. > For imported templates, do NOT translate those fields manually. Template sheet names, headers, property type display values, > CLI messages, and auto-track/i18n-owned labels must come from `src/tracking/i18n` via `AE_LANG=` and `draft.meta.lang`. > When a localized label is needed, inspect `src/tracking/i18n` and use the existing resource key/value; do not invent translations from the model. > If template business text needs localization and the CLI/i18n resources do not provide it, preserve the imported text and ask the user before rewriting business semantics. > Only identifier fields like `event_name`, `prop_name` remain in English. Property names are `snake_case`; event names are lowercase by default, uppercase only when the user asks to preserve it. > This skill only cares about command behavior, not internal implementation. --- ## Phase 0 — Anchor (one question per message) > **Step 1: Language initialization** > > Determine `` from user's input language: Chinese→`zh`, English→`en`, Japanese→`ja`, Korean→`ko`. Other languages default to `en`. > All subsequent CLI commands must be prefixed with `AE_LANG=` to ensure CLI output and generated xlsx headers match the user's language. > When uploading the xlsx, pass `--lang ` as well; it must match `draft.meta.lang` / the generated xlsx language. Collect the following **5 items** sequentially, **do NOT ask all at once**: ### Item 1 — Application Scenario Ask: **"What is your application's business scenario? One sentence summary, e.g.: An e-commerce website where users browse products and place orders"** After user responds, record to `meta.scenario` and generate `meta.plan_name`. ### Item 2 — Source Material + Business Dimension (combined) Before asking, decide whether the current runtime is an agent sandbox. The agent may judge this from runtime context such as sandbox-provisioned `cli-token.json`, restricted filesystem access, or absence of the user's local files. Do not ask the user just to decide sandbox visibility. Product document is available in sandbox environments **only for files that are readable inside the sandbox workspace**, including files the user attaches/uploads into the conversation workspace. It cannot read arbitrary local paths outside the sandbox unless those files are mounted or attached. Codebase is a local-material option and must be hidden in sandbox environments unless the codebase is already present in the readable workspace. When options are hidden, renumber the visible list contiguously from 1; never show skipped numbers. If **not** in a sandbox environment, ask exactly: ```text Choose your source material (up to 2): 1 - Product document (local path, image file, or folder) — Extract events and properties from product docs; supports md/pdf/docx/xlsx/pptx/URL/images (png/jpg/jpeg/webp) 2 - Detailed description (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc. 3 - Codebase (local project path; hidden in sandbox) — Analyze source code to extract events and properties 4 - Pre-built template (built-in industry and game genre templates) — Select a built-in template 5 - Modify existing tracking plan (local AE format xlsx file) — Import an existing tracking plan xlsx as baseline for modification; can be combined with Product doc / Description / Codebase, but NOT with Pre-built template 6 - Data sample / file profile (from ae-data-integration inspect) — Map data columns (CSV/Excel/JSONL) to events & properties from an inspect profile; single-source path, not combinable with other options Reply with number(s), e.g. 1,5 or 4. Select up to 2 (option 6 is single-source). ``` If in a sandbox environment, ask exactly: ```text Choose your source material (up to 2): 1 - Product document (sandbox workspace path, uploaded attachment, URL, image file, or folder) — Extract events and properties from product docs; supports md/pdf/docx/xlsx/pptx/URL/images (png/jpg/jpeg/webp). You can attach/upload relevant files here. 2 - Detailed description (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc. 3 - Pre-built template (built-in industry and game genre templates) — Select a built-in template 4 - Modify existing tracking plan (sandbox workspace path) — Import an existing tracking plan xlsx as baseline for modification; can be combined with Product doc / Description, but NOT with Pre-built template 5 - Data sample / file profile (from ae-data-integration inspect) — Map data columns (CSV/Excel/JSONL) to events & properties from an inspect profile; single-source path, not combinable with other options Reply with number(s), e.g. 1,4 or 3. Select up to 2 (option 5 is single-source). ``` Do not rewrite this source material list as unnumbered bullets, cards, or prose. The user must be able to reply with the visible numbers. When translating this prompt, preserve the numeric prefixes and line breaks exactly. Every visible option MUST be on its own line and MUST begin with `1 -`, `2 -`, `3 -`, etc. Never place two numbered options in the same paragraph or visual line. If a Markdown renderer may collapse soft line breaks, use Markdown hard line breaks (two trailing spaces before newline) rather than blank lines. Translation may change only the option text, not the numbering prefix or one-option-per-line structure. User can multi-select (max 2). Interpret numbers by the **visible list shown to the user**, not by the non-sandbox canonical list. Canonical source material options (non-sandbox numbering): 1. **Product document** ****(****local path, sandbox workspace path, uploaded attachment, URL, image file, or folder) — Extract events and properties from product docs; supports md/pdf/docx/xlsx/pptx/URL/images (png/jpg/jpeg/webp) 2. **Detailed description** (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc. 3. **Codebase** (local project path; hidden in sandbox) — Analyze source code to extract events and properties 4. **Pre-built template** (built-in industry and game genre templates) — Select a built-in template (run `AE_LANG= ae-cli tracking plan list-templates --json` to see available templates) Based on user selection, determine source material type and record to `meta.source_type`: | Selection | source_type | Handling | |---|---|---| | Product doc only | `prd` | Read product docs (text/images), extract events and properties | | Description only | `chat` | Construct events in Draft phase based on description | | Codebase only | `codebase` | Scan source code, extract events/properties from business logic | | Template only | `template` | Provide built-in template selection | | Existing plan only | `existing_plan` | Import xlsx as baseline (see "Modify Existing Tracking Plan Flow" below) | | Data sample only | `data` | Read the inspect profile (`ae-local-data-profile/v1`), map columns → events/properties (see "Data-path (source_type = data)" below) | | Any two-item combo | Join two types with `_` | First as baseline, second as supplement (priority: existing_plan → template → codebase → prd → chat) | | Existing plan + Pre-built template | **NOT allowed** | Both provide event baselines; semantic conflict | | Data sample + any other | **NOT allowed** | Data sample is a standalone single-source path | **Follow-up questions** (ask in follow-up order defined in Multi-Source Combination Rules below): - Product doc → if not in a sandbox environment, ask exactly: ```text What is the product document path? You can provide one or more items, separated by commas or newlines: 1. Local file path 2. URL 3. Image file path 4. Folder path ``` - Product doc → if in a sandbox environment, ask exactly: ```text What is the product document path? You can provide one or more items, separated by commas or newlines: 1. Sandbox workspace path 2. Uploaded attachment path 3. URL 4. Image file path 5. Folder path You can also attach/upload relevant files here, and I will read them from the sandbox workspace if available. ``` - Detailed description → If too vague, follow up on core features, user behaviors, business flows, monetization - Codebase → ask **"What is the project directory path?"**, then scan source to extract business logic - Pre-built template → display matching templates for user confirmation - Modify existing tracking plan → ask **"Please provide the xlsx file path of your existing tracking plan"**, then follow the flow below - Data sample → ask **"Please provide the path of the inspect profile JSON (or the run directory containing it)"**, then read the `ae-local-data-profile/v1` product and follow the "Data-path (source_type = data)" flow below **Modify Existing Tracking Plan Flow** (when user selects this option): 1. **Import**: Ask user for the file path, then immediately import: ```bash AE_LANG= ae-cli tracking code import-template --template --out .ae-cli/draft.json ``` 2. **Check result**: - If CLI errors (file not found / parse failure) → report error, ask user to fix the file and retry - If `draft.json` has `events` array empty → 🛑 **Severe: No AE-format sheets found** (missing `#` prefix sheets like `#事件数据`). Tell user the file does not appear to be an AE tracking plan xlsx. User must fix the original file and re-import. 3. **Content validation** (when events are non-empty): ```bash AE_LANG= ae-cli tracking plan validate --in .ae-cli/draft.json --fix ``` 4. **Handle validation results by severity**: - If validate passes with **no issues at all** → skip to Step 5. | Severity | Examples | Handling | User Action | |---|---|---|---| | 🔧 **Minor** (auto-fixable) | `display_name` duplicate, `array_row` sub-property inconsistency, event name duplicate | `--fix` auto-fixes, writes to `draft.json`. Inform user of what was fixed. | None (informed) | | ⚠️ **Medium** (needs confirmation) | property name snake_case violation, property name duplicate, invalid property type, nested property parent is not a composite type | List each issue with current value → suggested fix. User confirms item by item before writing to `draft.json`. | Confirm each fix | | 🛑 **Severe** | File cannot be parsed, or events array is empty after import | Reject. Tell user the specific issue. User fixes **original file** and re-imports. | Fix original file | **Medium issue confirmation format**: ``` ⚠️ The following content needs to be fixed: | # | Issue | Location | Current | Suggested | |---|-------|----------|---------|------------| | 1 | snake_case | event_name | UserLogin | user_login (keep UserLogin only if the user asked to preserve case) | | 2 | snake_case | prop_name | vipLevel | vip_level | | 3 | invalid type | property "level" | integer | number | Apply all suggested fixes? ok / specify per item / skip ``` - `ok` → apply all suggested fixes to `draft.json` - `specify per item` → confirm each item one by one - `skip` → keep current values, handle in Refine phase later ⚠️ **Never modify the user's original xlsx file.** All changes go into `draft.json`. 5. **Re-validate** after fixes → loop until clean, then continue to the next follow-up question (if combined with another source material), or Item 3 (if existing_plan is the only source). **Codebase analysis flow** (when source_type includes `codebase`): 1. User provides project directory path 2. Scan directory structure, identify tech stack (engine/framework/language) 3. Read core business modules (game logic, scene management, UI interaction, state/data models, networking/payment, etc.) 4. Extract from code: - **Events**: Player interaction actions (click/swipe/trigger), scene transitions, game state changes (start/pause/end), business flow nodes (purchase/upgrade/unlock) - **Event Properties**: Action parameters (bullet type/enemy level/item ID), state values (score/HP/coins), context (level ID/difficulty/mode) - **User Properties**: Persistent state (level/experience/VIP/cumulative spend) 5. Map extracted results to AE naming conventions (event names lowercase by default, uppercase only on request; property names `snake_case`; + `display_name` in user's language) 6. Confirm extracted results with user, supplement missing items **Business Dimension Confirmation**: After source material is confirmed, **must** process business dimension info based on source_type. User must explicitly confirm before proceeding. | source_type | Handling | |---|---| | `template` | Directly display template's inherited business dimensions; skip detailed inference | | `existing_plan` | Infer business dimensions from existing plan content (analyze event modules, payment events, currency properties); follow up on missing items; event injection preview | | `prd` / `codebase` / `chat` | Infer business dimensions → follow up on missing items → event injection preview | | Combo (e.g. `template_prd`) | See detailed rules below — baseline source's method is primary, supplementary source contributes additional context | **If source_type is template or starts with template_** (covers `template`, `template_prd`, `template_codebase`, `template_chat`): Display template's preset business dimensions: ``` Business Dimension (inherited from template: