veza/apps/web/src/services/analyticsService.ts
2026-01-07 19:39:21 +01:00

55 lines
1.9 KiB
TypeScript

const MOCK_GLOBAL_STATS = {
total_users: 12500,
total_tracks: 3420,
total_plays: 1205430,
total_revenue: 14250.50,
followers: 24500,
profile_views: 45200,
trends: { plays: 8.2, revenue: 12.5, followers: 2.1, views: -2.4 },
sparklines: {
plays: [40, 35, 50, 60, 55, 70, 80, 75, 90],
revenue: [10, 12, 15, 14, 18, 20, 22, 25, 28],
followers: [20, 21, 21, 22, 22, 23, 23, 24, 24],
views: [50, 48, 45, 42, 40, 43, 41, 40, 38]
}
};
const TOP_TRACKS = [
{ id: 't1', title: 'Neon Nights', plays: 15420, change: 12, revenue: 145.50 },
{ id: 't2', title: 'Cyber City', plays: 12100, change: -5, revenue: 98.20 },
{ id: 't3', title: 'System Failure', plays: 8500, change: 24, revenue: 65.00 },
{ id: 't4', title: 'Mainframe', plays: 6200, change: 8, revenue: 42.10 },
];
export const analyticsService = {
recordEvent: async (_eventName: string, _payload: any) => {
// Analytics events are handled by the analytics service
return Promise.resolve();
},
getGlobalStats: async (_range: string = '30d') => {
await new Promise(resolve => setTimeout(resolve, 600));
return MOCK_GLOBAL_STATS;
},
getTopTracks: async (_range: string = '30d') => {
await new Promise(resolve => setTimeout(resolve, 500));
return TOP_TRACKS;
},
getTrafficSources: async () => {
await new Promise(resolve => setTimeout(resolve, 400));
return [
{ label: 'Direct', val: 45, color: 'bg-kodo-cyan' },
{ label: 'Social Media', val: 30, color: 'bg-kodo-magenta' },
{ label: 'Search', val: 15, color: 'bg-kodo-lime' },
{ label: 'Referral', val: 10, color: 'bg-kodo-gold' },
];
},
getDeviceBreakdown: async () => {
await new Promise(resolve => setTimeout(resolve, 400));
return { mobile: 65, desktop: 35 };
}
};