行为统计接口
用户行为事件相关的 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"
}
]