ae-generate-tracking-plan

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ae-generate-tracking-plan

ae-generate-tracking-plan

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=<user_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.
对话语言:本技能文档为英文,但所有输出给用户的内容必须使用用户输入的语言。英文输入→英文回复;中文输入→中文回复;日文输入→日文回复。若不确定,默认使用英文。此规则适用于所有输出:章节标题、阶段名称、模板提示、示例文本、选项列表等。 ⚠️ 重要提示:模板本地化由CLI负责。请勿使用模型手动翻译导入的模板内容。通过设置
AE_LANG=<user_lang>
、编写
draft.meta.lang
并通过
ae-cli tracking code import-template
/
ae-cli tracking plan draft
重新生成,以
src/tracking/i18n
模块为唯一可信来源。
在更改任何模板所属的本地化标签之前,请先在
src/tracking/i18n
中查找对应的翻译(例如
resources/xlsx/sheets.ts
resources/xlsx/headers.ts
resources/xlsx/types.ts
resources/cli/*.json
)。如果没有找到匹配的翻译,请保留导入的文本,并在重写业务语义前询问用户。
除非是CLI导入所需的标识符、模板名称或为可追溯性引用的原始素材,否则请勿将本文档中的中文文本直接复制到英文/日文回复中。

Terminology Glossary

术语对照表

中文EnglishNotes
埋点方案Tracking PlanAE project-level event & property definitions
埋点模板Tracking Plan TemplatePre-built industry/genre xlsx templates
方案名称Plan NameUser-facing plan identifier
应用场景Application ScenarioOne-sentence description of what the app does
素材来源Source Material Typeprd / chat / codebase / template
业务维度Business DimensionRevenue model, core loop, functional entries, currency system
收入模型Revenue ModelIAA / IAP / mixed / subscription / commission
核心循环Core LoopCore gameplay loop (e.g. "grind stages → earn coins → gacha for heroes")
功能入口Functional EntryStage, shop, guild, leaderboard, task, achievement, etc.
货币体系Currency SystemHard currency (diamonds), soft currency (gold), etc.
事件EventNamed user action or system occurrence (
event_name
)
事件属性Event PropertyData attached to an event (
prop_names
)
公共事件属性Common/Super PropertyProperty 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 PropertyProperty on the user profile (persistent state)
预置属性Preset PropertySystem property prefixed with
#
(
#device_id
,
#time
, etc.)
自动采集事件Auto-track EventSDK auto-collected events (
ta_app_start
,
ta_page_show
, etc.)
系统事件System Eventevent_tag value reserved for SDK auto-track events (
ta_*
). One of two non-module tags (together with 基础事件).
基础事件Basicevent_tag value for account-level lifecycle/progression events (register, login, level_up, create_role, etc.). Not tied to any functional module.
功能模块Functional Moduleevent_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 PlatformAndroid, iOS, Web, Unity, Mini-program, etc.
服务端语言Server LanguageJava, Python, Go, Node.js, PHP, etc.
用户体系User Identity Systemdistinct_id strategy + account_id source
访客 IDVisitor ID / Distinct IDAnonymous identity before login
账号 IDAccount IDIdentified user after login
插入InsertDirect code injection into project
片段SnippetCode delivered as standalone files
对象组Object Array (
array_row
)
[{...}]
— variable-length list of related entities
对象Object (
object
)
{...}
— fixed-structure single entity
校验ValidationDraft rule checking before xlsx generation
上传UploadPushing the xlsx tracking plan to AE
追加AppendAdding new events/properties to an existing plan
替换ReplaceDeleting existing plan and uploading a new one
冲突检测Conflict DetectionDetecting type mismatches and duplicate events before upload
归档ArchiveCopying final draft.xlsx to
plans/
directory
xlsx 格式契约xlsx Format ContractColumn rules for AE-compatible Excel generation
draft.jsondraft.jsonInternal intermediate representation (JSON) of the tracking plan
display_nameDisplay NameHuman-readable name in the user's language
event_tagEvent TagFunctional module the event belongs to (e.g. Battle, Shop, Ads, Payment). Auto-track events use "System Event".
snake_casesnake_caseCanonical naming format:
lowercase_with_underscores
中文English说明
埋点方案Tracking PlanAE项目级事件与属性定义
埋点模板Tracking Plan Template预构建的行业/品类Excel模板
方案名称Plan Name用户可见的方案标识符
应用场景Application Scenario应用业务场景的一句话描述
素材来源Source Material Typeprd / chat / codebase / template
业务维度Business Dimension收入模型、核心循环、功能入口、货币体系
收入模型Revenue ModelIAA / IAP / mixed / subscription / commission
核心循环Core Loop核心业务流程(例如:"刷关卡→赚金币→抽卡获取英雄")
功能入口Functional Entry关卡、商店、公会、排行榜、任务、成就等
货币体系Currency System硬通货(钻石)、软通货(金币)等
事件Event命名的用户操作或系统行为(
event_name
事件属性Event Property附加到事件的数据(
prop_names
公共事件属性Common/Super Property自动附加到所有事件的属性。⚠️ AE官方中文术语为「公共事件属性」或「公共属性」,请勿将"Super Property"翻译为「超级属性」——这不是有效的AE术语。
用户属性User Property用户档案上的属性(持久化状态)
预置属性Preset Property
#
为前缀的系统属性(
#device_id
#time
等)
自动采集事件Auto-track EventSDK自动采集的事件(
ta_app_start
ta_page_show
等)
系统事件System Event为SDK自动采集事件保留的
event_tag
值(
ta_*
)。与「基础事件」同为非模块标签。
基础事件Basic账号全生命周期/成长事件(注册、登录、升级、创建角色等)的
event_tag
值,不绑定任何功能模块。
功能模块Functional Module特定功能业务事件的
event_tag
值,标识事件所属模块(例如:Battle、Shop、Ads、Payment、Basic)
SDK 集成模式SDK Integration Mode
client_only
/
server_only
/
both
/
none
客户端平台Client PlatformAndroid、iOS、Web、Unity、小程序等
服务端语言Server LanguageJava、Python、Go、Node.js、PHP等
用户体系User Identity Systemdistinct_id策略 + account_id来源
访客 IDVisitor ID / Distinct ID登录前的匿名身份
账号 IDAccount ID登录后的已识别用户身份
插入Insert直接将代码注入项目
片段Snippet以独立文件形式交付的代码
对象组Object Array (
array_row
)
[{...}]
— 可变长度的关联实体列表
对象Object (
object
)
{...}
— 固定结构的单个实体
校验Validation生成Excel前的草稿规则检查
上传Upload将Excel埋点方案推送到AE平台
追加Append向现有方案添加新的事件/属性
替换Replace删除现有方案并上传新方案
冲突检测Conflict Detection上传前检测类型不匹配和重复事件
归档Archive将最终draft.xlsx复制到
plans/
目录
xlsx 格式契约xlsx Format Contract兼容AE的Excel生成列规则
draft.jsondraft.json埋点方案的内部中间表示(JSON格式)
display_nameDisplay Name用户语言下的可读名称
event_tagEvent Tag事件所属的功能模块(例如:Battle、Shop、Ads、Payment)。自动采集事件使用"System Event"。
snake_casesnake_case标准命名格式:
小写字母加下划线

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=<user_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 <user_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=<user_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 snake_case (canonical format). This skill only cares about command behavior, not internal implementation.

当用户提及以下内容时触发:"tracking plan / tracking template / AE plan / help me create tracking"等。 支持的应用类型:H5 / Web / iOS / Android / 小程序 / Unity。严格遵循阶段0→1→2→3→4的流程,不得跳过步骤。
阶段1/3/4通过
ae-cli tracking
CLI执行(
ae-cli tracking plan draft
/
ae-cli auth login
/
ae-cli tracking plan upload
/
ae-cli tracking plan delete
)。 所有CLI命令必须添加
AE_LANG=<user_lang>
前缀
(例如:
AE_LANG=en ae-cli tracking plan draft ...
), 确保CLI输出信息和生成的Excel表头与用户语言一致。 上传命令还必须传递
--lang <user_lang>
,以便服务器使用相同的工作表/表头语言解析上传的Excel。
语言规则:对于新生成的内容,draft.json中面向用户的字段(
display_name
event_desc
event_tag
、 属性
display_name
、属性
desc
等)应使用用户输入的语言生成。 每个事件、事件属性、公共事件属性和用户属性必须包含非空的
display_name
。 标准snake_case标识符不能替代面向用户的显示名称。 对于导入的模板,请勿手动翻译这些字段。模板工作表名称、表头、属性类型显示值、 CLI消息以及自动采集/i18n所属标签必须通过
AE_LANG=<user_lang>
draft.meta.lang
src/tracking/i18n
获取。 当需要本地化标签时,检查
src/tracking/i18n
并使用现有资源键/值;不得通过模型自行生成翻译。 如果模板业务文本需要本地化但CLI/i18n资源未提供,请保留导入的文本并在重写业务语义前询问用户。 只有
event_name
prop_name
等标识符字段保留英文snake_case格式(标准格式)。 本技能仅关注命令行为,不涉及内部实现。

Phase 0 — Anchor (one question per message)

阶段0 — 锚点(每次消息一个问题)

Step 1: Language initialization
Determine
<user_lang>
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=<user_lang>
to ensure CLI output and generated xlsx headers match the user's language. When uploading the xlsx, pass
--lang <user_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:
步骤1:语言初始化
根据用户输入语言确定
<user_lang>
:中文→
zh
,英文→
en
,日文→
ja
,韩文→
ko
,其他语言默认
en
。 后续所有CLI命令必须添加
AE_LANG=<user_lang>
前缀,确保CLI输出和生成的Excel表头与用户语言一致。 上传Excel时,还需传递
--lang <user_lang>
;该值必须与
draft.meta.lang
/生成的Excel语言匹配。
按顺序收集以下5项信息不得一次性全部询问

Item 1 — Application Scenario

项1 — 应用场景

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
.
询问:"你的应用业务场景是什么?请用一句话概括,例如:用户可浏览商品并下单的电商网站"
用户回复后,记录到
meta.scenario
并生成
meta.plan_name

Item 2 — Source Material + Business Dimension (combined)

项2 — 素材来源 + 业务维度(合并询问)

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/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

Reply with number(s), e.g. 1,5 or 4. Select up to 2.
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/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

Reply with number(s), e.g. 1,4 or 3. Select up to 2.
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/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=<user_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
:
Selectionsource_typeHandling
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)
Any two-item comboJoin two types with
_
First as baseline, second as supplement (priority: existing_plan → template → codebase → prd → chat)
Existing plan + Pre-built templateNOT allowedBoth provide event baselines; semantic conflict
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
Modify Existing Tracking Plan Flow (when user selects this option):
  1. Import: Ask user for the file path, then immediately import:
    bash
    AE_LANG=<user_lang> ae-cli tracking code import-template --template <path> --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=<user_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.
    SeverityExamplesHandlingUser 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)snake_case violation, property name duplicate, invalid property type, nested property parent is not a composite typeList each issue with current value → suggested fix. User confirms item by item before writing to
    draft.json
    .
    Confirm each fix
    🛑 SevereFile cannot be parsed, or events array is empty after importReject. 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 |
    | 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 (
    snake_case
    event names +
    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_typeHandling
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: <template name>)

Revenue Model: <revenue_model>
Core Loop: <core_loop>
Functional Entries: <functional_entries>
Currency System: <currency_system>

Confirm using these business dimensions? ok / modify
  • User
    ok
    → proceed to next step
  • User says "modify" → switch to prd/chat flow for user to supplement
  • For combos (e.g.
    template_prd
    ): after confirming template dimensions, also note any supplementary insights from
    prd
    /
    chat
    as context for Phase 1.2.
If source_type includes existing_plan:
Infer business dimensions from the imported plan content:
  1. Analyze existing events: Examine
    event_tag
    values to identify functional modules (e.g. events tagged "Battle" → 战斗 module). Examine event names for payment/ad-related patterns to infer revenue model.
  2. Inference display: Format inference results as a summary:
    Business Dimension (inferred from existing plan: <filename>)
    
    Revenue Model: <inferred from payment/ad events>
    Core Loop: <inferred from event flow>
    Functional Entries: <inferred from event_tag values>
    Currency System: <inferred from currency-related properties>
    
    Confirm these business dimensions? ok / modify
  3. Follow up missing: Only ask about items that could not be inferred
  4. Event injection preview: Show suggested injected event modules (only add events not already in the plan); user
    ok
    to proceed
  • For combos (e.g.
    existing_plan_prd
    ): after confirming dimensions from the plan, also note any supplementary insights from
    prd
    /
    chat
    as context for Phase 1.2.
If source_type is prd / codebase / chat:
  1. Inference display: Format inference results as a summary, using
    business-dimension-mapping.md
    as the mapping baseline
  2. Follow up missing: Only ask about missing items or items inferred as "simple"
  3. Event injection preview: Show suggested injected event modules; user
    ok
    to proceed
Platform validation: Use
business-dimension-mapping.md
Chapter 5 decision rules to check if injected events' platform assignments are reasonable.
Template matching (prd / codebase / chat scenarios, optional; NOT applicable to existing_plan or template scenarios):
After business dimension confirmation, auto-detect matching templates based on app type:
bash
AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
Show matching templates to user for confirmation. Confirmed templates serve as baseline and participate in Phase 1 event merging.
询问前,判断当前运行环境是否为Agent沙箱。Agent可通过运行时上下文判断,例如沙箱提供的
cli-token.json
、受限的文件系统访问权限或用户本地文件不存在等。不得仅为判断沙箱可见性而询问用户。
产品文档仅在沙箱环境中对沙箱工作区内可读的文件可用,包括用户附加/上传到对话工作区的文件。除非文件已挂载或附加,否则无法读取沙箱外的任意本地路径。代码库是本地素材选项,除非代码库已存在于可读工作区,否则在沙箱环境中必须隐藏。当选项被隐藏时,将可见列表重新从1开始连续编号;不得显示跳过的编号。
如果不在沙箱环境中,严格按以下内容询问:
text
选择你的素材来源(最多选2项):

1 - 产品文档(本地路径、图片文件或文件夹)—— 从产品文档中提取事件和属性;支持md/pdf/docx/URL/图片(png/jpg/jpeg/webp)
2 - 详细描述(对话式)—— 描述应用业务流程、核心功能、用户行为、变现模型等
3 - 代码库(本地项目路径;沙箱环境中隐藏)—— 分析源代码提取事件和属性
4 - 预构建模板(内置行业和游戏品类模板)—— 选择内置模板
5 - 修改现有埋点方案(本地AE格式Excel文件)—— 导入现有埋点方案Excel作为修改基准;可与产品文档/描述/代码库组合,但**不可**与预构建模板组合

请回复编号,例如:1,5 或 4。最多选2项。
如果在沙箱环境中,严格按以下内容询问:
text
选择你的素材来源(最多选2项):

1 - 产品文档(沙箱工作区路径、上传的附件、URL、图片文件或文件夹)—— 从产品文档中提取事件和属性;支持md/pdf/docx/URL/图片(png/jpg/jpeg/webp)。你可在此附加/上传相关文件。
2 - 详细描述(对话式)—— 描述应用业务流程、核心功能、用户行为、变现模型等
3 - 预构建模板(内置行业和游戏品类模板)—— 选择内置模板
4 - 修改现有埋点方案(沙箱工作区路径)—— 导入现有埋点方案Excel作为修改基准;可与产品文档/描述组合,但**不可**与预构建模板组合

请回复编号,例如:1,4 或 3。最多选2项。
不得将此素材来源列表改写为无序列表、卡片或散文形式。用户必须能够通过回复可见编号进行选择。 翻译此提示时,严格保留数字前缀和换行符。每个可见选项必须单独占一行,且必须以
1 -
2 -
3 -
等开头。不得将两个编号选项放在同一段落或同一视觉行中。如果Markdown渲染器可能折叠软换行,请使用Markdown硬换行(换行前添加两个空格)而非空行。仅可修改选项文本,不得修改编号前缀或每行一个选项的结构。
用户可多选(最多2项)。根据显示给用户的可见列表而非非沙箱环境的标准列表来解读编号。
标准素材选项(非沙箱环境编号):
  1. 产品文档(本地路径、沙箱工作区路径、上传的附件、URL、图片文件或文件夹)—— 从产品文档中提取事件和属性;支持md/pdf/docx/URL/图片(png/jpg/jpeg/webp)
  2. 详细描述(对话式)—— 描述应用业务流程、核心功能、用户行为、变现模型等
  3. 代码库(本地项目路径;沙箱环境中隐藏)—— 分析源代码提取事件和属性
  4. 预构建模板(内置行业和游戏品类模板)—— 选择内置模板(运行
    AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
    查看可用模板)
根据用户选择,确定素材类型并记录到
meta.source_type
选择source_type处理方式
仅产品文档
prd
读取产品文档(文本/图片),提取事件和属性
仅详细描述
chat
在草稿阶段根据描述构建事件
仅代码库
codebase
扫描源代码,从业务逻辑中提取事件/属性
仅模板
template
提供内置模板选择
仅现有方案
existing_plan
导入Excel作为基准(见下文「修改现有埋点方案流程」)
任意两项组合
_
连接两种类型
前者为基准,后者为补充(优先级:existing_plan → template → codebase → prd → chat)
现有方案 + 预构建模板不允许两者均提供事件基准,存在语义冲突
跟进问题(按「多源组合规则」中定义的跟进顺序询问):
  • 产品文档 → 若不在沙箱环境中,严格按以下内容询问:
    text
    产品文档路径是什么?
    
    你可提供一个或多个条目,用逗号或换行分隔:
    1. 本地文件路径
    2. URL
    3. 图片文件路径
    4. 文件夹路径
  • 产品文档 → 若在沙箱环境中,严格按以下内容询问:
    text
    产品文档路径是什么?
    
    你可提供一个或多个条目,用逗号或换行分隔:
    1. 沙箱工作区路径
    2. 上传的附件路径
    3. URL
    4. 图片文件路径
    5. 文件夹路径
    
    你也可在此附加/上传相关文件,我将从沙箱工作区读取(如果可用)。
  • 详细描述 → 若描述过于模糊,跟进询问核心功能、用户行为、业务流程、变现方式
  • 代码库 → 询问**「项目目录路径是什么?」**,然后扫描源代码提取业务逻辑
  • 预构建模板 → 展示匹配的模板供用户确认
  • 修改现有埋点方案 → 询问**「请提供现有埋点方案的Excel文件路径」**,然后遵循以下流程
修改现有埋点方案流程(当用户选择此选项时):
  1. 导入:询问用户文件路径,然后立即导入:
    bash
    AE_LANG=<user_lang> ae-cli tracking code import-template --template <path> --out .ae-cli/draft.json
  2. 检查结果
    • 若CLI报错(文件未找到/解析失败)→ 报告错误,要求用户修复文件并重试
    • draft.json
      events
      数组为空 → 🛑 严重问题:未找到AE格式工作表(缺少
      #
      前缀的工作表,如
      #事件数据
      )。告知用户该文件似乎不是AE埋点方案Excel。用户必须修复原始文件后重新导入。
  3. 内容校验(当事件非空时):
    bash
    AE_LANG=<user_lang> ae-cli tracking plan validate --in .ae-cli/draft.json --fix
  4. 按严重程度处理校验结果
    • 若校验完全通过 → 跳过步骤5。
    严重程度示例处理方式用户操作
    🔧 轻微(可自动修复)
    display_name
    重复、
    array_row
    子属性不一致、事件名称重复
    --fix
    自动修复,写入
    draft.json
    。告知用户修复内容。
    无需操作(仅告知)
    ⚠️ 中等(需确认)snake_case规则违反、属性名称重复、无效属性类型、嵌套属性父级非复合类型列出每个问题的当前值→建议修复方案。用户逐项确认后写入
    draft.json
    确认每项修复
    🛑 严重文件无法解析,或导入后events数组为空拒绝导入。告知用户具体问题。用户修复原始文件后重新导入。修复原始文件
    中等问题确认格式
    ⚠️ 以下内容需要修复:
    
    | # | 问题 | 位置 | 当前值 | 建议值 |
    |---|-------|----------|---------|------------|
    | 1 | snake_case规则违反 | event_name | UserLogin | user_login |
    | 2 | snake_case规则违反 | prop_name | vipLevel | vip_level |
    | 3 | 无效类型 | 属性"level" | integer | number |
    
    是否应用所有建议修复?ok / 逐项确认 / 跳过
    • ok
      → 将所有建议修复应用到
      draft.json
    • 逐项确认
      → 逐项确认每个问题
    • 跳过
      → 保留当前值,后续在优化阶段处理
    ⚠️ 不得修改用户的原始Excel文件。所有更改均写入
    draft.json
  5. 修复后重新校验 → 循环直至无问题,然后继续跟进下一个问题(若与其他素材来源组合),或进入项3(若仅选择现有方案)。
代码库分析流程(当source_type包含
codebase
时):
  1. 用户提供项目目录路径
  2. 扫描目录结构,识别技术栈(引擎/框架/语言)
  3. 读取核心业务模块(游戏逻辑、场景管理、UI交互、状态/数据模型、网络/支付等)
  4. 从代码中提取:
    • 事件:玩家交互操作(点击/滑动/触发)、场景切换、游戏状态变化(开始/暂停/结束)、业务流程节点(购买/升级/解锁)
    • 事件属性:操作参数(子弹类型/敌人等级/物品ID)、状态值(得分/生命值/金币)、上下文(关卡ID/难度/模式)
    • 用户属性:持久化状态(等级/经验/VIP/累计消费)
  5. 将提取结果映射到AE命名规范(
    snake_case
    事件名称 + 用户语言的
    display_name
  6. 与用户确认提取结果,补充缺失项
业务维度确认
确认素材来源后,必须根据source_type处理业务维度信息。用户必须明确确认后才能继续。
source_type处理方式
template
直接展示模板继承的业务维度;跳过详细推导
existing_plan
从现有方案内容推导业务维度(分析事件模块、支付事件、货币属性);跟进缺失项;事件注入预览
prd
/
codebase
/
chat
推导业务维度→跟进缺失项→事件注入预览
组合(例如
template_prd
见下文详细规则——基准素材的方法为主,补充素材提供额外上下文
若source_type为template或以template_开头(涵盖
template
template_prd
template_codebase
template_chat
):
展示模板预设的业务维度:
业务维度(继承自模板:<模板名称>)

收入模型:<revenue_model>
核心循环:<core_loop>
功能入口:<functional_entries>
货币体系:<currency_system>

是否确认使用这些业务维度?ok / 修改
  • 用户回复
    ok
    → 进入下一步
  • 用户回复"修改" → 切换到prd/chat流程,让用户补充信息
  • 对于组合类型(例如
    template_prd
    ):确认模板维度后,还需记录
    prd
    /
    chat
    提供的补充洞察,作为阶段1.2的上下文。
若source_type包含existing_plan
从导入的方案内容推导业务维度:
  1. 分析现有事件:检查
    event_tag
    值识别功能模块(例如:标记为"Battle"的事件→战斗模块)。检查事件名称中的支付/广告相关模式推导收入模型。
  2. 推导结果展示:将推导结果格式化为摘要:
    业务维度(从现有方案推导:<文件名>)
    
    收入模型:<从支付/广告事件推导>
核心循环:<从事件流推导> 功能入口:<从event_tag值推导> 货币体系:<从货币相关属性推导>
是否确认这些业务维度?ok / 修改
3. **跟进缺失项**:仅询问无法推导的项
4. **事件注入预览**:展示建议注入的事件模块(仅添加方案中未有的事件);用户回复`ok`后继续
- 对于组合类型(例如`existing_plan_prd`):确认方案维度后,还需记录`prd`/`chat`提供的补充洞察,作为阶段1.2的上下文。

**若source_type为prd / codebase / chat**:

1. **推导结果展示**:以`business-dimension-mapping.md`为映射基准,将推导结果格式化为摘要
2. **跟进缺失项**:仅询问缺失项或推导为"简单"的项
3. **事件注入预览**:展示建议注入的事件模块;用户回复`ok`后继续

平台校验:使用`business-dimension-mapping.md`第5章的决策规则检查注入事件的平台分配是否合理。

**模板匹配**(prd / codebase / chat场景,可选;**不适用于existing_plan或template场景**):

确认业务维度后,根据应用类型自动检测匹配的模板:
```bash
AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
向用户展示匹配的模板供确认。确认后的模板作为基准参与阶段1的事件合并。

Multi-Source Combination Rules (when user selects 2 source materials)

多源组合规则(当用户选择2项素材来源时)

Follow-up Order (Phase 0 questioning sequence):
Do not follow user's selection order. Instead, use this order:
existing_plan(blocking validation, always first)→ codebase/prd(user's selection order)→ chat → template
Rationale:
  • existing_plan
    must go first — import + validate may require the user to fix their file; processing it early avoids wasted context
  • codebase
    /
    prd
    — directly reflect actual business requirements, prioritized over generic descriptions and templates
  • chat
    — conversational description, supplements business context
  • template
    — generic industry template, least specific to the user's business
Source material processing happens primarily in Phase 1.2 (Merge Source Materials). The one exception is
existing_plan
: it is imported and validated in Phase 0 because user-provided files may need fixing before proceeding. All other sources are processed in Phase 1.2 per their standard flow.
Merge priority (Phase 1.2):
existing_plan → template → codebase → prd → chat → autotrack
Earlier sources take precedence — same-name events keep the earlier version, later sources only add new events or merge
prop_names
without overwriting.
Business Dimension Inference (combined scenarios):
Use the baseline source's inference method as primary. Supplementary sources (especially prd/chat) may contribute additional information — present a merged view for user confirmation.
Valid Combinations:
The "Baseline" column identifies which source has higher merge priority (see Phase 1.2 merge order), which may differ from the user's selection order. Follow-up questioning uses the fixed order in "Multi-Source Combination Rules" above, not the user's selection order.
BaselineSupplementaryPhase 0 for supplementary
existing_plancodebaseCollect path + quick tech stack detection
existing_planprdCollect path
existing_planchatCollect description; participates in dimension inference
templatecodebaseCollect path + quick tech stack detection; template matching/import deferred to Phase 1.2
templateprdCollect path; template matching/import deferred to Phase 1.2
templatechatCollect description
codebaseprdCollect path
codebasechatCollect description
prdchatCollect description
codebasetemplateSame as template+codebase row above (template is baseline per merge priority)
prdtemplateSame as template+prd row above (template is baseline per merge priority)
Forbidden:
existing_plan + template
(both provide event baselines; semantic conflict).
Record business dimension info to
meta.business_dimension
:
json
"business_dimension": {
  "revenue_model": "<model>",
  "core_loop": "<description>",
  "functional_entries": ["<entry list>"],
  "currency_system": { ... },
  "ad_scenes": [],
  "iap_items": []
}
跟进顺序(阶段0询问顺序):
不要遵循用户的选择顺序,而是使用以下顺序:
existing_plan(阻塞式校验,始终优先)→ codebase/prd(用户选择顺序)→ chat → template
理由:
  • existing_plan
    必须优先处理——导入+校验可能需要用户修复文件;提前处理可避免浪费上下文
  • codebase
    /
    prd
    ——直接反映实际业务需求,优先级高于通用描述和模板
  • chat
    ——对话式描述,补充业务上下文
  • template
    ——通用行业模板,对用户业务的针对性最弱
素材处理主要在阶段1.2(合并素材来源)进行。唯一例外是
existing_plan
:它在阶段0导入并校验,因为用户提供的文件可能需要修复后才能继续。所有其他素材均按标准流程在阶段1.2处理。
合并优先级(阶段1.2):
existing_plan → template → codebase → prd → chat → autotrack
优先级高的素材优先——同名事件保留优先级高的版本,优先级低的素材仅添加新事件或合并
prop_names
而不覆盖。
业务维度推导(组合场景)
以基准素材的推导方法为主。补充素材(尤其是prd/chat)可提供额外信息——展示合并后的视图供用户确认。
有效组合
「基准」列标识哪个素材具有更高的合并优先级(见阶段1.2合并顺序),可能与用户选择顺序不同。跟进询问使用「多源组合规则」中的固定顺序,而非用户选择顺序。
基准补充补充素材的阶段0处理
existing_plancodebase收集路径+快速技术栈检测
existing_planprd收集路径
existing_planchat收集描述;参与维度推导
templatecodebase收集路径+快速技术栈检测;模板匹配/导入延迟到阶段1.2
templateprd收集路径;模板匹配/导入延迟到阶段1.2
templatechat收集描述
codebaseprd收集路径
codebasechat收集描述
prdchat收集描述
codebasetemplate与上方template+codebase行相同(按合并优先级,template为基准)
prdtemplate与上方template+prd行相同(按合并优先级,template为基准)
禁止组合
existing_plan + template
(两者均提供事件基准,存在语义冲突)。
将业务维度信息记录到
meta.business_dimension
json
"business_dimension": {
  "revenue_model": "<model>",
  "core_loop": "<description>",
  "functional_entries": ["<entry list>"],
  "currency_system": { ... },
  "ad_scenes": [],
  "iap_items": []
}

Item 3 — SDK Integration Config (client + server combined)

项3 — SDK集成配置(客户端+服务端合并)

Ask: "What is your client platform? (multi-select OK, e.g. Android + iOS) Will you integrate a server-side SDK?"
After asking this Item 3 question, stop and wait for the user's answer. Do not display Item 4 in the same response.
Language filter: The following SDKs have Chinese-only documentation and are visible to Chinese users only:
Mini-program
,
Mini-game
,
OpenHarmony
,
LayaAir
,
Egret
,
Cocos2d-Lua
. Do not show these to non-Chinese users.
Client integration (multi-select OK):
OptionClient SDK Type
H5/Web AppJavaScript SDK
Mobile Game - Android NativeAndroid SDK
Mobile Game - iOS NativeiOS SDK
Mobile Game - UnityUnity SDK
Mobile Game - CocosCreatorCocosCreator SDK
Mobile Game - Cocos2d-xCocos2d-x SDK
Mobile Game - Cocos2d-LuaCocos2d-Lua SDK
Mobile Game - LayaAirLayaAir SDK
Mobile Game - EgretEgret SDK
Mobile Game - UnrealUnreal SDK
Mobile App - Android NativeAndroid SDK
Mobile App - iOS NativeiOS SDK
Mobile App - React NativeReact Native SDK
Mobile App - FlutterFlutter SDK
Mobile App - uni-appuni-app SDK
Mobile App - OpenHarmonyOpenHarmony SDK
Mini-gameMini-game SDK (unified, supports WeChat/QQ/TikTok/Baidu, etc.)
Mini-programMini-program SDK (unified, supports WeChat/TikTok/Alipay/Baidu, etc.)
PC Game - UnrealUnreal SDK
PC Game - UnityUnity SDK
PC App - C++C++ SDK
PC App - C#C# SDK
PC App - macOS NativemacOS SDK
PC App - OpenHarmonyOpenHarmony SDK
No client SDKNone (
sdk_integration_mode: "server_only"
)
Programming language (Android / iOS SDK only):
SDK TypeSupported Languages
Android SDKJava / Kotlin (can multi-select)
iOS SDKObjective-C / Swift (can multi-select)
Other SDKsFixed language, no selection needed
Follow-up: chose Android SDK → ask "Which programming language? Java / Kotlin / both" Follow-up: chose iOS SDK → ask "Which programming language? Objective-C / Swift / both"
Record to
client_platform_languages
:
json
"client_platform_languages": {
  "android": ["java", "kotlin"],
  "openharmony": ["typescript"]
}
⚠️ Multi-platform meta field rules: When ≥2 client platforms are selected, Draft meta must use
client_platforms
(array) +
client_platform_languages
(dictionary). Do NOT use only
client_sdk_type
(single value) +
client_language
(single value), which would only record one platform. Single-platform scenarios use
client_sdk_type
+
client_language
.
Server integration:
OptionServer SDK Typesdk_integration_mode
JavaJava SDK
both
PythonPython SDK
both
GoGo SDK
both
Node.jsNode SDK
both
PHPPHP SDK
both
C# / .NETC# SDK
both
C++C++ SDK
both
ErlangErlang SDK
both
LuaLua SDK
both
RubyRuby SDK
both
OtherFollow up on specific language; check wiki for SDK availability
both
No server SDKNone
client_only
or
none
SDK integration mode auto-detection:
Client IntegrationServer Integrationsdk_integration_mode
YesYes
both
YesNo
client_only
NoYes
server_only
NoNo
none
(RESTful / LogBus / DataX data ingestion)
none
mode: Suitable for historical data import, batch data sync, third-party system integration, etc. Refine phase does not inject SDK auto-track events.
Item 3 confirmation gate:
After the user answers Item 3, normalize the SDK configuration and ask only the missing follow-up questions (for Android/iOS programming language or
Other
server language).
Then summarize the normalized SDK config and ask: "Confirm this SDK integration config? Reply ok to continue to Item 4, or describe changes."
Do not display Item 4 or ask identity questions until the user explicitly confirms this SDK integration config.
询问:「你的客户端平台是什么?(可多选,例如:Android + iOS)是否要集成服务端SDK?」
询问此项后,停止并等待用户回复。不得在同一回复中展示项4。
语言过滤:以下SDK仅提供中文文档,仅对中文用户可见
Mini-program
Mini-game
OpenHarmony
LayaAir
Egret
Cocos2d-Lua
。不得向非中文用户展示这些选项。
客户端集成(可多选):
选项客户端SDK类型
H5/Web AppJavaScript SDK
移动游戏 - Android原生Android SDK
移动游戏 - iOS原生iOS SDK
移动游戏 - UnityUnity SDK
移动游戏 - CocosCreatorCocosCreator SDK
移动游戏 - Cocos2d-xCocos2d-x SDK
移动游戏 - Cocos2d-LuaCocos2d-Lua SDK
移动游戏 - LayaAirLayaAir SDK
移动游戏 - EgretEgret SDK
移动游戏 - UnrealUnreal SDK
移动应用 - Android原生Android SDK
移动应用 - iOS原生iOS SDK
移动应用 - React NativeReact Native SDK
移动应用 - FlutterFlutter SDK
移动应用 - uni-appuni-app SDK
移动应用 - OpenHarmonyOpenHarmony SDK
小游戏小游戏SDK(统一版,支持微信/QQ/抖音/百度等)
小程序小程序SDK(统一版,支持微信/抖音/支付宝/百度等)
PC游戏 - UnrealUnreal SDK
PC游戏 - UnityUnity SDK
PC应用 - C++C++ SDK
PC应用 - C#C# SDK
PC应用 - macOS原生macOS SDK
PC应用 - OpenHarmonyOpenHarmony SDK
无客户端SDKNone(
sdk_integration_mode: "server_only"
编程语言(仅Android / iOS SDK):
SDK类型支持语言
Android SDKJava / Kotlin(可多选)
iOS SDKObjective-C / Swift(可多选)
其他SDK固定语言,无需选择
跟进:若选择Android SDK → 询问**「使用哪种编程语言?Java / Kotlin / 两者都用」** 跟进:若选择iOS SDK → 询问**「使用哪种编程语言?Objective-C / Swift / 两者都用」**
记录到
client_platform_languages
json
"client_platform_languages": {
  "android": ["java", "kotlin"],
  "openharmony": ["typescript"]
}
⚠️ 多平台元字段规则:当选择≥2个客户端平台时,草稿元数据必须使用
client_platforms
(数组)+
client_platform_languages
(字典)。不得仅使用
client_sdk_type
(单个值)+
client_language
(单个值),否则仅能记录一个平台。单平台场景使用
client_sdk_type
+
client_language
服务端集成
选项服务端SDK类型sdk_integration_mode
JavaJava SDK
both
PythonPython SDK
both
GoGo SDK
both
Node.jsNode SDK
both
PHPPHP SDK
both
C# / .NETC# SDK
both
C++C++ SDK
both
ErlangErlang SDK
both
LuaLua SDK
both
RubyRuby SDK
both
其他跟进询问具体语言;查看wiki确认SDK可用性
both
无服务端SDKNone
client_only
none
SDK集成模式自动检测
客户端集成服务端集成sdk_integration_mode
both
client_only
server_only
none
(RESTful / LogBus / DataX数据导入)
none
模式:适用于历史数据导入、批量数据同步、第三方系统集成等。优化阶段不注入SDK自动采集事件。
项3确认环节
用户回复项3后,标准化SDK配置并仅询问缺失的跟进问题(Android/iOS编程语言或
Other
服务端语言)。
然后总结标准化后的SDK配置并询问:「确认此SDK集成配置?回复ok继续到项4,或描述修改内容。」
在用户明确确认此SDK集成配置前,不得展示项4或询问身份相关问题。

Item 4 — User Identity System (visitor ID + account ID combined)

项4 — 用户身份体系(访客ID + 账号ID合并)

Ask: "What is the visitor ID generation strategy?"
Options:
  • auto
    — SDK auto-generates (default, suitable for most scenarios)
  • device_id
    — Use device ID (iOS IDFV / Android AndroidID)
  • custom
    — Custom visitor ID (must call
    identify()
    immediately after SDK init)
Follow-up: chose
custom
→ ask "What value should the visitor ID use? e.g.: device ID / UUID / guest temp ID"

Ask: "What is the account ID source?"
Options:
  • user_account
    — User account ID (unique identifier after login)
  • role_id
    — Role ID (game-specific; one account may have multiple roles)
  • none
    — No account system (pure guest mode)
Follow-up:
  • chose
    user_account
    → ask "What specific value for account ID? e.g.: user_id (user ID), phone (phone number), email (email address)"
  • chose
    role_id
    → explain "Role ID is suitable for games — one account can create multiple roles, enabling finer-grained per-role behavior analysis"
Record to
meta.user_identity
:

询问:「访客ID生成策略是什么?」
选项:
  • auto
    — SDK自动生成(默认,适用于大多数场景)
  • device_id
    — 使用设备ID(iOS IDFV / Android AndroidID)
  • custom
    — 自定义访客ID(必须在SDK初始化后立即调用
    identify()
跟进:若选择
custom
→ 询问**「访客ID应使用什么值?例如:设备ID / UUID / 临时游客ID」**

询问:「账号ID来源是什么?」
选项:
  • user_account
    — 用户账号ID(登录后的唯一标识符)
  • role_id
    — 角色ID(游戏专用;一个账号可拥有多个角色)
  • none
    — 无账号体系(纯游客模式)
跟进:
  • 若选择
    user_account
    → 询问**「账号ID的具体值是什么?例如:user_id(用户ID)、phone(手机号)、email(邮箱)」**
  • 若选择
    role_id
    → 说明**「角色ID适用于游戏场景——一个账号可创建多个角色,支持更细粒度的单角色行为分析」**
记录到
meta.user_identity

Phase 1 — Draft

阶段1 — 草稿

1.1 Construct Canonical Draft

1.1 构建标准草稿

Draft conceptual structure (internal JSON; users do not view directly):
Draft
├── meta:
│   ├── app_type:                   App type
│   ├── sdk_integration_mode:       SDK integration mode: client_only / server_only / both
│   ├── client_platforms?:          Client SDK type list (required when multi-platform, e.g. ["android","ios"])
│   ├── client_sdk_type?:           Primary client SDK type (single platform, backward compatible)
│   ├── client_platform_languages?: Per-platform languages (required when multi-platform, e.g. {"android":["kotlin"],"ios":["swift"]})
│   ├── client_language?:           Client dev language (single platform, backward compatible)
│   ├── server_language?:           Server dev language (only when server_only or both)
│   ├── project_id?:                AE project ID (filled in Phase 3)
│   ├── host?:                      AE web address (filled in Phase 3)
│   ├── plan_name:                  Plan name
│   ├── lang:                       xlsx output language (zh/en/ja/ko), based on user's current language; controls generated xlsx headers/sheet names
│   ├── scenario:                   Business scenario description
│   ├── source_type:                Source material type
│   ├── user_identity:              User identity config
│   │   ├── account_id_source:      Account ID source: user_account / role_id / none
│   │   ├── account_id_field?:      Account ID field name (only when user_account, e.g. user_id / phone / email)
│   │   ├── distinct_id_strategy:   Visitor ID strategy: auto / device_id / custom
│   │   └── distinct_id_custom_value?: Custom visitor ID value
│   └── business_dimension:         Business dimension config (injected in Phase 1.3)
│       ├── revenue_model:          Revenue model: IAA / IAP / mixed / subscription / commission
│       ├── core_loop:              Core gameplay loop description
│       ├── functional_entries:     Functional entry list
│       ├── currency_system:        Currency system
│       ├── ad_scenes:              Ad scenes (IAA / mixed only)
│       └── iap_items:              IAP items (IAP / mixed only)
├── events:                         Event array, each with platform field
├── event_properties:               Global event property pool (deduplicated)
├── common_event_properties:        Common/super properties (attached to every event)
└── user_properties:                User properties
SDK integration mode fields:
json
// Multi-platform example (Android + iOS)
{
  "sdk_integration_mode": "both",       // client_only / server_only / both
  "client_platforms": ["android", "ios"],   // Required for multi-platform
  "client_platform_languages": {            // Required for multi-platform; per-platform languages
    "android": ["kotlin"],
    "ios": ["swift"]
  },
  "server_language": "java"                // Only when server_only or both
}

// Single platform example (backward compatible)
{
  "sdk_integration_mode": "client_only",
  "client_sdk_type": "android",            // Single platform
  "client_language": "kotlin"              // Single platform
}
Event platform tag (
events[].platform
)
:
json
{
  "event_name": "order_create",
  "display_name": "Order Create",
  "platform": "server",    // client / server / both
  "prop_names": ["order_id", "order_amount", "payment_method"],
  "source": "prd"
}
  • platform: "client"
    — Client-side upload (user behavior events)
  • platform: "server"
    — Server-side upload (business data events)
  • platform: "both"
    — Both sides upload (timestamps must be synced)
Property object format (
event_properties
/
common_event_properties
pool entries)
:
json
{
  "name": "order_amount",
  "display_name": "Order Amount",
  "type": "number",
  "desc": "Order total in cents",
  "source": "prd"
}
⚠️ Field names: use
name
(NOT
prop_name
),
display_name
,
type
,
desc
,
source
. Events reference properties by
prop_names: ["order_amount", ...]
— this is an array of property
name
references (string array), NOT property objects.
User property format (
user_properties
pool entries)
:
json
{
  "name": "vip_level",
  "display_name": "VIP Level",
  "type": "number",
  "desc": "Current VIP level of the user",
  "source": "chat",
  "update_type": "user_set"
}
update_type
is one of:
user_set
(overwrite),
user_setOnce
(first-set-only),
user_add
(numeric accumulate).
User identity fields (
meta.user_identity
)
:
json
{
  "account_id_source": "user_account", // Account ID source: user_account / role_id / none
  "account_id_field": "user_id",       // Account ID field name (only when user_account)
  "distinct_id_strategy": "auto",      // Visitor ID strategy: auto / device_id / custom
  "distinct_id_custom_value": null     // Custom visitor ID value description (only when strategy=custom)
}
Property types (enum):
string
/
number
/
bool
/
datetime
/
object
(single object, with sub-properties) /
array_row
(object array, supports
parent.child
nesting) /
array_string
(string array)
Naming rules: Event names / property names must be
snake_case
; use
display_name
field for human-readable names.
草稿概念结构(内部JSON;用户不可直接查看):
Draft
├── meta:
│   ├── app_type:                   应用类型
│   ├── sdk_integration_mode:       SDK集成模式:client_only / server_only / both
│   ├── client_platforms?:          客户端SDK类型列表(多平台时必填,例如["android","ios"])
│   ├── client_sdk_type?:           主客户端SDK类型(单平台,向后兼容)
│   ├── client_platform_languages?: 各平台语言(多平台时必填,例如{"android":["kotlin"],"ios":["swift"]})
│   ├── client_language?:           客户端开发语言(单平台,向后兼容)
│   ├── server_language?:           服务端开发语言(仅server_only或both模式)
│   ├── project_id?:                AE项目ID(阶段3填充)
│   ├── host?:                      AE网页地址(阶段3填充)
│   ├── plan_name:                  方案名称
│   ├── lang:                       Excel输出语言(zh/en/ja/ko),基于用户当前语言;控制生成的Excel表头/工作表名称
│   ├── scenario:                   业务场景描述
│   ├── source_type:                素材类型
│   ├── user_identity:              用户身份配置
│   │   ├── account_id_source:      账号ID来源:user_account / role_id / none
│   │   ├── account_id_field?:      账号ID字段名(仅user_account模式,例如user_id / phone / email)
│   │   ├── distinct_id_strategy:   访客ID策略:auto / device_id / custom
│   │   └── distinct_id_custom_value?: 自定义访客ID值
│   └── business_dimension:         业务维度配置(阶段1.3注入)
│       ├── revenue_model:          收入模型:IAA / IAP / mixed / subscription / commission
│       ├── core_loop:              核心业务流程描述
│       ├── functional_entries:     功能入口列表
│       ├── currency_system:        货币体系
│       ├── ad_scenes:              广告场景(仅IAA / mixed模式)
│       └── iap_items:              内购商品(仅IAP / mixed模式)
├── events:                         事件数组,每个事件包含platform字段
├── event_properties:               全局事件属性池(去重)
├── common_event_properties:        公共事件属性(附加到所有事件)
└── user_properties:                用户属性
SDK集成模式字段
json
// 多平台示例(Android + iOS)
{
  "sdk_integration_mode": "both",       // client_only / server_only / both
  "client_platforms": ["android", "ios"],   // 多平台必填
  "client_platform_languages": {            // 多平台必填;各平台语言
    "android": ["kotlin"],
    "ios": ["swift"]
  },
  "server_language": "java"                // 仅server_only或both模式
}

// 单平台示例(向后兼容)
{
  "sdk_integration_mode": "client_only",
  "client_sdk_type": "android",            // 单平台
  "client_language": "kotlin"              // 单平台
}
事件平台标签(
events[].platform
json
{
  "event_name": "order_create",
  "display_name": "订单创建",
  "platform": "server",    // client / server / both
  "prop_names": ["order_id", "order_amount", "payment_method"],
  "source": "prd"
}
  • platform: "client"
    — 客户端上传(用户行为事件)
  • platform: "server"
    — 服务端上传(业务数据事件)
  • platform: "both"
    — 两端上传(时间戳必须同步)
属性对象格式(
event_properties
/
common_event_properties
池条目)
json
{
  "name": "order_amount",
  "display_name": "订单金额",
  "type": "number",
  "desc": "订单总金额(单位:分)",
  "source": "prd"
}
⚠️ 字段名:使用
name
(而非
prop_name
)、
display_name
type
desc
source
。事件通过
prop_names: ["order_amount", ...]
引用属性——这是属性
name
的引用数组(字符串数组),而非属性对象。
用户属性格式(
user_properties
池条目)
json
{
  "name": "vip_level",
  "display_name": "VIP等级",
  "type": "number",
  "desc": "用户当前的VIP等级",
  "source": "chat",
  "update_type": "user_set"
}
update_type
可选值:
user_set
(覆盖)、
user_setOnce
(仅首次设置)、
user_add
(数值累加)。
用户身份字段(
meta.user_identity
json
{
  "account_id_source": "user_account", // 账号ID来源:user_account / role_id / none
  "account_id_field": "user_id",       // 账号ID字段名(仅user_account模式)
  "distinct_id_strategy": "auto",      // 访客ID策略:auto / device_id / custom
  "distinct_id_custom_value": null     // 自定义访客ID值描述(仅strategy=custom时)
}
属性类型(枚举):
string
/
number
/
bool
/
datetime
/
object
(单个对象,包含子属性) /
array_row
(对象数组,支持
parent.child
嵌套) /
array_string
(字符串数组)
命名规则:事件名称/属性名称必须为
snake_case
;使用
display_name
字段作为可读名称。

1.2 Merge Source Materials

1.2 合并素材来源

Merge order: existing_plan → template → codebase → prd → chat → autotrack
Earlier sources take precedence — same-name events keep the earlier version, later sources only add new events or merge
prop_names
without overwriting.
  • existing_plan: Already imported and validated in Phase 0 (see "Modify Existing Tracking Plan Flow"). Events are in draft.json as the baseline; each item marked
    source: "existing_plan"
    . Higher-priority sources supplement with new events only; same-name events keep the existing_plan version.
  • template: User-selected industry template (see "Template Lookup Convention" below) as baseline; each item marked
    source: "template"
    • Templates are resolved by ae-cli from the ae-cli package root and user template directory
    • Import command:
      AE_LANG=<user_lang> ae-cli tracking code import-template --template-name "<template name>" --out .ae-cli/draft.json
    • ⚠️ Must validate immediately after template import (see Phase 1.6); template content may not be fully correct
    • ⚠️ Do not manually translate template content after import: Do NOT read draft.json and model-translate
      display_name
      ,
      event_desc
      ,
      event_tag
      , or property
      display_name
      /
      desc
      . Keep imported business content as produced by the CLI/template reader unless the user explicitly asks for semantic rewriting.
    • ⚠️ Use
      src/tracking/i18n
      for localization owned by the CLI
      :
      AE_LANG=<user_lang>
      +
      draft.meta.lang
      control CLI messages, xlsx sheet names, xlsx headers, property type display values, and auto-track/i18n-owned labels. If these are wrong, inspect the existing translations under
      src/tracking/i18n
      , then regenerate with the intended locale instead of editing labels by hand.
    • ⚠️ No model-invented translations for template labels: When replacing or explaining a localized template-owned label, use the exact value from
      src/tracking/i18n
      resources. If no corresponding resource exists, preserve the template text and ask the user before changing semantics.
    • ⚠️ event_tag is not free-form model translation: Do not manually map
      业务事件
      /
      系统事件
      to another language. Preserve template tags, or rely on
      src/tracking/i18n
      and autotrack generation for system labels when the CLI owns them.
  • codebase: Scan project source directory, extract events/properties from business logic; same-name events merge prop_names without overwriting existing fields; new items
    source: "codebase"
  • prd: Read all user-provided product documents (md / pdf / docx / URL / images), extract events and properties from each file; same-name events merge prop_names without overwriting existing fields; image files analyzed via multimodal interpretation of UI elements and interaction flows; all new items
    source: "prd"
    • prd path is a folder: Recursively scan all files in the directory:
      • md/pdf/docx → read text content, extract events/properties
      • png/jpg/jpeg/webp → multimodal interpretation, analyze UI elements and interaction flows
      • subdirectories → recurse
      • other files → skip
    • prd path is a URL: Fetch URL content directly, process by the same rules above
  • chat: Anchor phase business scenario + refine phase edit instructions,
    source: "chat"
  • autotrack: Auto-inject SDK auto-track events based on
    meta.client_sdk_type
    (only for
    client_only
    or
    both
    mode),
    source: "autotrack"
合并顺序:existing_plan → template → codebase → prd → chat → autotrack
优先级高的素材优先——同名事件保留优先级高的版本,优先级低的素材仅添加新事件或合并
prop_names
而不覆盖。
  • existing_plan:已在阶段0导入并校验(见「修改现有埋点方案流程」)。事件以draft.json为基准;每个条目标记
    source: "existing_plan"
    。优先级更高的素材仅补充新事件;同名事件保留existing_plan版本。
  • template:用户选择的行业模板(见下文「模板查找规范」)作为基准;每个条目标记
    source: "template"
    • 模板由ae-cli从ae-cli包根目录和用户模板目录解析
    • 导入命令:
      AE_LANG=<user_lang> ae-cli tracking code import-template --template-name "<template name>" --out .ae-cli/draft.json
    • ⚠️ 模板导入后必须立即校验(见阶段1.6);模板内容可能不完全正确
    • ⚠️ 导入后不得手动翻译模板内容:不得读取draft.json并通过模型翻译
      display_name
      event_desc
      event_tag
      或属性
      display_name
      /
      desc
      。除非用户明确要求重写语义,否则保留CLI/模板读取器生成的导入业务内容。
    • ⚠️ 使用
      src/tracking/i18n
      处理CLI所属的本地化内容
      AE_LANG=<user_lang>
      +
      draft.meta.lang
      控制CLI消息、Excel工作表名称、Excel表头、属性类型显示值以及自动采集/i18n所属标签。如果这些内容错误,检查
      src/tracking/i18n
      下的现有翻译,然后使用目标区域设置重新生成,而非手动编辑标签。
    • ⚠️ 不得通过模型自行生成模板标签的翻译:替换或解释模板所属的本地化标签时,使用
      src/tracking/i18n
      资源中的精确值。如果没有对应的资源,保留模板文本并在更改语义前询问用户。
    • ⚠️ event_tag并非自由模型翻译:不得手动将「业务事件」/「系统事件」映射到其他语言。保留模板标签,或当CLI拥有系统标签时,依赖
      src/tracking/i18n
      和自动采集生成。
  • codebase:扫描项目源目录,从业务逻辑中提取事件/属性;同名事件合并prop_names而不覆盖现有字段;新条目标记
    source: "codebase"
  • prd:读取用户提供的所有产品文档(md / pdf / docx / URL / 图片),从每个文件中提取事件和属性;同名事件合并prop_names而不覆盖现有字段;图片文件通过UI元素和交互流程的多模态分析处理;所有新条目标记
    source: "prd"
    • prd路径为文件夹:递归扫描目录中的所有文件:
      • md/pdf/docx → 读取文本内容,提取事件/属性
      • png/jpg/jpeg/webp → 多模态解读,分析UI元素和交互流程
      • 子目录 → 递归处理
      • 其他文件 → 跳过
    • prd路径为URL:直接获取URL内容,按上述规则处理
  • chat:锚点阶段的业务场景 + 优化阶段的编辑指令,标记
    source: "chat"
  • autotrack:根据
    meta.client_sdk_type
    自动注入SDK自动采集事件(仅
    client_only
    both
    模式),标记
    source: "autotrack"

1.3 Inject Business Dimension Events

1.3 注入业务维度事件

Based on
meta.business_dimension
collected in Phase 0, inject corresponding events by the following rules.
Revenue model → Required events:
Revenue ModelInjected EventsDescription
IAA
ad_show
,
ad_click
,
ad_reward_get
Ad impression / click / reward claim
IAP
payment
,
payment_fail
Payment success / failure
mixed
All IAA + IAP events
subscription
subscription_start
,
subscription_renew
,
subscription_cancel
Subscription start / renew / cancel
commission
order_create
,
order_paid
,
commission_settled
Order create / payment / commission settlement
Core loop → Event sequence:
Parse node actions from user's
core_loop
description, map to events:
Example: "Players repeatedly clear stages to earn coins, use coins to gacha for heroes" → Stage module:
stage_start
(stage begin),
stage_complete
(stage clear),
stage_fail
(stage fail) → Resource gain:
token_get
(coin gain, props:
token_type=diamond
,
token_amount
) → Gacha module:
gacha_draw
(gacha pull),
pool_type
(pool type),
draw_count
(draw count) → Hero gain:
hero_get
(hero acquired),
hero_id
Functional entries → Module event groups:
Functional EntryEvent ExamplesDescription
Stage
stage_start
,
stage_complete
,
stage_fail
,
stage_id
Stage start / complete / fail
Gacha
gacha_draw
,
pool_type
,
draw_count
,
hero_get
Gacha pull / pool / count / acquire
Shop
shop_open
,
shop_buy
,
token_balance
Shop open / buy / balance
Guild
guild_join
,
guild_donate
,
guild_boss_start
Guild join / donate / boss fight
Leaderboard
rank_view
,
rank_refresh
,
rank_click
Ranking view / refresh / click
Tasks
task_accept
,
task_complete
,
task_reward_claim
Task accept / complete / reward claim
Achievements
achieve_unlock
,
achieve_reward_claim
Achievement unlock / reward claim
Daily Check-in
daily_sign
,
sign_reward_claim
Daily sign-in / reward claim
Currency system → Property design:
Currency TypeEventProperties
Hard currency (diamonds) gain
token_get
token_type=diamond
,
token_amount
,
token_balance
,
source
Soft currency (gold) gain
token_get
token_type=gold
,
token_amount
,
token_balance
,
source
Hard currency spend
token_consume
token_type
,
token_amount
,
token_balance
,
consume_type
Soft currency spend
token_consume
token_type
,
token_amount
,
token_balance
,
consume_type
Injection rules:
  1. Business dimension events marked
    source: "business_dimension"
  2. When merging with source material events, same-name events keep the source material version, do not overwrite
  3. When revenue model is
    none
    (no monetization), skip revenue-related event injection
根据阶段0收集的
meta.business_dimension
,按以下规则注入对应事件。
收入模型 → 必填事件
收入模型注入事件描述
IAA
ad_show
,
ad_click
,
ad_reward_get
广告展示 / 点击 / 奖励领取
IAP
payment
,
payment_fail
支付成功 / 失败
mixed
所有IAA + IAP事件
subscription
subscription_start
,
subscription_renew
,
subscription_cancel
订阅开始 / 续订 / 取消
commission
order_create
,
order_paid
,
commission_settled
订单创建 / 支付 / 佣金结算
核心循环 → 事件序列
从用户的
core_loop
描述中解析节点操作,映射为事件:
示例:"玩家反复通关关卡赚取金币,使用金币抽卡获取英雄" → 关卡模块:
stage_start
(关卡开始)、
stage_complete
(关卡通关)、
stage_fail
(关卡失败) → 资源获取:
token_get
(金币获取,属性:
token_type=diamond
token_amount
) → 抽卡模块:
gacha_draw
(抽卡)、
pool_type
(卡池类型)、
draw_count
(抽卡次数) → 英雄获取:
hero_get
(获取英雄)、
hero_id
功能入口 → 模块事件组
功能入口事件示例描述
关卡
stage_start
,
stage_complete
,
stage_fail
,
stage_id
关卡开始 / 通关 / 失败
抽卡
gacha_draw
,
pool_type
,
draw_count
,
hero_get
抽卡 / 卡池 / 次数 / 获取英雄
商店
shop_open
,
shop_buy
,
token_balance
商店打开 / 购买 / 余额
公会
guild_join
,
guild_donate
,
guild_boss_start
公会加入 / 捐赠 / 公会BOSS战开始
排行榜
rank_view
,
rank_refresh
,
rank_click
排行榜查看 / 刷新 / 点击
任务
task_accept
,
task_complete
,
task_reward_claim
任务接受 / 完成 / 奖励领取
成就
achieve_unlock
,
achieve_reward_claim
成就解锁 / 奖励领取
每日签到
daily_sign
,
sign_reward_claim
每日签到 / 奖励领取
货币体系 → 属性设计
货币类型事件属性
硬通货(钻石)获取
token_get
token_type=diamond
,
token_amount
,
token_balance
,
source
软通货(金币)获取
token_get
token_type=gold
,
token_amount
,
token_balance
,
source
硬通货消耗
token_consume
token_type
,
token_amount
,
token_balance
,
consume_type
软通货消耗
token_consume
token_type
,
token_amount
,
token_balance
,
consume_type
注入规则
  1. 业务维度事件标记
    source: "business_dimension"
  2. 与素材来源事件合并时,同名事件保留素材来源版本,不得覆盖
  3. 若收入模型为
    none
    (无变现),跳过收入相关事件注入

1.4 Auto-inject SDK Auto-track Events

1.4 自动注入SDK自动采集事件

Based on SDK integration mode collected in Phase 0, decide whether to inject auto-track events:
Injection conditions:
  • sdk_integration_mode === "client_only"
    → inject auto-track events
  • sdk_integration_mode === "both"
    → inject auto-track events (client side only)
  • sdk_integration_mode === "server_only"
    do NOT inject (server SDKs have no auto-track)
  • sdk_integration_mode === "none"
    do NOT inject (no SDK; data ingestion via other methods)
Injection rules:
  1. Only inject recommended events; optional events are not auto-injected (prompted in Refine phase for optional enablement)
  2. Auto-track events placed at the end of
    events
    array, marked
    source: "autotrack"
  3. Auto-track event
    event_tag
    set to
    "System Event"
  4. Auto-track events only carry preset properties (
    prop_names
    is empty or contains only preset property names)
  5. Preset properties prefixed with
    #
    are not added to
    event_properties
    pool (auto-collected by SDK)
  6. Cleanup + Deduplication: The CLI will:
    • Remove auto-track events inherited from templates or existing plans that don't match the user's selected SDKs. For example: if a template built for Android/iOS contains
      ta_app_install
      ,
      ta_app_start
      ,
      ta_app_end
      but the user selects JavaScript SDK, those
      ta_app_*
      events will be automatically removed since JavaScript SDK does not support them.
    • Inject the correct auto-track events for the user's selected SDKs.
    • Deduplicate by event name globally — won't inject events that already exist in the draft (correct auto-track events inherited from templates are kept).
SDK type → Recommended events (see
references/autotrack-events.md
for details):
SDK TypeRecommended (auto-inject)Optional (Refine prompt)
Android / iOS
ta_app_install
,
ta_app_start
,
ta_app_end
ta_app_view
,
ta_app_click
,
ta_app_crash
JavaScript
ta_page_show
,
ta_page_hide
ta_pageview
WeChat Mini-program
ta_mp_launch
,
ta_mp_show
,
ta_mp_hide
,
ta_mp_view
,
ta_mp_share
ta_page_leave
,
ta_add_favorite
,
ta_mp_click
WeChat Mini-game
ta_mp_launch
,
ta_mp_show
,
ta_mp_hide
Unity
ta_app_install
,
ta_app_start
,
ta_app_end
ta_scene_loaded
,
ta_scene_unloaded
Unity WeChat Mini-game
ta_mg_launch
,
ta_mg_show
,
ta_mg_hide
ta_scene_loaded
,
ta_scene_unloaded
Other game engines
ta_app_install
,
ta_app_start
,
ta_app_end
Auto-track event purpose notes:
  • Auto-track events are the SDK's built-in auto-reporting mechanism; you do not need to manually define same-name events
  • Example: JavaScript SDK's
    ta_page_show
    auto-collects page views; no need to define
    home_page_show
    ,
    about_page_show
    etc.
  • If templates already contain auto-track events (e.g.
    ta_app_install
    in industry templates), CLI will not inject duplicates
  • These events require enabling corresponding switches during SDK initialization in the
    ae-generate-tracking-code
    phase
Draft JSON example:
json
{
  "event_name": "ta_app_install",
  "display_name": "App Install",
  "event_desc": "Triggered on first app install; upgrades do not trigger; reinstall after deletion triggers",
  "event_tag": "System Event",
  "platform": "client",
  "prop_names": [],
  "source": "autotrack"
}
Note: Auto-track event
platform
is always
"client"
, because only client SDKs have auto-track capability.
根据阶段0收集的SDK集成模式,决定是否注入自动采集事件:
注入条件
  • sdk_integration_mode === "client_only"
    → 注入自动采集事件
  • sdk_integration_mode === "both"
    → 注入自动采集事件(仅客户端)
  • sdk_integration_mode === "server_only"
    不注入(服务端SDK无自动采集功能)
  • sdk_integration_mode === "none"
    不注入(无SDK;通过其他方式导入数据)
注入规则
  1. 仅注入推荐事件;可选事件不自动注入(优化阶段提示用户是否启用)
  2. 自动采集事件放在
    events
    数组末尾,标记
    source: "autotrack"
  3. 自动采集事件的
    event_tag
    设置为
    "System Event"
  4. 自动采集事件仅携带预置属性(
    prop_names
    为空或仅包含预置属性名称)
  5. #
    为前缀的预置属性不添加到
    event_properties
    池(由SDK自动采集)
  6. 清理 + 去重:CLI将:
    • 移除模板或现有方案中与用户选择的SDK不匹配的自动采集事件。例如:若为Android/iOS构建的模板包含
      ta_app_install
      ta_app_start
      ta_app_end
      ,但用户选择JavaScript SDK,这些
      ta_app_*
      事件将被自动移除,因为JavaScript SDK不支持它们。
    • 注入用户选择的SDK对应的正确自动采集事件。
    • 全局去重按事件名称——不会注入草稿中已存在的事件(模板继承的正确自动采集事件将保留)。
SDK类型 → 推荐事件(详情见
references/autotrack-events.md
):
SDK类型推荐(自动注入)可选(优化阶段提示)
Android / iOS
ta_app_install
,
ta_app_start
,
ta_app_end
ta_app_view
,
ta_app_click
,
ta_app_crash
JavaScript
ta_page_show
,
ta_page_hide
ta_pageview
微信小程序
ta_mp_launch
,
ta_mp_show
,
ta_mp_hide
,
ta_mp_view
,
ta_mp_share
ta_page_leave
,
ta_add_favorite
,
ta_mp_click
微信小游戏
ta_mp_launch
,
ta_mp_show
,
ta_mp_hide
Unity
ta_app_install
,
ta_app_start
,
ta_app_end
ta_scene_loaded
,
ta_scene_unloaded
Unity微信小游戏
ta_mg_launch
,
ta_mg_show
,
ta_mg_hide
ta_scene_loaded
,
ta_scene_unloaded
其他游戏引擎
ta_app_install
,
ta_app_start
,
ta_app_end
自动采集事件用途说明
  • 自动采集事件是SDK内置的自动上报机制;无需手动定义同名事件
  • 示例:JavaScript SDK的
    ta_page_show
    自动采集页面浏览量;无需定义
    home_page_show
    about_page_show
    等事件。
  • 若模板已包含自动采集事件(例如行业模板中的
    ta_app_install
    ),CLI不会注入重复事件
  • 这些事件需要在
    ae-generate-tracking-code
    阶段的SDK初始化时启用对应开关
草稿JSON示例
json
{
  "event_name": "ta_app_install",
  "display_name": "应用安装",
  "event_desc": "首次安装应用时触发;升级不触发;删除后重新安装触发",
  "event_tag": "System Event",
  "platform": "client",
  "prop_names": [],
  "source": "autotrack"
}
注意:自动采集事件的
platform
始终为
"client"
,因为只有客户端SDK具备自动采集能力。

1.5 Persist + Generate xlsx

1.5 持久化 + 生成Excel

Must write draft.json first, then run draft command. Do not skip this step and run ae-cli tracking plan draft directly.
  • Save draft to
    .ae-cli/draft.json
  • ⚠️ Write
    meta.lang
    : Set
    draft.meta.lang
    based on user's current language (
    zh
    /
    en
    /
    ja
    /
    ko
    ), ensuring generated xlsx headers / sheet names / type values match the AE platform language
  • Must verify file was updated after writing (check file modification time or content); only generate xlsx after confirming new content
  • Generate upload-ready xlsx:
bash
AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
必须先写入draft.json,再运行draft命令。不得跳过此步骤直接运行ae-cli tracking plan draft。
  • 将草稿保存到
    .ae-cli/draft.json
  • ⚠️ 写入
    meta.lang
    :根据用户当前语言设置
    draft.meta.lang
    zh
    /
    en
    /
    ja
    /
    ko
    ),确保生成的Excel表头/工作表名称/类型值与AE平台语言一致
  • 必须验证写入后文件已更新(检查文件修改时间或内容);确认新内容后再生成Excel
  • 生成可上传的Excel:
bash
AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx

1.6 Rule Validation (must execute)

1.6 规则校验(必须执行)

Auto-validate during xlsx generation to ensure compliance with AE tracking plan rules:
bash
AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx --fix
Validation rules:
RuleDescriptionAuto-fix
Display name uniquenessWithin same property pool,
display_name
must not repeat
✅ Add distinguishing prefix
Object array consistencySame
array_row
across different events must have identical sub-properties
✅ Fill missing sub-properties
snake_caseEvent/property names must match
^[a-z][a-z0-9_]*$
❌ Manual fix needed
Property name uniquenessProperty names must not repeat❌ Manual fix needed
Event name uniquenessEvent names must not repeat✅ Remove later duplicates
Validation flow:
  1. CLI auto-validates draft.json
  2. Fixable issues found → auto-fix → update draft.json → generate xlsx
  3. Non-fixable issues found → error; manual fix of draft.json needed
  4. No issues → proceed to Phase 1.7
Note: Display names can be the same across different property pools (e.g.
vip_level
can be both an event property and a user property).
Relationship to Phase 0 existing_plan validation: The underlying rule engine is the same, but Phase 0 uses interactive 3-tier (Minor/Medium/Severe) because the user is present to confirm each fix. Phase 1.6 uses batch 2-tier (auto-fixable / manual-fix-needed) because it runs as part of the automated draft generation. Rules that are "Medium (needs confirmation)" in Phase 0 appear as "❌ Manual fix needed" here — the same rule, just without the interactive prompt.
生成Excel时自动校验,确保符合AE埋点方案规则:
bash
AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx --fix
校验规则
规则描述自动修复
显示名称唯一性同一属性池内,
display_name
不得重复
✅ 添加区分前缀
对象数组一致性不同事件中相同的
array_row
必须具有相同的子属性
✅ 填充缺失的子属性
snake_case规则事件/属性名称必须匹配
^[a-z][a-z0-9_]*$
❌ 需要手动修复
属性名称唯一性属性名称不得重复❌ 需要手动修复
事件名称唯一性事件名称不得重复✅ 删除后续重复项
校验流程
  1. CLI自动校验draft.json
  2. 发现可修复问题→自动修复→更新draft.json→生成Excel
  3. 发现不可修复问题→报错;需要手动修复draft.json
  4. 无问题→进入阶段1.7
注意:不同属性池中的显示名称可以相同(例如
vip_level
可以同时是事件属性和用户属性)。
与阶段0现有方案校验的关系:底层规则引擎相同,但阶段0使用交互式三级(轻微/中等/严重),因为用户在场可确认每项修复。阶段1.6使用批量两级(可自动修复/需手动修复),因为它是自动草稿生成的一部分。阶段0中为「中等(需确认)」的规则在此处显示为「❌ 需要手动修复」——规则相同,只是没有交互式提示。

1.7 Show Summary

1.7 展示摘要

Display to user via markdown table: event count / event property pool size / super property count / user property count; show deliverable paths.
After displaying, tell user:
Phase 1 complete.
Next: Phase 2 — Refine to confirm the plan.
通过Markdown表格向用户展示:事件数量 / 事件属性池大小 / 公共属性数量 / 用户属性数量;展示交付物路径。
展示后告知用户:
阶段1完成。
下一步:阶段2 — 优化方案并确认。

📁 Template Lookup Convention

📁 模板查找规范

Run the following command to dynamically discover available templates:
bash
AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
Language rules: Template names and template business content must not be model-translated. Use localized names only when they are returned by the CLI or found in
src/tracking/i18n
resources. If
list-templates --json
only returns the original template
name
, display that name as-is and keep it unchanged for import. Before presenting or modifying any localized template-owned label, look it up in
src/tracking/i18n
; do not invent a translation.
Built-in templates are resolved by ae-cli from the ae-cli package root. User templates are resolved from the ae-cli user template directory. Do not manually construct
./tracking-plan-template/...
paths from the user's current workspace.
Search directories in order:
  1. <ae-cli package root>/tracking-plan-template/
    — bundled templates
  2. ~/.ae-cli/templates/
    — user-provided template directory
Each template prefers
.md
distilled file (if same-name
.md
exists, return md path; otherwise return xlsx path). Display the template names returned by the CLI, and keep the exact
name
from the JSON result for import. Auto-detect format on import:
bash
AE_LANG=<user_lang> ae-cli tracking code import-template --template-name "<template name>" --out .ae-cli/draft.json

运行以下命令动态发现可用模板:
bash
AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
语言规则:模板名称和模板业务内容不得通过模型翻译。仅当CLI返回或在
src/tracking/i18n
资源中找到本地化名称时,才使用本地化名称。如果
list-templates --json
仅返回原始模板
name
,则按原样显示该名称并保持不变用于导入。在展示或修改任何模板所属的本地化标签前,先在
src/tracking/i18n
中查找;不得自行生成翻译。
内置模板由ae-cli从ae-cli包根目录解析。用户模板从ae-cli用户模板目录解析。不得从用户当前工作区手动构造
./tracking-plan-template/...
路径。
搜索目录顺序:
  1. <ae-cli package root>/tracking-plan-template/
    — 捆绑模板
  2. ~/.ae-cli/templates/
    — 用户提供的模板目录
每个模板优先选择
.md
提炼文件(如果存在同名
.md
文件,返回md路径;否则返回xlsx路径)。 展示CLI返回的模板名称,并使用JSON结果中的精确
name
进行导入。导入时自动检测格式:
bash
AE_LANG=<user_lang> ae-cli tracking code import-template --template-name "<template name>" --out .ae-cli/draft.json

Phase 2 — Refine (5-segment loop)

阶段2 — 优化(5段循环)

In order, one conversation round per segment:
  1. sdk_config (SDK config + User identity, combined) — Show SDK integration mode, platform/language, visitor ID strategy, account ID source, corresponding SDK calls
  2. business (Business dimension + Business events, combined) — Show revenue model, core loop, functional entries, injected event modules (grouped by platform)
  3. autotrack (Auto-track events) — Show SDK auto-track events in a separate table, note enablement method
  4. common_props (Super properties) — Show all super properties, note usage scenarios and considerations
  5. props (Event properties + User properties) — Show event property pool grouped by event + user properties table
Per-segment flow:
  1. Display corresponding section of current draft
  2. Ask a segment-specific confirmation question. Always include the current segment number, current segment key, and next segment key:
    text
    Segment <n>/5 <segment_key> confirmed? Reply ok to continue to Segment <n+1>/5 <next_segment_key>, or describe changes.
    For Segment 5:
    text
    Segment 5/5 props confirmed? Reply ok to archive the plan and continue to Phase 3, or describe changes.
  3. User gives natural language instructions → update
    .ae-cli/draft.json
    → re-run:
    bash
    AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
  4. User
    ok
    → proceed to next segment
ok
is a refine state-machine input, not a repeated-message error. If the user replies
ok
multiple times in a row, advance exactly one segment per
ok
in order. Before each confirmation prompt, print the new segment heading first, so consecutive confirmations do not look like the same question repeated.
User may say "Go back to segment N" at any time to jump to any segment (N = 1-5).

按顺序进行,每段一轮对话:
  1. sdk_config(SDK配置 + 用户身份,合并) — 展示SDK集成模式、平台/语言、访客ID策略、账号ID来源、对应的SDK调用
  2. business(业务维度 + 业务事件,合并) — 展示收入模型、核心循环、功能入口、注入的事件模块(按平台分组)
  3. autotrack(自动采集事件) — 在单独表格中展示SDK自动采集事件,说明启用方式
  4. common_props(公共属性) — 展示所有公共属性,说明使用场景和注意事项
  5. props(事件属性 + 用户属性) — 展示按事件分组的事件属性池 + 用户属性表格
每段流程:
  1. 展示当前草稿的对应部分
  2. 询问该段专属的确认问题。必须包含当前段编号、当前段标识和下一段标识:
    text
    第<n>/5段 <segment_key> 确认完毕?回复ok继续到第<n+1>/5段 <next_segment_key>,或描述修改内容。
    对于第5段:
    text
    第5/5段 props 确认完毕?回复ok归档方案并继续到阶段3,或描述修改内容。
  3. 用户给出自然语言指令→更新
    .ae-cli/draft.json
    →重新运行:
    bash
    AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
  4. 用户回复
    ok
    →进入下一段
ok
是优化状态机的输入,并非重复消息错误。如果用户连续多次回复
ok
,每次
ok
仅推进一段。在每个确认提示前,先打印新段标题,避免连续确认看起来像重复问题。
用户可随时说**「回到第N段」**跳转到任意段(N=1-5)。

sdk_config (Phase 2 Segment 1)

sdk_config(阶段2第1段)

Show SDK integration config + user identity system:
SDK Integration Config:
- Integration mode: <client_only / server_only / both / none>
- Client: <platform> (<language>)
- Server: <language>

User Identity Config:
- Account ID source: <user_account / role_id / none>
- Account ID field: <specific field>
- Visitor ID strategy: <auto / device_id / custom>
User ok / modify.

展示SDK集成配置 + 用户身份体系:
SDK集成配置:
- 集成模式:<client_only / server_only / both / none>
- 客户端:<平台>(<语言>)
- 服务端:<语言>

用户身份配置:
- 账号ID来源:<user_account / role_id / none>
- 账号ID字段:<具体字段>
- 访客ID策略:<auto / device_id / custom>
用户回复ok / 修改。

business (Phase 2 Segment 2)

business(阶段2第2段)

Show business dimensions + business events:
Business Dimensions:
- Revenue model: <IAA / IAP / mixed / subscription / commission>
- Core loop: <description>
- Functional entries: <list>
- Currency system: <hard currency / soft currency>

Injected Event Modules (grouped by platform):

Client events (platform=client):
- <event>: <display_name> — <event_desc>
- ...

Server events (platform=server):
- <event>: <display_name> — <event_desc>
- ...

Both-platform events (platform=both):
- <event>: <display_name> — <event_desc>
Conflict detection: If business dimensions contradict source materials, prominently flag for user confirmation.
User ok / modify.

展示业务维度 + 业务事件:
业务维度:
- 收入模型:<IAA / IAP / mixed / subscription / commission>
- 核心循环:<描述>
- 功能入口:<列表>
- 货币体系:<硬通货 / 软通货>

注入的事件模块(按平台分组):

客户端事件(platform=client):
- <event>:<display_name> — <event_desc>
- ...

服务端事件(platform=server):
- <event>:<display_name> — <event_desc>
- ...

跨平台事件(platform=both):
- <event>:<display_name> — <event_desc>
冲突检测:若业务维度与素材来源矛盾,突出标记供用户确认。
用户回复ok / 修改。

autotrack (Phase 2 Segment 3)

autotrack(阶段2第3段)

Only shown for
client_only
or
both
mode.
Display SDK auto-track event list, with notes:
  • These events are auto-collected by the SDK; no manual track() calls needed during code generation — just enable corresponding switches during SDK init
  • display_name
    or
    event_desc
    can be adjusted; event names cannot be changed
User ok / modify.

仅在
client_only
both
模式下展示。
展示SDK自动采集事件列表,并附带说明:
  • 这些事件由SDK自动采集;代码生成期间无需手动调用track()——只需在SDK初始化时启用对应开关
  • display_name
    event_desc
    可调整;事件名称不可更改
用户回复ok / 修改。

common_props (Phase 2 Segment 4)

common_props(阶段2第4段)

Show all super properties (
name
/
display_name
/
type
/
desc
).
Notes:
  • Super properties are attached to every event; ideal for business-wide global dimensions
  • Common super properties (by app type):
    • H5/Web:
      channel
      (source channel),
      referrer_domain
      (referring domain)
    • Mobile App:
      channel
      ,
      app_version
      ,
      platform
    • Game:
      channel
      ,
      vip_level
      ,
      server_id
    • Mini-program:
      channel
      ,
      scene
  • Prohibited: Do NOT set SDK preset properties (
    #
    prefix) as super properties
User ok / modify.

展示所有公共属性(
name
/
display_name
/
type
/
desc
)。
说明:
  • 公共属性附加到所有事件;适用于全业务全局维度
  • 按应用类型划分的常见公共属性:
    • H5/Web:
      channel
      (来源渠道)、
      referrer_domain
      (来源域名)
    • 移动应用:
      channel
      app_version
      platform
    • 游戏:
      channel
      vip_level
      server_id
    • 小程序:
      channel
      scene
  • 禁止:不得将SDK预置属性(
    #
    前缀)设置为公共属性
用户回复ok / 修改。

props (Phase 2 Segment 5)

props(阶段2第5段)

Show event property pool (grouped by event) + user properties table:
  • Event properties:
    name
    /
    display_name
    /
    type
    /
    desc
    , grouped by
    event_tag
  • User properties:
    name
    /
    display_name
    /
    type
    /
    update_type
    /
    desc
User property update methods:
Update MethodDescriptionUse Case
user_setOnce
Only set on first occurrence; subsequent updates ignoredFirst registration time, first payment time, first channel
user_set
Overwrite update; always takes latest valueCurrent level, current balance, nickname, VIP status
user_add
Numeric accumulation; suitable for cumulative valuesTotal recharge amount, total login days, total ads watched
User ok → immediately execute archive command, then proceed to Phase 3.

展示按事件分组的事件属性池 + 用户属性表格:
  • 事件属性:
    name
    /
    display_name
    /
    type
    /
    desc
    ,按
    event_tag
    分组
  • 用户属性:
    name
    /
    display_name
    /
    type
    /
    update_type
    /
    desc
用户属性更新方式
更新方式描述使用场景
user_setOnce
仅首次设置;后续更新被忽略首次注册时间、首次支付时间、首次来源渠道
user_set
覆盖更新;始终取最新值当前等级、当前余额、昵称、VIP状态
user_add
数值累加;适用于累计值累计充值金额、累计登录天数、累计观看广告次数
用户回复ok → 立即执行归档命令,然后进入阶段3。

Refine Phase Heuristic Suggestions

优化阶段启发式建议

  • Super properties vs Event properties: Property appears on 3+ events → promote to super property; super properties are suitable for business-wide global dimensions (
    channel
    ,
    vip_level
    ,
    ab_test_group
    )
  • Prohibited: Do NOT set SDK preset properties (
    #
    prefix) as super properties
  • Events must have properties: Every event must have at least one semantically meaningful, describable property
  • Nested properties:
    array_row
    parent properties have
    parent.child
    sub-properties describing a group of objects

  • 公共属性 vs 事件属性:属性出现在3个以上事件中→提升为公共属性;公共属性适用于全业务全局维度(
    channel
    vip_level
    ab_test_group
  • 禁止:不得将SDK预置属性(
    #
    前缀)设置为公共属性
  • 事件必须包含属性:每个事件必须至少包含一个语义明确、可描述的属性
  • 嵌套属性
    array_row
    父属性包含
    parent.child
    子属性,描述一组对象

Post-Phase 2 — Pre-delivery Self-check

阶段2后 — 交付前自检

⚠️ Before uploading to AE, must complete the following self-check. Fix any issues before uploading.
⚠️ 上传到AE前必须完成以下自检。修复所有问题后再上传。

Naming Convention Check

命名规范检查

  • Do event/property names start with a letter?
  • Do event/property names contain only letters, digits, and underscores (no Chinese, no spaces)?
  • Are there duplicate event names or synonymous events coexisting (e.g.
    order_create
    and
    create_order
    )?
  • Does the same property name map to multiple display names or types?
  • Does every event, event property, common event property, and user property have a non-empty
    display_name
    in the user's language?
  • 事件/属性名称是否以字母开头?
  • 事件/属性名称是否仅包含字母、数字和下划线(无中文、无空格)?
  • 是否存在重复事件名称或同义事件共存(例如
    order_create
    create_order
    )?
  • 同一属性名称是否映射到多个显示名称或类型?
  • 每个事件、事件属性、公共事件属性和用户属性是否包含用户语言的非空
    display_name

Revenue Model Required Events Check

收入模型必填事件检查

Revenue ModelMust Include EventsCheck
IAA
ad_show
,
ad_click
,
ad_reward_get
[ ]
IAP
payment
,
payment_fail
[ ]
mixed
All IAA + IAP events[ ]
subscription
subscription_start
,
subscription_renew
,
subscription_cancel
[ ]
commission
order_create
,
order_paid
,
commission_settled
[ ]
收入模型必须包含事件检查
IAA
ad_show
,
ad_click
,
ad_reward_get
[ ]
IAP
payment
,
payment_fail
[ ]
mixed
所有IAA + IAP事件[ ]
subscription
subscription_start
,
subscription_renew
,
subscription_cancel
[ ]
commission
order_create
,
order_paid
,
commission_settled
[ ]

Paired Event Consistency Check

配对事件一致性检查

Start/end paired events (e.g.
battle_start
/
battle_end
) must carry same-name, same-structure object arrays:
  • Object array sub-properties reported by start event must be same name and same type in end event
  • Check: stage pairs (
    stage_start
    /
    stage_complete
    ), battle pairs (
    battle_start
    /
    battle_end
    ), gacha pairs (
    gacha_draw
    /
    hero_get
    ), etc.
开始/结束配对事件(例如
battle_start
/
battle_end
)必须携带同名、同结构的对象数组:
  • 开始事件上报的对象数组子属性必须与结束事件中的子属性名称和类型相同
  • 检查:关卡配对(
    stage_start
    /
    stage_complete
    )、战斗配对(
    battle_start
    /
    battle_end
    )、抽卡配对(
    gacha_draw
    /
    hero_get
    )等

Unit Description Check

单位描述检查

  • Are monetary fields annotated with unit (cents/USD)?
  • Are duration fields annotated with unit (seconds/milliseconds)?
  • Are balance fields annotated as post-recharge balance or pre-operation balance?
  • 货币字段是否标注单位(分/美元)?
  • 时长字段是否标注单位(秒/毫秒)?
  • 余额字段是否标注为充值后余额或操作前余额?

Enum Value Check

枚举值检查

  • Are enum values listed in event description (≤ 10 values)?
  • For > 10 values, is there a note to use a dimension table?
  • Is the null-value fallback strategy documented (e.g. "unknown channel → use
    unknown
    ")?
  • 事件描述中是否列出枚举值(≤10个值)?
  • 若超过10个值,是否注明使用维度表?
  • 是否记录空值回退策略(例如:"未知渠道→使用
    unknown
    ")?

Object Array Usage Check

对象数组使用检查

Only use object arrays (
array_row
) when ALL THREE conditions are met; otherwise use object or plain properties:
  1. An event property has multiple same-type entities to record
  2. Each entity needs ≥ 2 properties recorded
  3. Entity count is variable
仅当全部三个条件满足时才使用对象数组(
array_row
);否则使用对象或普通属性:
  1. 事件属性需要记录多个同类型实体
  2. 每个实体需要记录≥2个属性
  3. 实体数量可变

Object Usage Check

对象使用检查

Use object (
object
) when the following condition is met; distinguish from object arrays:
  • One-to-one relationship → use
    object
    : e.g. user's current "equipment" details, player's "current deployed hero" (only one)
  • One-to-many relationship → use
    array_row
    : e.g. "backpack items" list, "lineup heroes" list (multiple)
Quick rule: data shaped like
{...}
→ use
object
; data shaped like
[{...}]
→ use
array_row
.

满足以下条件时使用对象(
object
);与对象数组区分:
  • 一对一关系→使用
    object
    :例如用户当前的「装备」详情、玩家「当前部署的英雄」(仅一个)
  • 一对多关系→使用
    array_row
    :例如「背包物品」列表、「阵容英雄」列表(多个)
快速规则:数据格式为
{...}
→使用
object
;数据格式为
[{...}]
→使用
array_row

Post-Phase 2 — Archive

阶段2后 — 归档

After all 5 Refine segments are confirmed (user
ok
on Segment 5), archive immediately; do not skip or delay:
bash
AE_LANG=<user_lang> ae-cli tracking plan archive --draft .ae-cli/draft.json --xlsx .ae-cli/draft.xlsx --name "<plan_name>"
ParameterDescriptionExample
--draft
draft.json path (required)
.ae-cli/draft.json
--xlsx
draft.xlsx path (required)
.ae-cli/draft.xlsx
--name
Plan name used as output filename prefix (required)
"AI SaaS Website Tracking Plan"
Output lands at
plans/<date>-<plan_name>.xlsx
;
draft.json
is updated with
meta.archived_at
.
After archiving, tell user:
✅ Archive complete
File path: plans/<date>-<plan_name>.xlsx

Next: Phase 3 — Upload to AE:
1. Login to AE to get token
2. Get AE project ID
3. Upload plan to AE
⚠️ Hard rule: Archive must complete before entering Phase 3. Before Phase 3.1's first question, must confirm
meta.archived_at
exists.

所有5个优化段确认完毕后(用户回复第5段
ok
),立即归档;不得跳过或延迟
bash
AE_LANG=<user_lang> ae-cli tracking plan archive --draft .ae-cli/draft.json --xlsx .ae-cli/draft.xlsx --name "<plan_name>"
参数描述示例
--draft
draft.json路径(必填)
.ae-cli/draft.json
--xlsx
draft.xlsx路径(必填)
.ae-cli/draft.xlsx
--name
用作输出文件名前缀的方案名称(必填)
"AI SaaS网站埋点方案"
输出文件位于
plans/<date>-<plan_name>.xlsx
draft.json
将更新
meta.archived_at
字段。
归档后告知用户:
✅ 归档完成
文件路径:plans/<date>-<plan_name>.xlsx

下一步:阶段3 — 上传到AE:
1. 登录AE获取令牌
2. 获取AE项目ID
3. 将方案上传到AE
⚠️ 硬性规则:进入阶段3前必须完成归档。阶段3.1的第一个问题前,必须确认
meta.archived_at
存在。

Phase 3 — Token & projectId

阶段3 — 令牌与项目ID

At the start of Phase 3, tell user:
undefined
阶段3开始时告知用户:
undefined

Phase 3 — Upload Preparation

阶段3 — 上传准备

Next steps:
  1. Check active AE host and login status
  2. Login to AE to get token if needed
  3. AE project ID
undefined
下一步:
  1. 检查当前AE主机和登录状态
  2. 若需登录AE获取令牌
  3. 获取AE项目ID
undefined

3.1 Check Active AE Host and Login Status

3.1 检查当前AE主机和登录状态

Do not ask for the AE web address first. ae-cli stores an active AE host, and auth commands can use it directly.
First check current auth/host status:
bash
ae-cli auth status
If an active host is configured, save that host to
.ae-cli/draft.json
meta.host
. If
auth status
reports
authenticated: true
, skip login and continue to project ID.
Only if ae-cli reports no active host / no AE host configured, ask the user:
"What is the AE web address?"
After user responds, configure it and save the same value to
.ae-cli/draft.json
meta.host
:
bash
ae-cli config set-host <host>
If
auth status
reports unauthenticated, use the agent split-flow. Do not run blocking
ae-cli auth login
directly from an AI agent.
Step 1 — request an authorization URL and return control to the user:
bash
ae-cli auth login --no-wait
Show the returned
verification_url
to the user and ask them to complete authorization. Keep the returned
device_code
for the next step.
Step 2 — after the user says authorization is complete, finish login:
bash
ae-cli auth login --device-code <device_code>
ae-cli auth status
Do not retry with
ae-cli auth login --host <host>
unless the previous command explicitly failed because no active host was configured. In that case, configure the host first, then restart the split-flow with
--no-wait
.
Common error tips and self-recovery:
ErrorCauseWhat to Tell the User
Device authorize request failed
The agent runtime cannot reach the authorization serviceReport that no device code was created and include the exact error
not_mac
A legacy browser-token flow was attemptedRetry the split-flow device-code login; do not ask the user for browser tokens
NO_TAB_FOUND
A legacy browser-token flow was attemptedRetry the split-flow device-code login; do not ask the user to open Chrome
Token cached for 20 hours; same host avoids re-auth.
不得先询问AE网页地址。ae-cli存储当前AE主机,认证命令可直接使用。
首先检查当前认证/主机状态:
bash
ae-cli auth status
若已配置当前主机,将该主机保存到
.ae-cli/draft.json
meta.host
。若
auth status
显示
authenticated: true
,跳过登录直接进入项目ID环节。
仅当ae-cli报告无当前主机/未配置AE主机时,询问用户:
「AE网页地址是什么?」
用户回复后,配置主机并将相同值保存到
.ae-cli/draft.json
meta.host
bash
ae-cli config set-host <host>
auth status
显示未认证,使用Agent分流流程。不得直接从AI代理运行阻塞式
ae-cli auth login
步骤1 — 请求授权URL并将控制权交还给用户:
bash
ae-cli auth login --no-wait
向用户展示返回的
verification_url
并要求完成授权。保留返回的
device_code
用于下一步。
步骤2 — 用户告知授权完成后,完成登录:
bash
ae-cli auth login --device-code <device_code>
ae-cli auth status
除非前一个命令明确因未配置当前主机而失败,否则不得使用
ae-cli auth login --host <host>
重试。若出现该情况,先配置主机,然后使用
--no-wait
重启分流流程。
常见错误提示与自我恢复:
错误原因告知用户内容
Device authorize request failed
Agent运行时无法连接到授权服务报告未创建设备代码并包含精确错误信息
not_mac
尝试了旧版浏览器令牌流程重试分流式设备代码登录;不得要求用户提供浏览器令牌
NO_TAB_FOUND
尝试了旧版浏览器令牌流程重试分流式设备代码登录;不得要求用户打开Chrome
令牌缓存20小时;同一主机无需重新认证。

3.2 Get AE Project ID and Update Draft

3.2 获取AE项目ID并更新草稿

Ask user: "What is the AE project ID? Go to AE Admin → 'Project Settings' → 'Integration Config' → copy 'Project ID', or check the AE system URL parameter currentProjectId=<id>"
After user provides projectId, update
.ae-cli/draft.json
meta.project_id
.

询问用户:「AE项目ID是什么?前往AE管理后台→『项目设置』→『集成配置』→复制『项目ID』,或查看AE系统URL参数currentProjectId=<id>
用户提供projectId后,更新
.ae-cli/draft.json
meta.project_id

Phase 4 — Upload

阶段4 — 上传

At the start of Phase 4, tell user:
undefined
阶段4开始时告知用户:
undefined

Phase 4 — Upload to AE

阶段4 — 上传到AE

Checking project's existing plan...
undefined
检查项目现有方案...
undefined

4.1 Check Project's Existing Plan

4.1 检查项目现有方案

Before uploading, check if the project already has a tracking plan:
bash
AE_LANG=<user_lang> ae-cli tracking plan fetch --project <projectId> > .ae-cli/existing-plan.json
Do not add
--host
here unless the user explicitly provides a reachable override for this command. In agent sandboxes, ae-cli can resolve the request host from the sandbox-provisioned
cli-token.json
; passing a stale Kubernetes internal host can bypass that fallback.
Result assessment:
  • File empty or command error
    404
    → project has no plan; upload directly
  • File has content → project has an existing plan; show summary + conflict detection
When existing plan exists, display:
Project already has a tracking plan:
- Events: XX
- Event properties: YY
- Super properties: ZZ
- User properties: WW

Choose upload mode:
1. Append (keep existing plan, add new events/properties)
2. Replace (delete existing plan, upload new plan)

Append / Replace?

上传前检查项目是否已有埋点方案:
bash
AE_LANG=<user_lang> ae-cli tracking plan fetch --project <projectId> > .ae-cli/existing-plan.json
除非用户明确为此命令提供可访问的覆盖主机,否则不得添加
--host
。在Agent沙箱中,ae-cli可从沙箱提供的
cli-token.json
解析请求主机;传递过时的Kubernetes内部主机可能绕过该回退机制。
结果评估
  • 文件为空或命令报错
    404
    →项目无方案;直接上传
  • 文件有内容→项目已有方案;展示摘要 + 冲突检测
当项目已有方案时,展示
项目已存在埋点方案:
- 事件:XX
- 事件属性:YY
- 公共属性:ZZ
- 用户属性:WW

选择上传模式:
1. 追加(保留现有方案,添加新事件/属性)
2. 替换(删除现有方案,上传新方案)

追加 / 替换?

4.2 Append Mode Conflict Detection

4.2 追加模式冲突检测

When user chooses "Append", must detect conflicts (AE merge-by-name has silent discard risk):
Read two files:
  • Existing plan:
    .ae-cli/existing-plan.json
  • New plan:
    .ae-cli/draft.json
Detect two types of conflicts:
当用户选择「追加」时,必须检测冲突(AE按名称合并存在静默丢弃风险):
读取两个文件
  • 现有方案:
    .ae-cli/existing-plan.json
  • 新方案:
    .ae-cli/draft.json
检测两种冲突类型

Conflict Type A: Same-name property type mismatch (severe)

冲突类型A:同名属性类型不匹配(严重)

AE rule: Same-name properties must have the same type, otherwise reported data will be discarded.
Detection logic:
Compare
event_properties
/
common_event_properties
/
user_properties
three property pools:
  • For each property in the new plan, find same-name property in existing plan
  • If same name but different type → record as
    property_type_conflict
    (severe error)
Conflict display:
⚠️ Severe conflict: Same-name property type mismatch

The following properties have different types in the existing plan vs. new plan.
Appending will cause reported data to be discarded:

| Property Name | Existing Type | New Plan Type |
|---|---|---|
| order_amount | number | string |
| vip_level | string | number |

Suggestions:
1. Modify the new plan's property types to match the existing plan
2. Or choose "Replace" mode to redefine types

Continue append (without fixing) / Modify draft / Switch to replace?
AE规则:同名属性必须具有相同类型,否则上报数据将被丢弃。
检测逻辑
比较
event_properties
/
common_event_properties
/
user_properties
三个属性池:
  • 对于新方案中的每个属性,在现有方案中查找同名属性
  • 若名称相同但类型不同→记录为
    property_type_conflict
    (严重错误)
冲突展示
⚠️ 严重冲突:同名属性类型不匹配

以下属性在现有方案与新方案中的类型不同。
追加将导致上报数据被丢弃:

| 属性名称 | 现有类型 | 新方案类型 |
|---|---|---|
| order_amount | number | string |
| vip_level | string | number |

建议:
1. 修改新方案的属性类型以匹配现有方案
2. 或选择「替换」模式重新定义类型

继续追加(不修复) / 修改草稿 / 切换为替换?

Conflict Type B: Same-name events (advisory)

冲突类型B:同名事件(提示)

AE merge-by-name: Same-name events are not overwritten; new-name events are added.
Detection logic:
For each event in the new plan, find same-name event in existing plan:
  • If same-name event exists → record as
    event_exists
    (advisory, not an error)
Conflict display (advisory only):
⚠️ Advisory: The following events already exist in the project (append mode will not overwrite)

- user_login (existing: 2 properties, new plan: 3 properties)
- order_create (existing: 5 properties, new plan: 5 properties)

After append:
- Existing event property associations will not change
- New properties for existing events will not be added
- New events will be added normally

Continue append? yes / no

AE按名称合并:同名事件不会被覆盖;新名称事件将被添加。
检测逻辑
对于新方案中的每个事件,在现有方案中查找同名事件:
  • 若存在同名事件→记录为
    event_exists
    (提示,非错误)
冲突展示(仅提示):
⚠️ 提示:以下事件已存在于项目中(追加模式不会覆盖)

- user_login(现有:2个属性,新方案:3个属性)
- order_create(现有:5个属性,新方案:5个属性)

追加后:
- 现有事件的属性关联不会改变
- 现有事件的新属性不会被添加
- 新事件将正常添加

继续追加?是 / 否

4.3 Upload Flow

4.3 上传流程

Decide based on conflict detection results:
Detection ResultAction
No conflictsUpload directly
Advisory only (Type B)Upload after user confirmation
Severe conflict (Type A)User fixes or switches to replace
Upload command:
bash
AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --lang <user_lang> [--replace]
  • With
    --replace
    : Delete existing project plan first then upload (when user chooses "Replace", or severe conflict switches to replace)
  • Without
    --replace
    : AE merge-by-name merge (no conflicts, or advisory only with user confirmation to append)
Upload commands MUST pass
--lang <user_lang>
explicitly.
--lang
must match the generated xlsx language and
draft.meta.lang
;
AE_LANG
is only used for CLI messages and xlsx regeneration context. Do not call AE user language config APIs and do not use
--switch-lang
. If the xlsx language is wrong, regenerate the xlsx with the intended language before uploading:
bash
AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --lang <user_lang> [--replace]
On successful upload, prompt user to verify in AE Admin. Provide the full URL (tracking plan page URL format:
https://<host>/#/data/plan
).
Then read the uploaded plan back through ae-cli and synchronize its display names to any event/property metadata that already exists in the project:
bash
AE_LANG=<user_lang> ae-cli tracking plan get --project-id <projectId> --host <host>
AE_LANG=<user_lang> ae-cli tracking plan sync-display-names \
  --project-id <projectId> \
  --draft .ae-cli/draft.json \
  --host <host>
sync-display-names
is intentionally safe to rerun:
  • It fills only blank event/property metadata display names.
  • It never overwrites a non-empty display name already maintained in AE.
  • missing_in_metadata
    means that the event/property has not appeared in project metadata yet; it is not an upload failure. Report those names and rerun the same command after the first Debug or production data reaches AE.
  • missing_display_name_in_draft
    means the generated plan is incomplete. Add the missing localized
    display_name
    , regenerate/validate the xlsx, and rerun the upload/synchronization flow.

根据冲突检测结果决定操作:
检测结果操作
无冲突直接上传
仅提示(类型B)用户确认后上传
严重冲突(类型A)用户修复或切换为替换模式
上传命令:
bash
AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --lang <user_lang> [--replace]
  • --replace
    :先删除现有项目方案再上传(当用户选择「替换」,或严重冲突切换为替换模式时)
  • 不带
    --replace
    :AE按名称合并(无冲突,或仅提示且用户确认追加)
上传命令必须显式传递
--lang <user_lang>
--lang
必须与生成的Excel语言和
draft.meta.lang
匹配;
AE_LANG
仅用于CLI消息和Excel重新生成上下文。不得调用AE用户语言配置API,不得使用
--switch-lang
。若Excel语言错误,上传前重新生成Excel:
bash
AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --lang <user_lang> [--replace]
上传成功后,提示用户在AE管理后台验证。提供完整URL(埋点方案页面URL格式:
https://<host>/#/data/plan
)。
然后通过ae-cli读取上传后的方案,并将其显示名称同步到项目中已存在的任何事件/属性元数据:
bash
AE_LANG=<user_lang> ae-cli tracking plan get --project-id <projectId> --host <host>
AE_LANG=<user_lang> ae-cli tracking plan sync-display-names \
  --project-id <projectId> \
  --draft .ae-cli/draft.json \
  --host <host>
sync-display-names
可安全重复运行:
  • 仅填充空白的事件/属性元数据显示名称。
  • 绝不会覆盖AE中已维护的非空显示名称。
  • missing_in_metadata
    表示事件/属性尚未出现在项目元数据中;这不是上传失败。 报告这些名称,并在首次调试或生产数据到达AE后重新运行相同命令。
  • missing_display_name_in_draft
    表示生成的方案不完整。添加缺失的本地化
    display_name
    , 重新生成/校验Excel,然后重新运行上传/同步流程。

4.4 Upload Failure Handling and Auto-fix

4.4 上传失败处理与自动修复

Use
--auto-fix
option on upload (enabled by default); CLI auto-detects and fixes errors:
bash
AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --lang <user_lang> [--replace]
上传时使用
--auto-fix
选项(默认启用);CLI自动检测并修复错误:
bash
AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --lang <user_lang> [--replace]

AE API Error Types

AE API错误类型

Error TypeDescriptionAuto-fix
event_prop_display_duplicate
Event property display name duplicate✅ Add distinguishing prefix
complex_event_property_should_has_same_child_property
Object array sub-property inconsistency✅ Fill missing sub-properties
event_name_duplicate
Event name duplicate✅ Remove later duplicates
property_type_conflict
Property type mismatch (append mode)❌ Switch to replace mode
错误类型描述自动修复
event_prop_display_duplicate
事件属性显示名称重复✅ 添加区分前缀
complex_event_property_should_has_same_child_property
对象数组子属性不一致✅ 填充缺失的子属性
event_name_duplicate
事件名称重复✅ 删除后续重复项
property_type_conflict
属性类型不匹配(追加模式)❌ 切换为替换模式

Auto-fix Flow

自动修复流程

CLI auto-executes:
  1. Upload xlsx to TE
  2. Check if
    eventErrorMap
    has errors
  3. Fixable errors → auto-fix draft.json → regenerate xlsx → re-upload
  4. Loop up to 3 times; prompt user for manual intervention if exceeded
Example output:
🔧 Auto-fixing upload errors (attempt 1/3)...
Fixed: Fixed object array sub-property inconsistency, Fixed display name duplicate
[plan-upload] regenerated: .ae-cli/draft.xlsx

CLI自动执行:
  1. 将Excel上传到TE
  2. 检查
    eventErrorMap
    是否有错误
  3. 可修复错误→自动修复draft.json→重新生成Excel→重新上传
  4. 最多循环3次;若超过次数提示用户手动干预
示例输出
🔧 自动修复上传错误(尝试1/3)...
已修复:修复对象数组子属性不一致,修复显示名称重复
[plan-upload] 已重新生成:.ae-cli/draft.xlsx

4.5 Post-success Actions

4.5 上传成功后操作

After successful upload and display-name synchronization, prompt user to verify in AE Admin. Provide the full URL (tracking plan page URL format:
https://<host>/#/data/plan
). Include a short synchronization summary: updated counts, preserved existing counts, and any names still missing from project metadata.
Ask about generating tracking code:
The tracking plan has been uploaded successfully. Would you like to generate tracking code next?
  • Yes → guide user to use the
    ae-generate-tracking-code
    skill
  • No → inform user of plan archive location:
    plans/<date>-<plan_name>.xlsx
    ; can continue anytime
上传成功并完成显示名称同步后,提示用户在AE管理后台验证。提供完整URL (埋点方案页面URL格式:
https://<host>/#/data/plan
)。包含简短的同步摘要: 更新数量、保留的现有数量以及仍未出现在项目元数据中的名称。
询问是否生成埋点代码
埋点方案已上传成功。是否要继续生成埋点代码?
  • → 引导用户使用
    ae-generate-tracking-code
    技能
  • → 告知用户方案归档位置:
    plans/<date>-<plan_name>.xlsx
    ;可随时继续

Prohibitions

禁止操作

  • Asking all anchor questions at once
  • Skipping Phase 3 and uploading directly
  • Manually assembling xlsx bypassing
    .ae-cli/draft.json
  • Translating "Super Property" as "超级属性" in any user-facing output (interaction prompts, plan summaries, event/property descriptions) — the correct AE Chinese term is "公共事件属性" or "公共属性"
  • Calling
    fetch
    AE API directly within the skill — all AE communication must go through project scripts / CLI

  • 一次性询问所有锚点问题
  • 跳过阶段3直接上传
  • 绕过
    .ae-cli/draft.json
    手动组装Excel
  • 在任何面向用户的输出(交互提示、方案摘要、事件/属性描述)中将"Super Property"翻译为「超级属性」——AE官方中文术语为「公共事件属性」或「公共属性」
  • 在技能中直接调用
    fetch
    AE API——所有AE通信必须通过项目脚本/CLI进行

Internal Reference (contributor use; not skill usage paths)

内部参考(贡献者使用;非技能使用路径)

  • skills/ae-generate-tracking-plan/references/te-api.md
    — AE backend endpoint capture documentation
  • skills/ae-generate-tracking-plan/references/xlsx-schema.md
    — xlsx format contract (writer rules + reader compatibility)
  • skills/ae-generate-tracking-plan/references/autotrack-events.md
    — SDK auto-track event definitions (per-platform event lists + SDK type mapping)
  • skills/ae-generate-tracking-plan/references/business-dimension-mapping.md
    — Business dimension → event/property mapping table (revenue model / functional entries / currency system → injected events)
  • src/plan/types.ts
    — Draft TypeScript type definitions
  • skills/ae-generate-tracking-plan/references/te-api.md
    — AE后端端点捕获文档
  • skills/ae-generate-tracking-plan/references/xlsx-schema.md
    — Excel格式契约(写入规则 + 读取兼容性)
  • skills/ae-generate-tracking-plan/references/autotrack-events.md
    — SDK自动采集事件定义(按平台事件列表 + SDK类型映射)
  • skills/ae-generate-tracking-plan/references/business-dimension-mapping.md
    — 业务维度→事件/属性映射表(收入模型 / 功能入口 / 货币体系→注入事件)
  • src/plan/types.ts
    — 草稿TypeScript类型定义