diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index cf9e82b5..86860634 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -201,9 +201,9 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat }]); module.controller('ToolbarCtrl', ['$scope', '$http', '$state', '$stateParams', - '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', + '$route', '$location', 'SettingsService', 'EntryService', 'ProfileService', 'AnalyticsService', function($scope, $http, $state, $stateParams, $route, $location, - SettingsService, EntryService, ProfileService) { + SettingsService, EntryService, ProfileService, AnalyticsService) { function totalActiveAjaxRequests() { return ($http.pendingRequests.length + $.active); @@ -273,6 +273,7 @@ function($scope, $http, $state, $stateParams, $route, $location, $state.transitionTo('feeds.help'); }; $scope.toDonate = function() { + AnalyticsService.track('/donate'); $state.transitionTo('feeds.help'); }; }]); @@ -587,8 +588,11 @@ function($scope, $state, $stateParams, $dialog, AdminUsersService) { }; }]); -module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService', -function($scope, $location, SettingsService) { +module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService', 'AnalyticsService', +function($scope, $location, SettingsService, AnalyticsService) { + + AnalyticsService.track(); + $scope.settingsService = SettingsService; $scope.$watch('settingsService.settings', function(value) { $scope.settings = angular.copy(value); @@ -607,8 +611,11 @@ function($scope, $location, SettingsService) { }; }]); -module.controller('ProfileCtrl', ['$scope', '$location', 'ProfileService', -function($scope, $location, ProfileService) { +module.controller('ProfileCtrl', ['$scope', '$location', 'ProfileService', 'AnalyticsService', +function($scope, $location, ProfileService, AnalyticsService) { + + AnalyticsService.track(); + $scope.user = ProfileService.get(); $scope.cancel = function() { diff --git a/src/main/webapp/js/main.js b/src/main/webapp/js/main.js index 08f7d791..9b4641f3 100644 --- a/src/main/webapp/js/main.js +++ b/src/main/webapp/js/main.js @@ -4,6 +4,10 @@ var app = angular.module('commafeed', [ 'ui', 'ui.bootstrap', 'ui.state', app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider', function($routeProvider, $stateProvider, $urlRouterProvider) { + var trackCtrl = ['AnalyticsService', function(AnalyticsService) { + AnalyticsService.track(); + }]; + $stateProvider.state('feeds', { abstract : true, url : '/feeds', @@ -21,7 +25,8 @@ function($routeProvider, $stateProvider, $urlRouterProvider) { }); $stateProvider.state('feeds.help', { url : '/help', - templateUrl : 'templates/feeds.help.html' + templateUrl : 'templates/feeds.help.html', + controller: trackCtrl }); $stateProvider.state('admin', { diff --git a/src/main/webapp/js/services.js b/src/main/webapp/js/services.js index f6503612..82e2ad5c 100644 --- a/src/main/webapp/js/services.js +++ b/src/main/webapp/js/services.js @@ -2,10 +2,10 @@ var module = angular.module('commafeed.services', [ 'ngResource' ]); module.service('AnalyticsService', [ '$state', function($state) { this.track = function(path) { - path = path || $state.$current.url.prefix; if (!ga) { return; } + path = path || $state.$current.url.prefix; ga('send', 'pageview', { page : path });