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
@ -23,4 +23,4 @@ class CreateTrackHashes extends Migration
$table->dropColumn('hash');
});
}
}
}

View file

@ -1,6 +1,6 @@
<?php
use App\Track;
use Poniverse\Ponyfm\Track;
use Illuminate\Database\Migrations\Migration;
class UpdateTrackHash extends Migration
@ -16,4 +16,4 @@ class UpdateTrackHash extends Migration
public function down()
{
}
}
}

View file

@ -1,6 +1,6 @@
<?php
use App\Track;
use Poniverse\Ponyfm\Track;
use Illuminate\Database\Migrations\Migration;
@ -52,4 +52,4 @@ class CreateTrackFilesTable extends Migration
Schema::drop('track_files');
}
}
}

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

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,22 +112,25 @@
@else
isLogged: false
@endif
}
},
environment: "{{ App::environment() }}"
};
</script>
<script>
{{-- Google Analytics --}}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']);
_gaq.push(['_setDomainName', 'pony.fm']);
@if(config('ponyfm.google_analytics_id'))
<script>
{{-- Google Analytics --}}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']);
(function() {
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';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
(function() {
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';
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,17 +52,19 @@
{!! Assets::scriptIncludes('embed') !!}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']);
_gaq.push(['_setDomainName', 'pony.fm']);
_gaq.push(['_trackPageview']);
@if(config('ponyfm.google_analytics_id'))
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ config('ponyfm.google_analytics_id') }}']);
_gaq.push(['_setDomainName', 'pony.fm']);
_gaq.push(['_trackPageview']);
(function() {
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';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
(function() {
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';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
@endif
</body>
</html>