Monday, July 16, 2018

Google Analytics Exceptions

You may have noticed some exceptions in the Visual Studio output window when using Google Analytics.    I had 3 exceptions of  "Automation server can’t create object" and one exception of  "Unable to get property getRandomValues of undefined or null reference".

Automation Server Can't Create Object

The Google Analytics javascript in analytics.js tries to determine what version of ShockwaveFlash is installed on your computer by trying to create objects of three versions of ShockwaveFlash and use an instance even if it's null which throws an exception.  The exceptions are caught and not re-thrown so there are no issues, but you will see the exceptions in the Visual Studio output window.

 Here is the code of interest:

 function fc() {
var a, b, c; if ((c = (c = O.navigator) ? c.plugins : null) && c.length)
for (var d = 0; d < c.length && !b; d++) {
var e = c[d]; - 1 < e.name.indexOf("Shockwave Flash") && (b = e.description)
}
if (!b) try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), b = a.GetVariable("$version")
} catch (g) {}
if (!b) try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"), b = "WIN 6,0,21,0", a.AllowScriptAccess = "always", b = a.GetVariable("$version")
} catch (g) {}
if (!b) try {
a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), b = a.GetVariable("$version")
} catch (g) {}
b &&
(a = b.match(/[\d]+/g)) && 3 <= a.length && (b = a[0] + "." + a[1] + " r" + a[2]);
return b || void 0
};


Unable to get property getRandomValues

An analytics.js function relies on an exception to determine if the  .crypto object is defined.  The function returns a value in the catch().

Again, the exceptions is caught and not re-thrown so there are no issues, but you will see the exceptions in the Visual Studio output window.

Here is the code of interest: 

var hd = function() {
return Math.round(2147483647 * Math.random())
},
      Bd = function() {
      try {
      var a = new Uint32Array(1);
      O.crypto.getRandomValues(a);
      return a[0] & 2147483647
      } catch (b) {
      return hd()
      }