Support for auto download parameter, dynamic OS /get routes, fix for dev analytics

This commit is contained in:
Jeremy Kauffman 2017-12-14 14:02:19 -05:00
parent 74e0a9423b
commit b96d016977
5 changed files with 20 additions and 8 deletions

View file

@ -97,11 +97,10 @@ class Controller
$router->get(['/get', 'get'], 'DownloadActions::executeGet'); $router->get(['/get', 'get'], 'DownloadActions::executeGet');
$router->get(['/getrubin', 'getrubin'], 'DownloadActions::executeGet'); $router->get(['/getrubin', 'getrubin'], 'DownloadActions::executeGet');
$router->get(['/windows', 'get-windows'], 'DownloadActions::executeGet'); foreach(array_keys(OS::getAll()) as $os)
$router->get(['/linux', 'get-linux'], 'DownloadActions::executeGet'); {
$router->get(['/osx', 'get-osx'], 'DownloadActions::executeGet'); $router->get(['/' . $os, 'get-' . $os], 'DownloadActions::executeGet');
$router->get(['/android', 'get-android'], 'DownloadActions::executeGet'); }
$router->get(['/ios', 'get-ios'], 'DownloadActions::executeGet');
$router->get('/roadmap', 'ContentActions::executeRoadmap'); $router->get('/roadmap', 'ContentActions::executeRoadmap');
$router->post('/quickstart/auth', 'DeveloperActions::executeQuickstartAuth'); $router->post('/quickstart/auth', 'DeveloperActions::executeQuickstartAuth');

View file

@ -40,6 +40,7 @@ class DownloadActions extends Actions
'analyticsLabel' => $analyticsLabel, 'analyticsLabel' => $analyticsLabel,
'buttonLabel' => $buttonLabel, 'buttonLabel' => $buttonLabel,
'downloadUrl' => $asset ? $asset['browser_download_url'] : null, 'downloadUrl' => $asset ? $asset['browser_download_url'] : null,
'isAuto' => Request::getParam('auto'),
'os' => $os, 'os' => $os,
'osTitle' => $osTitle, 'osTitle' => $osTitle,
'osIcon' => $osIcon, 'osIcon' => $osIcon,

View file

@ -2,6 +2,9 @@
class OS class OS
{ {
/*
* if changing below constants, you should add permanent redirects for old OS names used in URLs
*/
const OS_ANDROID = 'android', const OS_ANDROID = 'android',
OS_IOS = 'ios', OS_IOS = 'ios',
OS_LINUX = 'linux', OS_LINUX = 'linux',
@ -32,7 +35,7 @@ class OS
case 'pkg': case 'pkg':
return OS::OS_OSX; return OS::OS_OSX;
case 'msi': // fallthrough case 'Fmsi': // fallthrough
case 'exe': case 'exe':
return OS::OS_WINDOWS; return OS::OS_WINDOWS;

View file

@ -21,11 +21,19 @@
<a class="btn-alt btn-large" <a class="btn-alt btn-large"
download download
href="<?php echo $downloadUrl ?>" href="<?php echo $downloadUrl ?>"
id="get-download-btn"
data-facebook-track="1" data-facebook-track="1"
data-analytics-category="Sign Up" data-analytics-category="Sign Up"
data-analytics-action="Download" data-analytics-action="Download"
data-analytics-label="<?php echo $analyticsLabel ?>" data-analytics-label="<?php echo $analyticsLabel ?>"
><?php echo $buttonLabel ?></a> ><?php echo $buttonLabel ?></a>
<?php if ($isAuto): ?>
<?php js_start() ?>
var anchor = document.getElementById('get-download-btn');
ga('send', 'event', anchor.getAttribute('data-analytics-category'), anchor.getAttribute('data-analytics-action'), anchor.getAttribute('data-analytics-label'));
setTimeout(function() { window.location = anchor.getAttribute('href'); }, 500);
<?php js_end() ?>
<?php endif ?>
<br/> <br/>
<span class="meta"> <span class="meta">
<?php echo $version ?>, <?php echo $version ?>,

View file

@ -24,7 +24,8 @@
</script> </script>
<?php else: ?> <?php else: ?>
<?php js_start() ?> <script>
window.ga = function() { };
console.log('Analytics partial skipped because this is a non-production instance.'); console.log('Analytics partial skipped because this is a non-production instance.');
<?php js_end() ?> </script>
<?php endif ?> <?php endif ?>