feat(ECR-016): UserIntelligence 用户洞察只读切片并 Closed
聚合 GET /admin/users/:id/insight(报告类型/派生标签/行为快照),admin-h5 洞察 Tab;无 migration / 无 UGC / 无真支付。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -31,7 +31,17 @@ async function request<T>(method: string, path: string, body?: unknown): Promise
|
||||
headers,
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
})
|
||||
const env = (await res.json()) as ApiEnvelope<T>
|
||||
const text = await res.text()
|
||||
let env: ApiEnvelope<T>
|
||||
try {
|
||||
env = JSON.parse(text) as ApiEnvelope<T>
|
||||
} catch {
|
||||
throw new Error(
|
||||
res.status === 404
|
||||
? `接口不存在或后端未更新(${path})`
|
||||
: `响应不是 JSON(HTTP ${res.status})`,
|
||||
)
|
||||
}
|
||||
if (!res.ok || env.code !== 0) {
|
||||
throw new Error(env.message || `HTTP ${res.status}`)
|
||||
}
|
||||
@@ -130,6 +140,18 @@ export const adminApi = {
|
||||
created_at: string
|
||||
}>
|
||||
}>('GET', `/users/${id}/status-transitions`),
|
||||
userInsight: (id: string) =>
|
||||
request<{
|
||||
user_id: string
|
||||
profiles_count: number
|
||||
reports_by_type: Array<{ type: string; count: number }>
|
||||
recent_reports: Array<{ id: string; type: string; created_at: string }>
|
||||
tags: Array<{ code: string; label: string }>
|
||||
behavior: {
|
||||
events: Array<{ name: string; page_path?: string; received_at: string }>
|
||||
ask_thread_count: number
|
||||
}
|
||||
}>('GET', `/users/${id}/insight`),
|
||||
grant: (id: string, plan: string) =>
|
||||
request<{ ok: boolean }>('POST', `/users/${id}/membership/grant`, { plan }),
|
||||
grantAskQuota: (id: string, delta: number) =>
|
||||
|
||||
Reference in New Issue
Block a user