3

Starting with the upgrade from Dojo 1.6 to 1.7, my site tracking code seems to be throwing an error that I can't resolve. I've compared the API docs for 1.6 and 1.7 and don't see any significant differences.

My original code was a declarative widget near the end of <body>:

<div data-dojo-type="dojox.analytics.Urchin"
    data-dojo-props='acct: "UA-88003-8"'>
</div>

I have since tried a programmatic version like this from a script that is loaded manually in <head>:

require(["dojox/analytics/Urchin"], function(ga) {
    var analytics = new ga({acct: "UA-88003-8"});
});

Either way the error thrown looks something like this:

Uncaught TypeError: Object [object Object] has no method 'get' a.(anonymous function) ga.js:11 require.cache.dojox/analytics/Urchin._213.trackPageView dojo:15 require.cache.dojox/analytics/Urchin._213.GAonLoad dojo:15 require.cache.dojox/analytics/Urchin._213._gotGA dojo:15 (anonymous function) dojo:15 _310

I am using a custom build of Dojo, but this issue is easily replicated in control environment using stock Dojo libraries. Here is an example on JSFiddle.

What is the correct way to instantiate a GA tracker object using Dojo 1.7?

Caleb
  • 5,084
  • 1
  • 46
  • 65
  • If the code used to instantiate Urchin in 1.6 doesn't work in 1.7, it's a bug. There may have been a bug introduced in the AMD conversion of the code. You should file a report at bugs.dojotoolkit.org – peller Dec 28 '11 at 03:46
  • 1
    @peller I filed [a bug report here](http://bugs.dojotoolkit.org/ticket/14534). – Caleb Dec 28 '11 at 08:41

1 Answers1

1

This error is caused by a bug in the Dojo library in the dojox component. The code for instantiating the object in my question is correct.

In order to work around this until the next Dojo release, you can apply this patch: (download)

Index: dojox/analytics/Urchin.js
===================================================================
--- dojox/analytics/Urchin.js~ 2012-01-04 17:20:46.000000000 +0200
+++ dojox/analytics/Urchin.js 2011-08-30 23:18:13.000000000 +0300
@@ -126,7 +126,7 @@
                         //      |               pane.attr("href", ref);
                         //      |       });

-                        this.tracker._trackPageview.apply(this, arguments);
+                        this.tracker._trackPageview.apply(this.tracker, arguments);
                 }

         });
Caleb
  • 5,084
  • 1
  • 46
  • 65