Skip to content

行为统计接口

用户行为事件相关的 API 接口。

记录登录事件

记录用户登录事件。

请求

http
POST /api/behavior/login
Authorization: Bearer <token>
Content-Type: application/json

请求体

json
{
  "location": "北京市海淀区"
}

响应

成功 (200):

json
{
  "code": 0,
  "message": "登录事件记录成功"
}

记录通用事件

记录用户行为事件。

请求

http
POST /api/behavior/events
Authorization: Bearer <token>
Content-Type: application/json

请求体

json
{
  "eventType": "language_choice",
  "eventValue": "zh-CN"
}

支持的事件类型

eventType说明eventValue 示例
translation_on翻译开关true / false
voice_provider语音服务商tencent / iflytek
language_choice语言选择zh-CN / en-US
ambient_sound环境音enabled / disabled
subtitle_layout字幕布局top / bottom
volume_detection音量检测auto / manual

响应

成功 (200):

json
{
  "code": 0,
  "message": "事件记录成功"
}

获取登录记录

获取用户的登录事件列表。

请求

http
GET /api/behavior/login
Authorization: Bearer <token>

响应

成功 (200):

json
[
  {
    "eventId": 1,
    "eventType": "login",
    "eventValue": null,
    "location": "北京市海淀区",
    "createdAt": "2026-01-29T10:30:00Z"
  }
]

获取统计数据

获取用户的所有行为事件统计。

请求

http
GET /api/behavior/stats
Authorization: Bearer <token>

响应

成功 (200):

json
{
  "loginCount": 15,
  "events": [
    {
      "eventType": "language_choice",
      "count": 3,
      "lastValue": "zh-CN"
    },
    {
      "eventType": "voice_provider",
      "count": 2,
      "lastValue": "tencent"
    }
  ]
}

获取特定类型事件

获取翻译事件

http
GET /api/behavior/translation
Authorization: Bearer <token>

获取语音服务商事件

http
GET /api/behavior/voice-provider
Authorization: Bearer <token>

获取语言选择事件

http
GET /api/behavior/language-choice
Authorization: Bearer <token>

响应格式

json
[
  {
    "eventId": 1,
    "eventType": "language_choice",
    "eventValue": "zh-CN",
    "location": null,
    "createdAt": "2026-01-29T10:30:00Z"
  }
]

Mooting 开发者文档