# Analytics Chinese Business Labels Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Make the behavior analytics page display Chinese business descriptions for events, pages, buttons, preferences, and API calls.

**Architecture:** Add a backend analytics dictionary that enriches aggregation DTOs with Chinese labels, add request-level API analytics in the mini program, and update web-admin to consume label fields and show an API call panel.

**Tech Stack:** Spring Boot, MyBatis Plus, Vue 3, Element Plus, ECharts, uni-app mini program.

---

### Task 1: Backend Analytics Dictionary

**Files:**
- Create: `server/src/main/java/com/emotion/service/analytics/AnalyticsDictionary.java`
- Modify: `server/src/main/java/com/emotion/dto/response/analytics/AnalyticsTopEventItem.java`
- Modify: `server/src/main/java/com/emotion/dto/response/analytics/AnalyticsTrendItem.java`
- Modify: `server/src/main/java/com/emotion/dto/response/analytics/AnalyticsPreferenceItem.java`

- [x] Add event, event type, page, dimension, value, and API label maps.
- [x] Add DTO fields for Chinese labels while keeping original keys.
- [x] Add helper methods for page and API labels.

### Task 2: Backend Aggregation Enrichment

**Files:**
- Modify: `server/src/main/java/com/emotion/mapper/AnalyticsEventMapper.java`
- Modify: `server/src/main/java/com/emotion/service/impl/AnalyticsServiceImpl.java`

- [x] Query `page_path` and `api_path` for top events.
- [x] Fill `eventLabel`, `eventTypeLabel`, `pageLabel`, `apiLabel` in top events.
- [x] Fill trend event labels and preference labels.
- [x] Replace funnel labels with Chinese labels.

### Task 3: Mini Program API Analytics

**Files:**
- Modify: `mini-program/src/services/request.js`

- [x] Add API label map.
- [x] Track `api_request_success` and `api_request_fail`.
- [x] Include path, method, status, label, and duration.
- [x] Skip `/analytics/events/batch`.

### Task 4: Admin Analytics Page

**Files:**
- Modify: `web-admin/src/api/analytics.ts`
- Modify: `web-admin/src/views/analytics/AnalyticsDashboard.vue`

- [x] Add TypeScript fields for backend labels.
- [x] Render chart legend with `eventLabel`.
- [x] Replace all visible analytics text with Chinese.
- [x] Add API call table using top events filtered by `api` type.
- [x] Show Chinese page and preference labels.

### Task 5: Verification

**Commands:**
- `cd server && mvn test`
- `cd web-admin && npm run build`
- `cd mini-program && npm run build:mp-weixin` or available project build command
- `git diff --check`

- [x] Backend tests pass.
- [x] web-admin build passes.
- [x] mini-program build/check passes.
- [x] Diff check has no new whitespace errors.
