feat(admin): track capture-to-report conversion funnel

This commit is contained in:
xsl
2026-10-16 15:45:13 +08:00
parent 03a8907b4e
commit 9ff7a582af
8 changed files with 222 additions and 0 deletions
+18
View File
@@ -169,6 +169,23 @@ function loadRecords() {
}
/* ═══════════ 失败与异常 ═══════════ */
function renderCaptureFunnel(st) {
var funnel = st.capture_funnel;
var panel = $('#capture-funnel');
if (funnel && panel) {
var labels = [['started','开始拍照'],['front','正面拍完'],['right','右脸拍完'],['left','三张拍完'],['submitted','提交检测'],['response','收到成功结果'],['report','进入报告页']];
var html = '<table><thead><tr><th>阶段</th><th>累计流程</th><th>今日流程</th></tr></thead><tbody>';
labels.forEach(function (row) { html += '<tr><td>' + row[1] + '</td><td>' + funnel.total.counts[row[0]] + '</td><td>' + funnel.today.counts[row[0]] + '</td></tr>'; });
html += '</tbody></table>';
html += '<p class="hint">首次采集:' + (funnel.since ? fmtTime(new Date(funnel.since).toISOString()) : '暂无数据') + '</p>';
[['total','累计'],['today','今日']].forEach(function (row) {
var f = funnel[row[0]];
html += '<p>' + row[1] + ':进入报告转化率 ' + f.rate + '% · 成功进入平均耗时 ' + (f.avg_ms == null ? '—' : (f.avg_ms / 1000).toFixed(1) + ' 秒') +
' · 成功结果但未进入 ' + f.response_without_report + ' · 明确失败 ' + f.counts.failed + ' · 主动取消 ' + f.counts.canceled + ' · 发生后台中断 ' + f.counts.interrupted + ' · 尚未完成 ' + f.unfinished + '</p>';
});
panel.innerHTML = html;
}
}
function loadFails() {
api('/api/admin/stats').then(function (st) {
var box = $('#fail-dist');
@@ -228,6 +245,7 @@ function doRetry(id) {
var PIE_COLORS = ['#2563eb', '#2fa84f', '#f0a020', '#8a5cf6', '#d93026'];
function loadStats() {
api('/api/admin/stats').then(function (st) {
renderCaptureFunnel(st);
var cards = [
['今日检测', st.today_total],
['累计检测', st.total],