Made Google Analytics configurable, removed it outside of production, and corrected several namespace errors.

This commit is contained in:
Peter Deltchev 2015-10-23 19:44:20 -07:00
parent a4c24a7d64
commit dc7c2786a8
11 changed files with 61 additions and 38 deletions

View file

@ -28,4 +28,16 @@ return [
'sendfile' => env('USE_SENDFILE', true), 'sendfile' => env('USE_SENDFILE', true),
/*
|--------------------------------------------------------------------------
| Google Analytics ID
|--------------------------------------------------------------------------
|
| If provided, Pony.fm will track activity in the given Google Analytics
| profile.
|
*/
'google_analytics_id' => env('GOOGLE_ANALYTICS_ID', null),
]; ];

View file

@ -1,6 +1,6 @@
<?php <?php
use App\Track; use Poniverse\Ponyfm\Track;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
class CreateTrackHashes extends Migration class CreateTrackHashes extends Migration

View file

@ -1,6 +1,6 @@
<?php <?php
use App\Track; use Poniverse\Ponyfm\Track;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
class UpdateTrackHash extends Migration class UpdateTrackHash extends Migration

View file

@ -1,6 +1,6 @@
<?php <?php
use App\Track; use Poniverse\Ponyfm\Track;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;

View file

@ -2,10 +2,11 @@ window.pfm.preloaders = {}
module = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'pasvaz.bindonce', 'angularytics'] module = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'pasvaz.bindonce', 'angularytics']
if window.pfm.environment == 'production'
module.run [ module.run [
'Angularytics', 'Angularytics',
(analyitcs) -> (analytics) ->
analyitcs.init() analytics.init()
] ]
module.config [ module.config [
@ -26,6 +27,7 @@ module.config [
'/templates/directives/*' '/templates/directives/*'
] ]
if window.pfm.environment == 'production'
analytics.setEventHandlers ['Google'] analytics.setEventHandlers ['Google']
# Errors # Errors

View file

@ -22,3 +22,5 @@ PONI_CLIENT_ID=null
PONI_CLIENT_SECRET=null PONI_CLIENT_SECRET=null
PONYFM_DATASTORE=null PONYFM_DATASTORE=null
GOOGLE_ANALYTICS_ID=null

View file

@ -22,3 +22,5 @@ PONI_CLIENT_ID=
PONI_CLIENT_SECRET= PONI_CLIENT_SECRET=
PONYFM_DATASTORE=/vagrant-files PONYFM_DATASTORE=/vagrant-files
GOOGLE_ANALYTICS_ID=UA-29463256-1

Binary file not shown.

View file

@ -32,7 +32,7 @@
@if (Auth::check()) @if (Auth::check())
<div class="user-details dropdown"> <div class="user-details dropdown">
<a class="avatar dropdown-toggle" href="#"> <a class="avatar dropdown-toggle" href="#">
<img src="{{Auth::user()->getAvatarUrl(\App\Image::THUMBNAIL)}}" /> <img src="{{Auth::user()->getAvatarUrl(\Poniverse\Ponyfm\Image::THUMBNAIL)}}" />
<span><i class="icon-chevron-down"></i></span> <span><i class="icon-chevron-down"></i></span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
@ -112,14 +112,16 @@
@else @else
isLogged: false isLogged: false
@endif @endif
} },
environment: "{{ App::environment() }}"
}; };
</script> </script>
@if(config('ponyfm.google_analytics_id'))
<script> <script>
{{-- Google Analytics --}} {{-- Google Analytics --}}
var _gaq = _gaq || []; var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']); _gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']); _gaq.push(['_setDomainName', 'pony.fm']);
(function() { (function() {
@ -128,6 +130,7 @@
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); })();
</script> </script>
@endif
{!! Assets::scriptIncludes() !!} {!! Assets::scriptIncludes() !!}

View file

@ -26,7 +26,7 @@
<div class="player loading {{Auth::check() ? 'can-favourite' : ''}} {{$user['is_favourited'] ? 'favourited' : ''}}" data-track-id="{{ $track->id }}" data-duration="{{ $track->duration * 1000 }}"> <div class="player loading {{Auth::check() ? 'can-favourite' : ''}} {{$user['is_favourited'] ? 'favourited' : ''}}" data-track-id="{{ $track->id }}" data-duration="{{ $track->duration * 1000 }}">
<div class="play" disabled="disabled"> <div class="play" disabled="disabled">
<div class="button"><i class="icon-play"></i></div> <div class="button"><i class="icon-play"></i></div>
<img src="{{ $track->getCoverUrl(\App\Image::SMALL) }}" /> <img src="{{ $track->getCoverUrl(\Poniverse\Ponyfm\Image::SMALL) }}" />
</div> </div>
<div class="meta"> <div class="meta">
@if (Auth::check()) @if (Auth::check())
@ -52,9 +52,10 @@
{!! Assets::scriptIncludes('embed') !!} {!! Assets::scriptIncludes('embed') !!}
@if(config('ponyfm.google_analytics_id'))
<script type="text/javascript"> <script type="text/javascript">
var _gaq = _gaq || []; var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']); _gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']); _gaq.push(['_setDomainName', 'pony.fm']);
_gaq.push(['_trackPageview']); _gaq.push(['_trackPageview']);
@ -64,5 +65,6 @@
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); })();
</script> </script>
@endif
</body> </body>
</html> </html>