Skip to content

Commit

Permalink
Merge pull request #29 from henkelund/2.0.1
Browse files Browse the repository at this point in the history
2.0.1
  • Loading branch information
henkelund authored Mar 27, 2018
2 parents ec5e702 + 2f2821e commit 1685ec0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ php:
- 7.1
- 7.0
env:
- M2_VERSION=2.2.3
- M2_VERSION=2.2.2
- M2_VERSION=2.2.1
- M2_VERSION=2.2.0
Expand Down
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 1685ec0

Please sign in to comment.