Skip to content

Commit 807bf60

Browse files
committed
Implemented Google Analytics
1 parent 4fc88ad commit 807bf60

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/app/app.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ angular.module('spotmop', [
6666
/**
6767
* Global controller
6868
**/
69-
.controller('ApplicationController', function ApplicationController( $scope, $rootScope, $state, $localStorage, $timeout, $location, SpotifyService, MopidyService, EchonestService, PlayerService, SettingsService, NotifyService, PusherService, DialogService, Analytics ){
69+
.controller('ApplicationController', function ApplicationController( $scope, $rootScope, $state, $localStorage, $timeout, $location, SpotifyService, MopidyService, EchonestService, PlayerService, SettingsService, NotifyService, PusherService, DialogService, Analytics ){
7070

71-
// track this navigation event
72-
Analytics.trackEvent('Core', 'Spotmop', 'Started');
71+
// track core started
72+
Analytics.trackEvent('Spotmop', 'Started');
7373

7474
$scope.isTouchDevice = function(){
7575
if( SettingsService.getSetting('emulateTouchDevice',false) )
@@ -158,9 +158,10 @@ angular.module('spotmop', [
158158
}
159159
});
160160

161-
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
161+
// when we navigate to a new state
162+
$rootScope.$on('$stateChangeStart', function(event){
162163
$scope.hideMenu();
163-
BackgroundCheck.refresh();
164+
Analytics.trackPage( $location.path() );
164165
});
165166

166167
$(document).on('click', '#body', function(event){
@@ -185,7 +186,7 @@ angular.module('spotmop', [
185186
$scope.searchSubmit = function( query ){
186187

187188
// track this navigation event
188-
Analytics.trackEvent('Search', 'Search performed', query);
189+
Analytics.trackEvent('Search', 'Performed search', query);
189190

190191
// see if spotify recognises this query as a spotify uri
191192
var uriType = SpotifyService.uriType( query );
@@ -246,6 +247,7 @@ angular.module('spotmop', [
246247
* Mopidy music player is open for business
247248
**/
248249
$scope.$on('mopidy:state:online', function(){
250+
Analytics.trackEvent('Mopidy', 'Online');
249251
$rootScope.mopidyOnline = true;
250252
MopidyService.getCurrentTlTracks().then( function( tlTracks ){
251253
$scope.currentTracklist = tlTracks;
@@ -269,6 +271,7 @@ angular.module('spotmop', [
269271
.then( function(response){
270272
$scope.spotifyUser = response;
271273
SettingsService.setSetting('spotifyuser', $scope.spotifyUser);
274+
Analytics.trackEvent('Spotify', 'Online', response.id +'('+ response.display_name +')');
272275

273276
// update my playlists
274277
$scope.updatePlaylists();
@@ -286,8 +289,10 @@ angular.module('spotmop', [
286289

287290
// if we have no client name, then initiate initial setup
288291
var client = SettingsService.getSetting('pushername', null);
289-
if( typeof(client) === 'undefined' || !client || client == '' )
292+
if( typeof(client) === 'undefined' || !client || client == '' ){
290293
DialogService.create('initialsetup', $scope);
294+
Analytics.trackEvent('Core', 'Initial setup');
295+
}
291296
});
292297

293298
$rootScope.$on('spotmop:pusher:received', function(event, data){
@@ -298,6 +303,8 @@ angular.module('spotmop', [
298303
icon = data.spotifyuser.images[0].url;
299304

300305
NotifyService.browserNotify( data.title, data.body, icon );
306+
307+
Analytics.trackEvent('Pusher', 'Notification received', data.body);
301308
});
302309

303310

0 commit comments

Comments
 (0)