track more events

This commit is contained in:
Athou
2013-04-24 12:26:27 +02:00
parent 9dab6fa0fa
commit edb345da9c
3 changed files with 20 additions and 8 deletions

View File

@@ -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() {

View File

@@ -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', {

View File

@@ -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
});