ae-generate-tracking-code
Interactive generation of AE tracking code, LogBus2 configuration, and debug scripts from a tracking plan. Trigger words: 代码埋点、埋点代码、tracking code、埋点落地、logbus 配置、AE 上报代码、generate tracking code、insert tracking、トラッキングコード、트래킹 코드. Supports independent output mode selection per platform (insert/snippet).
By thinkingaiagenticengine · 453 installs
npx skills add thinkingaiagenticengine/ae-cli --skill ae-generate-tracking-code
Source repository · Upstream listing
ae generate tracking code
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, code comments, etc.
⚠️ CRITICAL: Many reference documents (wiki SDK docs, code examples) contain Chinese text. When reading Chinese source material to answer an English/Japanese user, you MUST translate headings, descriptions, and comments to the user's language. The source document's language is NOT the user's language. Use the Terminology Glossary above to map terms accurately.
Do NOT copy Chinese text verbatim from this document into English/Japanese replies.
Document link language : When providing official documentation URLs, use lan=zh CN for Chinese users, lan=en US for all others.
Terminology Glossary
中文 English Notes
埋点方案 Tracking Plan AE project level event/property definitions
代码埋点 Tracking Code Generation Generating SDK/LogBus code from a plan
埋点代码 Tracking Code The generated SDK init + track() calls + helpers
输出方式 Output Mode insert (inject) or snippet (file delivery)
插入 Insert Direct code injection into the user's project
片段 / 代码片段 Snippet Code delivered as files under .ae cli/output/
采集端 Collection Platform / Platform Where events are sent from: client, server, or both
客户端 Client Client side SDK (Android/iOS/Web/etc.)
服务端 Server Server side SDK (Java/Python/Go/etc.)
两端都采集 Both Events collected from both client and server
SDK 集成模式 SDK Integration Mode client only / server only / both
用户体系 User Identity System distinct id / account id strategy
校验脚本 Validation / Debug Script Test code to verify tracking works
LogBus2 配置 LogBus2 Configuration daemon.json for LogBus2 log sync tool
LoggerConsumer LoggerConsumer Server SDK consumer that writes events to local log files
BatchConsumer BatchConsumer Server SDK consumer that uploads events in batches
公共属性 Super Property Properties attached to all events automatically. ⚠️ The correct Chinese AE term is "公共属性" or "公共事件属性". Never translate "Super Property" as "超级属性" — that is NOT a valid AE term.
预置属性 Preset Property System properties prefixed with (e.g. device id , time )
事件属性 Event Property Custom properties on specific events
用户属性 User Property Properties set on the user profile
上报地址 SERVER URL Data ingestion endpoint (different from web URL!)
APP ID APP ID Application ID from AE Admin → "Integration Config"
project id Project ID AE project identifier (≠ APP ID)
自动采集 Auto track Auto collected events (app install, start, view, click)
埋点方案上传 Plan Upload Upload tracking plan xlsx to AE
When to Trigger
Trigger when user says: "generate tracking code / help me add web tracking / generate logbus config / server side reporting code" etc. Supports multiple platforms with independent output mode selection per platform.
Phase 0 — Anchor (one question per message)
Pre check: Read existing configuration from draft.json
First, check if .ae cli/draft.json exists and read existing configuration:
Config Item draft.json Field Handling
AE projectId meta.project id Has value → confirm; missing → ask
AE web address meta.host Has value → confirm; missing → ask
SERVER URL meta.server url Has value → confirm; missing → try lookup from project config, then ask if unavailable
APP ID meta.app id Has value → confirm; missing → try lookup from accessible project list, then ask if unavailable
SDK integration mode meta.sdk integration mode Has value → use directly
Client SDK type meta.client platforms (preferred) or meta.client sdk type Has value → use directly
Server language meta.server language Has value → use directly
User identity system meta.user identity Has value → use directly
Important : project id ≠ APP ID , and host ≠ SERVER URL . Even if project id and host are already set, SERVER URL and APP ID must still be resolved and confirmed separately. Prefer lookup first; ask the user only when lookup is unavailable or ambiguous.
Multi platform support :
If client platforms exists (array): multi platform scenario — generate code for each platform
If only client sdk type exists: single platform (backward compatible)
Example: client platforms: ["android", "openharmony"] → generate code for Android + OpenHarmony
Language support :
Android SDK: supports Java / Kotlin (can generate both)
iOS SDK: supports Objective C / Swift (can generate both)
Other SDKs: fixed language, no selection needed
Language configuration source :
Prefer meta.client platform languages (e.g. {"android": ["java", "kotlin"]} )
If not configured, ask user for Android/iOS platforms only
Confirmation flow :
Has value → ask "Confirm using draft.json config: <value ? yes / enter new value"
User says yes → use draft value
User enters new value → update draft.json and use new value
Required configuration (must resolve and confirm each item)
⚠️ Key: SERVER URL and APP ID are independent config items. Even if draft.json has project id and host, you MUST resolve and confirm them. project id ≠ APP ID , host ≠ SERVER URL .
1. APP ID — Prefer automatic lookup before asking:
If meta.project id is known, run ae cli project info list once for the current host.
Find the project whose projectId matches meta.project id .
If the matched project has appId , ask: "I found APP ID <appId for project <projectId . Use it? yes / enter new value"
If the project is missing, ambiguous, or has no appId , ask the user to copy APP ID from AE Admin → "Project Settings" → "Integration Config".
2. SERVER URL — Data ingestion endpoint ( different from web URL ; go to AE Admin → "Project Settings" → "Integration Config" → fill in "Public URL")
If meta.project id is known, you may try ae cli project info get project id <project id once.
Use the returned value only if the response explicitly contains a receiver URL field such as serverUrl , pushUrl , push url , receiverUrl , publicUrl , publicReceiverAddress , privateReceiverAddress , or equivalent ingestion endpoint field.
If both publicReceiverAddress and privateReceiverAddress are present, prefer publicReceiverAddress as SERVER URL for generated snippets unless the user explicitly needs an internal/private network receiver.
If a value is found, ask: "I found SERVER URL <url for project <projectId . Use it? yes / enter new value"
⚠️ "Public URL" only shows if previously filled in; if empty, this field won't display
Solution: ask ops for the URL, or skip this step (use SERVER URL or PUSH URL placeholder in code)
host handling (optional):
If you need to fetch plan from AE (no local draft.json) → ask for host
If local draft.json exists → host is not required for code generation
Before Debug validation, run ae cli config current and confirm the active host matches the target AE environment; if it does not, run ae cli config set host <AE HOST
Complete Debug validation with ae cli tracking debug device and ae cli tracking debug data by default; only hint the user to open the AE Debug page when those CLI capabilities are unavailable
If only xlsx file exists (no draft.json)
First, check if both .ae cli/draft.json and .ae cli/draft.xlsx exist:
If both are missing — the current environment hasn't generated a tracking plan yet. Remind user of two options:
1. Do you need to generate a tracking plan first?
Yes → suggest using ae generate tracking plan skill
Reference: tracking plan document (Feishu: https://www.feishu.cn/docx/Jt0VdhNB6oSJ4TxISs1cq2Ebnmg)
2. If you already have a tracking plan
Provide the xlsx file path and use ae cli tracking code import template template to import
Or place the xlsx file at .ae cli/draft.xlsx and re run
If xlsx file exists (provided via ae cli tracking code import template template or placed at .ae cli/draft.xlsx ):
Step 1: Parse the xlsx file
This command:
1. Reads events, event properties, super properties, and user properties from xlsx
2. Infers sdk integration mode from the event platform field
3. Outputs draft.json (meta section has events and plan name only)
Step 2: What can be inferred from xlsx
Field Can Infer? Notes
Event list ✅ From event data sheet
Event property pool ✅ From event data sheet
Super properties ✅ From super property sheet
User properties ✅ From user data sheet
sdk integration mode ⚠️ Limited xlsx "Platform" column can infer (client/server/both); if missing, must ask
client platforms ❌ Must ask user
client platform languages ❌ Must ask user (Android/iOS only)
server language ❌ Must ask user (only if sdk integration mode includes server)
user identity ❌ Must ask user
host / project id ❌ Must ask or skip
"Platform" column parsing rules :
Empty / no column → cannot infer platform; default to client side code generation (backward compatible)
客户端 / client → client only collection, parsed as platform: "client"
服务端 / server → server only collection, parsed as platform: "server"
客户端,服务端 / client,server / 服务端,客户端 / server,client → both platforms, parsed as platform: "both"
Internal representation : xlsx "Platform" column values are parsed by ae cli tracking code import template template into internal platform field values:
client → client side collection
server → server side collection
both → both platforms
Platform filtering during code generation :
Client code: only generate events where platform === "client" or platform === "both"
Server code: only generate events where platform === "server" or platform === "both"
If xlsx has no platform column: generate all events for both client and server (backward compatible)
Step 3: Ask for missing configuration
Ask in order, one item per message:
1. SDK integration mode : ask "Will tracking be reported via client side or server side? client / server / both"
2. Client platform(s) (only if sdk integration mode includes client):
ask "What platform(s) is your app?"
Android / Android SDK
iOS / iOS SDK
OpenHarmony / OpenHarmony SDK (Chinese users only)
Web / H5 (JavaScript SDK)
WeChat Mini program (Mini program SDK) (Chinese users only)
WeChat Mini game (Mini game SDK) (Chinese users only)
Unity Game (Unity SDK)
Cocos Game (CocosCreator / Cocos2d x / Cocos2d Lua / LayaAir — Cocos2d Lua & LayaAir for Chinese users only)
React Native / Flutter / uni app
Other
→ After user selects, only if Android or iOS is selected , follow up:
Android → ask "Which programming language? Java / Kotlin / both"
iOS → ask "Which programming language? Objective C / Swift / both"
3. Server language (only if sdk integration mode includes server):
ask "What is your server side language?"
Java
Python
Go
Node.js
PHP
C / .NET
Other
4. User identity system :
Account ID source: user account / role id / none
Visitor ID strategy: auto / device id / custom
5. APP ID / SERVER URL : resolve them with the lookup first flow above, confirm any found values with the user, and ask only for values that cannot be found or are rejected by the user.
Step 4: Merge configuration and proceed to Phase 1
Write gathered info to .ae cli/draft.json meta section, then proceed to Phase