From 17a644c5d82164f48e8f51fa75c23fa33230bc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Tue, 30 Dec 2014 08:11:47 +0100 Subject: [PATCH] Add Google Analytics --- .gitignore | 1 + Gruntfile.js | 22 ++++++++++++++++++---- front/src/js/app.js | 9 +++++++-- front/src/main.html | 10 ++++++++++ package.json | 1 + server_config/settings-prod.json | 10 ++++------ 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 37db380..5b5095f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ bower_components .vagrant results/* coverage +front/build har.json \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 8a4fa1d..f2c3ae6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,14 +1,12 @@ module.exports = function(grunt) { - var DEV_SERVER_PORT = 8383; - var TEST_SERVER_PORT = 8387; - // Tell our Express server that Grunt launched it process.env.GRUNTED = true; // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + settings: grunt.file.readJSON('./server_config/settings.json'), font: { icons: { @@ -37,6 +35,21 @@ module.exports = function(grunt) { ] } }, + replace: { + dist: { + options: { + patterns: [ + { + match: 'googleAnalyticsId', + replacement: '<%= settings.googleAnalyticsId %>' + } + ] + }, + files: [ + {expand: true, flatten: true, src: ['front/src/main.html'], dest: 'front/build/'} + ] + } + }, jshint: { all: [ '*.js', @@ -171,7 +184,8 @@ module.exports = function(grunt) { ]); grunt.registerTask('build', [ - 'less' + 'less', + 'replace' ]); grunt.registerTask('hint', [ diff --git a/front/src/js/app.js b/front/src/js/app.js index 612ad18..445c20c 100644 --- a/front/src/js/app.js +++ b/front/src/js/app.js @@ -12,9 +12,14 @@ var yltApp = angular.module('YellowLabTools', [ 'gradeDirective', ]); -yltApp.run(function($rootScope) { +yltApp.run(['$rootScope', '$location', function($rootScope, $location) { $rootScope.loadedRunId = null; -}); + + // Google Analytics + $rootScope.$on('$routeChangeSuccess', function(){ + ga('send', 'pageview', {'page': $location.path()}); + }); +}]); yltApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { diff --git a/front/src/main.html b/front/src/main.html index 6015d59..8522dcd 100644 --- a/front/src/main.html +++ b/front/src/main.html @@ -35,5 +35,15 @@ + + \ No newline at end of file diff --git a/package.json b/package.json index 6b34d28..80f6fd9 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "grunt-express": "^1.4.1", "grunt-fontsmith": "^0.9.1", "grunt-mocha-test": "^0.12.4", + "grunt-replace": "^0.8.0", "matchdep": "^0.3.0", "mocha": "^2.1.0", "phantomjs": "^1.9.13", diff --git a/server_config/settings-prod.json b/server_config/settings-prod.json index 8d06c6a..6b383c4 100644 --- a/server_config/settings-prod.json +++ b/server_config/settings-prod.json @@ -1,12 +1,10 @@ { "serverPort": 80, - "googleAnalyticsId": "UA-54493828-1", + "googleAnalyticsId": "", - "authorized-keys": { + "authorizedKeys": { }, - "tokenSalt": "", - "authorizedApplications": [ - - ] + "maxAnonymousRunsPerDay": 50, + "maxAnonymousCallsPerDay": 2000 } \ No newline at end of file