Skip to content

Commit

Permalink
Merge pull request #27 from igortregub/igortregub-patch-1
Browse files Browse the repository at this point in the history
The method setTrackerUrl is registered more than once in "_paq" variable
  • Loading branch information
henkelund authored Mar 27, 2018
2 parents 782d58f + ed91fa3 commit 2f2821e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions view/frontend/web/js/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,31 @@ define([
}

/**
* Initialzie this component with given options
* Checks that piwik.js is already on page
*
* @param {String} scriptUrl
* @returns {boolean}
*/
function scriptExists(scriptUrl) {
return $('script[src="' + scriptUrl + '"]').length === 1;
}

/**
* Initialize this component with given options
*
* @param {Object} options
*/
function initialize(options) {
defaultSiteId = options.siteId;
defaultTrackerUrl = options.trackerUrl;
if (piwik === null) {
pushAction([
['setSiteId', defaultSiteId],
['setTrackerUrl', defaultTrackerUrl]
]);
injectScript(options.scriptUrl);
if (!scriptExists(options.scriptUrl)) {
pushAction([
['setSiteId', defaultSiteId],
['setTrackerUrl', defaultTrackerUrl]
]);
injectScript(options.scriptUrl);
}
} else {
// If we already have the Piwik object we can resolve any pending
// promises immediately.
Expand Down

0 comments on commit 2f2821e

Please sign in to comment.