Files
Krystie 3e4cfcf683 feat: Add comprehensive analytics dashboard for creators
- Create detailed event tracking system (views, watch time, retention, traffic)
- Build channel analytics with daily aggregation
- Implement real-time stats caching
- Add traffic source detection and tracking
- Create audience demographics and retention tracking
- Build creator dashboard with Chart.js visualizations
- Implement automatic video analytics tracker JavaScript
- Add cron script for daily stats aggregation
- Document complete analytics system

Features:
- Channel overview (views, watch time, subscribers, engagement)
- Time series charts with multiple metrics
- Traffic sources breakdown (search, social, direct, etc.)
- Audience demographics (countries, devices, age ranges)
- Top videos by performance metric
- Audience retention graphs (minute-by-minute)
- Real-time viewer statistics
- Automatic tracking (no manual instrumentation)
- Privacy-compliant (hashed IPs, GDPR-ready)
- Production-ready with proper indexing
2026-03-30 17:34:18 -07:00

33 lines
956 B
PHP

<?php
/**
* Aggregate Analytics Daily Stats
* Run via cron once per day (recommended: 1 AM)
*
* Aggregates previous day's analytics into summary tables
*/
require_once dirname(__DIR__, 2) . '/f_core/config.boot.php';
require_once dirname(__DIR__, 2) . '/f_core/f_classes/class.analytics.php';
require_once dirname(__DIR__, 2) . '/f_core/f_classes/class.logger.php';
$logger = new VLogger('analytics_aggregation');
$analytics = new VAnalytics();
$date = $argv[1] ?? date('Y-m-d', strtotime('-1 day'));
$logger->info("Starting analytics aggregation for date: $date");
try {
$result = $analytics->aggregateDailyStats($date);
if ($result) {
$logger->info("Analytics aggregation complete for $date");
} else {
$logger->error("Analytics aggregation failed for $date");
}
} catch (Exception $e) {
$logger->error("Analytics aggregation error: " . $e->getMessage());
}
echo "Done. Aggregated stats for $date\n";