Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow zero timing values to be sent #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions dist/angularytics.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* The solution to tracking page views and events in a SPA with AngularJS
* @version v0.4.0 - 2016-03-03
* @link https://github.com/mgonto/angularytics
* @author Martin Gontovnikas <martin@gonto.com.ar>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
(function () {
angular.module('angularytics', []).provider('Angularytics', function () {
var eventHandlersNames = ['Google'];
Expand All @@ -17,11 +24,16 @@
this.setPageChangeEvent = function (newPageChangeEvent) {
pageChangeEvent = newPageChangeEvent;
};
var pageViewTrackingEnabled = true;
this.disablePageViewTracking = function () {
pageViewTrackingEnabled = false;
};
this.$get = [
'$injector',
'$rootScope',
'$location',
function ($injector, $rootScope, $location) {
// Helper methods
var eventHandlers = [];
angular.forEach(eventHandlersNames, function (handler) {
eventHandlers.push($injector.get('Angularytics' + handler + 'Handler'));
Expand All @@ -32,6 +44,7 @@
});
};
var service = {};
// Just dummy function so that it's instantiated on app creation
service.init = function () {
};
service.trackEvent = function (category, action, opt_label, opt_value, opt_noninteraction) {
Expand All @@ -50,14 +63,17 @@
};
service.trackTiming = function (category, variable, value, opt_label) {
forEachHandlerDo(function (handler) {
if (category && variable && value) {
if (category && variable && angular.isDefined(value)) {
handler.trackTiming(category, variable, value, opt_label);
}
});
};
$rootScope.$on(pageChangeEvent, function () {
service.trackPageView($location.url());
});
// Event listening
if (pageViewTrackingEnabled) {
$rootScope.$on(pageChangeEvent, function () {
service.trackPageView($location.url());
});
}
return service;
}
];
Expand Down
4 changes: 2 additions & 2 deletions dist/angularytics.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/angularytics.zip
Binary file not shown.
Loading