funel data

This commit is contained in:
2025-03-11 00:36:22 +08:00
parent 7857a9007a
commit bc42ff4dbf
13 changed files with 2171 additions and 11 deletions

View File

@@ -231,15 +231,39 @@ const Analytics: React.FC = () => {
}
]);
// Set mock funnel data
setFunnelData([
{ stage: 'Awareness', count: 10000, rate: 100 },
{ stage: 'Interest', count: 7500, rate: 75 },
{ stage: 'Consideration', count: 5000, rate: 50 },
{ stage: 'Intent', count: 3000, rate: 30 },
{ stage: 'Evaluation', count: 2000, rate: 20 },
{ stage: 'Purchase', count: 1000, rate: 10 }
]);
// 尝试从API获取漏斗数据
try {
// 这里使用一个示例项目ID实际使用时应该从props或状态中获取
const projectId = '1';
const response = await fetch(`http://localhost:4000/api/analytics/project/${projectId}/conversion-funnel?timeRange=${timeRange}`);
if (response.ok) {
const data = await response.json();
setFunnelData(data.funnel_data || []);
} else {
console.error('Failed to fetch funnel data from API, using mock data instead');
// 使用模拟数据作为后备
setFunnelData([
{ stage: 'Awareness', count: 10000, rate: 100 },
{ stage: 'Interest', count: 7500, rate: 75 },
{ stage: 'Consideration', count: 5000, rate: 50 },
{ stage: 'Intent', count: 3000, rate: 30 },
{ stage: 'Evaluation', count: 2000, rate: 20 },
{ stage: 'Purchase', count: 1000, rate: 10 }
]);
}
} catch (error) {
console.error('Error fetching funnel data:', error);
// 使用模拟数据作为后备
setFunnelData([
{ stage: 'Awareness', count: 10000, rate: 100 },
{ stage: 'Interest', count: 7500, rate: 75 },
{ stage: 'Consideration', count: 5000, rate: 50 },
{ stage: 'Intent', count: 3000, rate: 30 },
{ stage: 'Evaluation', count: 2000, rate: 20 },
{ stage: 'Purchase', count: 1000, rate: 10 }
]);
}
setLoading(false);
} catch (error) {