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,11 +2,12 @@ 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']
module.run [ if window.pfm.environment == 'production'
'Angularytics', module.run [
(analyitcs) -> 'Angularytics',
analyitcs.init() (analytics) ->
] analytics.init()
]
module.config [ module.config [
'$locationProvider', '$stateProvider', '$dialogProvider', 'AngularyticsProvider', '$httpProvider', '$sceDelegateProvider' '$locationProvider', '$stateProvider', '$dialogProvider', 'AngularyticsProvider', '$httpProvider', '$sceDelegateProvider'
@ -26,7 +27,8 @@ module.config [
'/templates/directives/*' '/templates/directives/*'
] ]
analytics.setEventHandlers ['Google'] if window.pfm.environment == 'production'
analytics.setEventHandlers ['Google']
# Errors # Errors
state.state 'errors-404', state.state 'errors-404',

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,22 +112,25 @@
@else @else
isLogged: false isLogged: false
@endif @endif
} },
environment: "{{ App::environment() }}"
}; };
</script> </script>
<script> @if(config('ponyfm.google_analytics_id'))
{{-- Google Analytics --}} <script>
var _gaq = _gaq || []; {{-- Google Analytics --}}
_gaq.push(['_setAccount', 'UA-29463256-1']); var _gaq = _gaq || [];
_gaq.push(['_setDomainName', 'pony.fm']); _gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']);
(function() { (function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
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,17 +52,19 @@
{!! Assets::scriptIncludes('embed') !!} {!! Assets::scriptIncludes('embed') !!}
<script type="text/javascript"> @if(config('ponyfm.google_analytics_id'))
var _gaq = _gaq || []; <script type="text/javascript">
_gaq.push(['_setAccount', 'UA-29463256-1']); var _gaq = _gaq || [];
_gaq.push(['_setDomainName', 'pony.fm']); _gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_trackPageview']); _gaq.push(['_setDomainName', 'pony.fm']);
_gaq.push(['_trackPageview']);
(function() { (function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
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>