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),
/*
|--------------------------------------------------------------------------
| 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
use App\Track;
use Poniverse\Ponyfm\Track;
use Illuminate\Database\Migrations\Migration;
class CreateTrackHashes extends Migration

View file

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

View file

@ -1,6 +1,6 @@
<?php
use App\Track;
use Poniverse\Ponyfm\Track;
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']
if window.pfm.environment == 'production'
module.run [
'Angularytics',
(analyitcs) ->
analyitcs.init()
(analytics) ->
analytics.init()
]
module.config [
@ -26,6 +27,7 @@ module.config [
'/templates/directives/*'
]
if window.pfm.environment == 'production'
analytics.setEventHandlers ['Google']
# Errors

View file

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

View file

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

Binary file not shown.

View file

@ -32,7 +32,7 @@
@if (Auth::check())
<div class="user-details dropdown">
<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>
</a>
<ul class="dropdown-menu">
@ -112,14 +112,16 @@
@else
isLogged: false
@endif
}
},
environment: "{{ App::environment() }}"
};
</script>
@if(config('ponyfm.google_analytics_id'))
<script>
{{-- Google Analytics --}}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']);
_gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']);
(function() {
@ -128,6 +130,7 @@
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
@endif
{!! 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="play" disabled="disabled">
<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 class="meta">
@if (Auth::check())
@ -52,9 +52,10 @@
{!! Assets::scriptIncludes('embed') !!}
@if(config('ponyfm.google_analytics_id'))
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']);
_gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']);
_gaq.push(['_trackPageview']);
@ -64,5 +65,6 @@
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
@endif
</body>
</html>