Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-05-14 01:50:54 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-05-14 01:51:12 +0400
commit743ec5b77d0edbe192ae25cef9a65bbe6b37f8d2 (patch)
tree8e94d16c4faab7f989be2822118f6fa16742195a /js
parentfd8c530ce25a4e703aa64068c026b393dc200e49 (diff)
refs #5049 log to console (if exist) if methods, that are applied first, are registered multiple times. We do not throw an error as this would prevent script execution
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/js/piwik.js b/js/piwik.js
index a714d0e923..84931dbbe5 100644
--- a/js/piwik.js
+++ b/js/piwik.js
@@ -3132,13 +3132,23 @@ if (typeof Piwik !== 'object') {
asyncTracker = new Tracker();
+ var applyFirst = {setTrackerUrl: 1, setAPIUrl: 1, setSiteId: 1};
+
// find the call to setTrackerUrl or setSiteid (if any) and call them first
for (iterator = 0; iterator < _paq.length; iterator++) {
- if (_paq[iterator][0] === 'setTrackerUrl'
- || _paq[iterator][0] === 'setAPIUrl'
- || _paq[iterator][0] === 'setSiteId') {
+ var methodName = _paq[iterator][0];
+
+ if (applyFirst[methodName]) {
apply(_paq[iterator]);
delete _paq[iterator];
+
+ if (applyFirst[methodName] > 1) {
+ if (typeof console !== 'undefined' && console && console.error) {
+ console.error('The method ' + methodName + ' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: http://developer.piwik.org/api-reference/tracking-javascript#multiple-piwik-trackers');
+ }
+ }
+
+ applyFirst[methodName]++;
}
}