grafana/public/app/core/services/analytics.js
Torkel Ödegaard ca84ef38f8 angular2 test
2015-12-16 12:21:13 +01:00

28 lines
577 B
JavaScript

define([
'angular',
'../core_module',
],
function(angular, coreModule) {
'use strict';
coreModule.default.service('googleAnalyticsSrv', function($rootScope, $location) {
var first = true;
this.init = function() {
$rootScope.$on('$viewContentLoaded', function() {
// skip first
if (first) {
first = false;
return;
}
window.ga('send', 'pageview', { page: $location.url() });
});
};
}).run(function(googleAnalyticsSrv) {
if (window.ga) {
googleAnalyticsSrv.init();
}
});
});