feat(analytics): 看板v2全平台口径——默认双渠道合计/拆分小字/双线趋势/跳转带query预选
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,9 @@ import type { Channel, Page } from './types'
|
||||
|
||||
export type { Channel }
|
||||
export type Scope = 'today' | 'week' | 'month'
|
||||
// 看板 v2(2026-09-07):overview 渠道参数支持 'all'=全平台(后端译成
|
||||
// channel=None);列表页(churn/unreplied)仍是单渠道,沿用 types.ts 的 Channel
|
||||
export type DashboardChannel = 'all' | Channel
|
||||
|
||||
export interface OverviewCards {
|
||||
msg_total: number
|
||||
@@ -27,15 +30,20 @@ export interface StaffRankingRow {
|
||||
call_cnt: number; msg_delta: number | null
|
||||
}
|
||||
export interface ActionCounts { unreplied_2h: number; churn_real_30d: number; sensitive_pending: number }
|
||||
// by_channel/trend_by_channel 仅 channel='all' 时后端才返回(可选字段);
|
||||
// 渠道趋势序列 call_cnt 恒 0——通话量无渠道语义不拆,总量走 trend
|
||||
export interface PerChannelCards { msg_total: number; active_customers: number; first_contact: number }
|
||||
export interface OverviewResp {
|
||||
scope: Scope
|
||||
channel: Channel
|
||||
channel: Channel | 'all'
|
||||
days: number[]
|
||||
cards: OverviewCards
|
||||
trend: TrendPoint[]
|
||||
anomaly: Anomaly | null
|
||||
staff_ranking: StaffRankingRow[]
|
||||
actions: ActionCounts
|
||||
by_channel?: { wechat: PerChannelCards; whatsapp: PerChannelCards }
|
||||
trend_by_channel?: { wechat: TrendPoint[]; whatsapp: TrendPoint[] }
|
||||
}
|
||||
export interface HealthResp { data_as_of: number | null; entities: { table: string; last_seen: string | null }[] }
|
||||
export interface ChurnRow {
|
||||
@@ -56,7 +64,7 @@ export interface SensitiveHitRow {
|
||||
room_id: string | null; ts: number | null; snippet: string | null; disposition: string
|
||||
}
|
||||
|
||||
export const getOverview = (channel: Channel, scope: Scope) =>
|
||||
export const getOverview = (channel: DashboardChannel, scope: Scope) =>
|
||||
getJson<OverviewResp>('/analytics/overview', { channel, scope })
|
||||
export const getAnalyticsHealth = () => getJson<HealthResp>('/analytics/health')
|
||||
export const getChurn = (params: Record<string, unknown>) =>
|
||||
|
||||
Reference in New Issue
Block a user