2021-04-14 15:58:40 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-14 15:58:40 +00:00
|
|
|
/**
|
|
|
|
* @copyright 2021 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Analytics routes file
|
|
|
|
*/
|
|
|
|
|
|
|
|
$routes->addPlaceholder(
|
|
|
|
'class',
|
|
|
|
'\bPodcastByCountry|\bPodcastByEpisode|\bPodcastByHour|\bPodcastByPlayer|\bPodcastByRegion|\bPodcastByService|\bPodcast|\bWebsiteByBrowser|\bWebsiteByEntryPage|\bWebsiteByReferer',
|
|
|
|
);
|
|
|
|
$routes->addPlaceholder(
|
|
|
|
'filter',
|
|
|
|
'\bWeekly|\bYearly|\bByDay|\bByWeekday|\bByMonth|\bByAppWeekly|\bByAppYearly|\bByOsWeekly|\bByDeviceWeekly|\bBots|\bByServiceWeekly|\bBandwidthByDay|\bUniqueListenersByDay|\bUniqueListenersByMonth|\bTotalListeningTimeByDay|\bTotalListeningTimeByMonth|\bByDomainWeekly|\bByDomainYearly',
|
|
|
|
);
|
|
|
|
|
2021-05-19 16:35:13 +00:00
|
|
|
$routes->group('', [
|
|
|
|
'namespace' => 'Analytics\Controllers',
|
|
|
|
], function ($routes): void {
|
|
|
|
$routes->group(config('Analytics')->gateway . '/(:num)/(:class)', function ($routes): void {
|
2021-04-14 15:58:40 +00:00
|
|
|
$routes->get('/', 'AnalyticsController::getData/$1/$2', [
|
|
|
|
'as' => 'analytics-full-data',
|
2021-05-19 16:35:13 +00:00
|
|
|
'filter' => config('Analytics')
|
|
|
|
->routeFilters[
|
2021-04-14 15:58:40 +00:00
|
|
|
'analytics-full-data'
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$routes->get('(:filter)', 'AnalyticsController::getData/$1/$2/$3', [
|
|
|
|
'as' => 'analytics-data',
|
2021-05-19 16:35:13 +00:00
|
|
|
'filter' => config('Analytics')
|
|
|
|
->routeFilters['analytics-data'],
|
2021-04-14 15:58:40 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$routes->get(
|
|
|
|
'(:filter)/(:num)',
|
|
|
|
'AnalyticsController::getData/$1/$2/$3/$4',
|
|
|
|
[
|
|
|
|
'as' => 'analytics-filtered-data',
|
2021-05-19 16:35:13 +00:00
|
|
|
'filter' => config('Analytics')
|
|
|
|
->routeFilters[
|
2021-04-14 15:58:40 +00:00
|
|
|
'analytics-filtered-data'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Route for podcast audio file analytics (/audio/pack(podcast_id,episode_id,bytes_threshold,filesize,duration,date)/podcast_folder/filename.mp3)
|
|
|
|
$routes->head(
|
|
|
|
'audio/(:base64)/(:any)',
|
|
|
|
'EpisodeAnalyticsController::hit/$1/$2',
|
|
|
|
[
|
|
|
|
'as' => 'episode-analytics-hit',
|
|
|
|
],
|
|
|
|
);
|
|
|
|
$routes->get(
|
|
|
|
'audio/(:base64)/(:any)',
|
|
|
|
'EpisodeAnalyticsController::hit/$1/$2',
|
|
|
|
[
|
|
|
|
'as' => 'episode-analytics-hit',
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Show the Unknown UserAgents
|
|
|
|
$routes->get('.well-known/unknown-useragents', 'UnknownUserAgentsController');
|
2021-06-08 09:52:11 +00:00
|
|
|
$routes->get('.well-known/unknown-useragents/(:num)', 'UnknownUserAgentsController/$1');
|