New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter "make_google_analytics_async" turns benign call to deprecated method into a functional error #441

Closed
GoogleCodeExporter opened this Issue Apr 6, 2015 · 11 comments

Comments

Projects
None yet
1 participant
@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Apr 6, 2015

Problem: Javascript error "Uncaught TypeError: Object #<Object> has no method 
'_initData' "

From what I read, the following call: "pageTracker._initData();" is a 
deprecated call that is harmless. However, when the filter is enabled, this 
causes the above javascript error.  It's easy enough for someone to correct 
this by removing the deprecated line of code but thought it might be worth 
reporting. It would be nice if the filter just detected and fixed this case.

What steps will reproduce the problem?
1. Enable filter: make_google_analytics_async

What is the expected output? What do you see instead?

Here is the before script:
<!--Google start Analytics-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : 
"http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + 
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker('UA-XXXXXX-10'); 
pageTracker._initData(); 
pageTracker._trackPageview(); 
</script>
<!--Google end Analytics-->

After filter:
<!--Google start Analytics-->
<script orig_type="text/javascript" type="text/psajs" orig_index="6">var 
gaJsHost=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");v
ar _gaq=_gaq||[];(function(){function functionName(fn){var 
name=/\W*function\s+([\w\$]+)\(/.exec(fn);if(!name)
return'No name';return name[1];}
var nameSpace='_gat';var existingGat=window[nameSpace];if(existingGat&&typeof 
existingGat['_getTracker']=='function'){return;}
var gaqAccounts=[];function 
setAccount(acct,prefix){if(gaqAccounts[prefix]!=acct){gaqAccounts[prefix]=acct;_
gaq.push([prefix+'_setAccount',acct]);}}
window['_modpagespeed_getRewriteTracker']=function(tracker_acct,tracker_name){va
r prefix=tracker_name?tracker_name+'.':'';function deferTrackerFunc(fn){return 
function(){setAccount(tracker_acct,prefix);var 
pushArgs=[fn];[].push.apply(pushArgs,arguments);_gaq.push(pushArgs);};}
var 
pageTrackerMethodNames=['_trackPageview','_trackEvent','_trackTrans','_addIgnore
dOrganic','_addIgnoredRef','_addItem','_addOrganic','_addTrans','_clearIgnoredOr
ganic','_clearIgnoredRef','_clearOrganic','_clearXKey','_clearXValue','_cookiePa
thCopy','_deleteCustomVar','_link','_linkByPost','_sendXEvent','_setAllowAnchor'
,'_setAllowHash','_setAllowLinker','_setAutoTrackOutbound','_setCampCIdKey','_se
tCampContentKey','_setCampIdKey','_setCampMediumKey','_setCampNOKey','_setCampNa
meKey','_setCampSourceKey','_setCampTermKey','_setCampaignCookieTimeout','_setCa
mpaignTrack','_setClientInfo','_setCookiePath','_setCookiePersistence','_setCook
ieTimeout','_setCustomVar','_setDetectFlash','_setDetectTitle','_setDomainName',
'_setHrefExamineLimit','_setLocalGifPath','_setLocalRemoteServerMode','_setLocal
ServerMode','_setMaxCustomVariables','_setNamespace','_setReferrerOverride','_se
tRemoteServerMode','_setSampleRate','_setSessionCookieTimeout','_setSessionTimeo
ut','_setTrackOutboundSubdomains','_setTrans','_setTransactionDelim','_setVar','
_setVisitorCookieTimeout','_setXKey','_setXValue'];var 
pageTracker={initData:function(){},};for(var 
i=pageTrackerMethodNames.length;i--;){var 
n=pageTrackerMethodNames[i];pageTracker[n]=deferTrackerFunc(prefix+n);}
return pageTracker;};var 
ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.s
rc=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-an
alytics.com/ga.js';var 
s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})(
);</script>
<script orig_type="text/javascript" type="text/psajs" orig_index="7">var 
pageTracker=_modpagespeed_getRewriteTracker('UA-2391884-10');pageTracker._initDa
ta();pageTracker._trackPageview();</script>
<!--Google end Analytics-->

What version of the product are you using (please check X-Mod-Pagespeed
header)? 1583

On what operating system? Ubuntu 10.04

Which version of Apache? 2.2

Which MPM? Event

Original issue reported on code.google.com by hayes...@gmail.com on 22 May 2012 at 7:24

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Oops, forgot to strip out the GA ID in the second set of javascript. If you can 
mark that out, that would be great.

Original comment by hayes...@gmail.com on 22 May 2012 at 7:25

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Hi Hayes,

Just confirming I understand: is this an issue of a benign problem in the 
original site turning into site-breakage in the 'optimized' version?

Original comment by jmara...@google.com on 22 May 2012 at 1:13

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Hey Josh,

Correct.  That is exactly what is happening.

Thanks.

Original comment by hayes...@gmail.com on 22 May 2012 at 6:33

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Original comment by jmara...@google.com on 24 May 2012 at 7:05

  • Changed state: Accepted
@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Original comment by jmara...@google.com on 11 Jun 2012 at 1:41

  • Changed title: make_google_analytics_async turns benign call to deprecated method into a functional error
@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Original comment by jmara...@google.com on 28 Sep 2012 at 8:12

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Fixed in r3635.

Original comment by sl...@google.com on 12 Nov 2013 at 9:59

  • Changed state: Fixed
@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Original comment by jefftk@google.com on 2 Jan 2014 at 5:42

  • Added labels: Milestone-v31
@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Is this actually fixed?  r3635 doesn't look like it's related.  Steve, can you 
clarify?

Original comment by jefftk@google.com on 3 Mar 2014 at 7:32

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Sorry, I gave the wrong revision. The correct revision is r3625 (it also 
includes an unrelated change).

Original comment by sl...@google.com on 5 Mar 2014 at 9:37

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Original comment by hui...@google.com on 5 Mar 2014 at 9:44

  • Changed title: Filter "make_google_analytics_async" turns benign call to deprecated method into a functional error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment