Skip to content

Commit

Permalink
chore: bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet committed Jan 22, 2015
1 parent 818c601 commit b532284
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "revolunet",
"name": "angular-google-analytics",
"description": "Easy Analytics for your AngularJS application",
"version": "0.0.9",
"version": "0.0.10",
"homepage": "https://github.com/revolunet/angular-google-analytics",
"repository": {
"type": "git",
Expand Down
51 changes: 47 additions & 4 deletions dist/angular-google-analytics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Angular Google Analytics - Easy tracking for your AngularJS application
* @version v0.0.9 - 2014-11-24
* @version v0.0.10 - 2015-01-22
* @link http://github.com/revolunet/angular-google-analytics
* @author Julien Bouquillon <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -174,6 +174,18 @@ angular.module('angular-google-analytics', [])
created = true;
}

function _generateCommandName(commandName, config) {
if (!angular.isUndefined(config) && 'name' in config && config.name) {
return config.name + '.' + commandName;
} else {
return commandName;
}
}

function _checkOption(key, config) {
return key in config && config[key];
}

function _createAnalyticsScriptTag() {
if (!accountId) {
me._log('warn', 'No account id set to create analytics script tag');
Expand All @@ -188,7 +200,30 @@ angular.module('angular-google-analytics', [])

if (angular.isArray(accountId)) {
accountId.forEach(function (trackerObj) {
$window.ga('create', trackerObj.tracker, cookieConfig, { name: trackerObj.name });
var _cookieConfig = 'cookieConfig' in trackerObj ? trackerObj.cookieConfig : cookieConfig;
var options;
if (_checkOption('crossDomainLinker', trackerObj)) {
trackerObj.allowLinker = trackerObj.crossDomainLinker;
}
angular.forEach(['name', 'allowLinker'], function(key) {
if (key in trackerObj) {
if (angular.isUndefined(options)) {
options = {};
}
options[key] = trackerObj[key];
}
});
if (angular.isUndefined(options)) {
$window.ga('create', trackerObj.tracker, _cookieConfig);
} else {
$window.ga('create', trackerObj.tracker, _cookieConfig, options);
}
if (options && 'allowLinker' in options && options.allowLinker) {
$window.ga(_generateCommandName('require', trackerObj), 'linker');
if (_checkOption('crossLinkDomains', trackerObj)) {
$window.ga(_generateCommandName('linker:autoLink', trackerObj), trackerObj.crossLinkDomains);
}
}
});
} else if (crossDomainLinker) {
$window.ga('create', accountId, cookieConfig, linkerConfig);
Expand Down Expand Up @@ -281,7 +316,7 @@ angular.module('angular-google-analytics', [])
_analyticsJs(function () {
if (angular.isArray(accountId)) {
accountId.forEach(function (trackerObj) {
$window.ga(trackerObj.name + '.send', 'pageview', {
$window.ga(_generateCommandName('send', trackerObj), 'pageview', {
'page': trackPrefix + url,
'title': title
});
Expand Down Expand Up @@ -314,7 +349,15 @@ angular.module('angular-google-analytics', [])
that._log('trackEvent', args);
});
_analyticsJs(function () {
$window.ga('send', 'event', category, action, label, value);
if (angular.isArray(accountId)) {
accountId.forEach(function (trackerObj) {
if (_checkOption('trackEvent', trackerObj)) {
$window.ga(_generateCommandName('send', trackerObj), 'event', category, action, label, value);
}
});
} else {
$window.ga('send', 'event', category, action, label, value);
}
that._log('event', args);
});
};
Expand Down
Loading

0 comments on commit b532284

Please sign in to comment.