Piwik 1.12: Error in Tracker? Patch provided

Dear Piwik-Team,

after upgrading to Piwik 1.12 we had some problems with some of our websites which are using Dojo 1.8.3. After some digging around we found that there (probably) is a bug in Piwik when using the CommonJS-Function “define”.

The specification of CommonJS says that the function “define” is defined as:

define(id?, dependencies?, factory);

But in piwik.js it is used in line 3032 as:

if (typeof define === ‘function’ && define.amd) {
define([‘piwik’], [], function () { return Piwik; });
}

So instead of the module-id beeing a String it is an array. In turn the implementation of Dojo of define() chokes.

A simple fix would be to use a String for the module-id like this:

if (typeof define === ‘function’ && define.amd) {
define(‘piwik’, [], function () { return Piwik; });
}

I think that is the way the CommonJS-Function should be used. See Modules/AsynchronousDefinition - CommonJS Spec Wiki

By the way: Thanks for the great work!

Tino

Thanks for the feedback. I’ve asked Anthon who wrote the code to comment.

You are correct. I’ll fix this (or merge a PR) ASAP.