1

Closed

SL4 version of GoogleAnalytics not working in OoB mode

description

I think I discovered a bug in the SL4 version of the GoogleAnalytics when running OoB.
 
Symptom: Running the GA in offline mode will not fire events off to the server (confirmed by Fiddler).
 
Cause:
I eventually decided to disassemble the GoogleAnalytics dll -- source was not included :( and think I found the problem...
In the method: Uri BuildUrl(AnalyticsEvent logEvent)
there is a line of code near the beginning:
if (logEvent.DocumentUri.Scheme == "https")
 
unfortunately, the first time this procedure is hit, logEvent.DocumentUri is null. this causes an exception.
 
Normally, I am creating my own AnalyticsEvent objects so I can set this to Application.Current.Host.Source but the very first AnalyticsEvent that shows up comes from Microsoft.WebAnalytics!Microsoft.WebAnalytics.WebAnalyticsService.Started() and the document uri is not set because of the following line of code in the constructor of DataCollector:
 
        if (HtmlPage.IsEnabled)   ****** this is false in OoB apps
        {
            this.documentUri = HtmlPage.Document.DocumentUri;
            this.referrer = HtmlPage.Document.GetProperty("referrer") as string;
        }
 
Note: the SL3 version of the GA dll does not appear to require the documentUri but really, it seems like the better fix might actually reside in DataCollector.
 
Let me know if there are any Qs,
 
Tim Greenfield
Closed Sep 27, 2010 at 7:38 AM by mscherotter
Fixed

comments

mscherotter wrote Sep 17, 2010 at 6:16 PM

Please try it with the new 1.4.6 installer.
Make sure you remove all existing reference to the MSAF and Google Analytics assemblies and add them from the new MSAF version.

wrote Sep 27, 2010 at 6:38 AM

Resolved with changeset 61564.

mscherotter wrote Sep 27, 2010 at 6:43 AM

The fix is now checked into Microsoft.WebAnalytics DataCollector.cs. Now, if the HtmlPage is not enabled or it is OOB, the AnalyticsEvent.DocumentUri will be Application.Current.Host.Source, the application xap file:
        if (HtmlPage.IsEnabled)
        {
            this.documentUri = HtmlPage.Document.DocumentUri;

            this.referrer = HtmlPage.Document.GetProperty("referrer") as string;
        }
        else
        {
            /// Out-of-browser application or HTML access is not enabled
            this.documentUri = Application.Current.Host.Source;
        }

mscherotter wrote Sep 27, 2010 at 7:37 AM

** Closed by mscherotter 9/26/2010 11:38 PM

mscherotter wrote Sep 27, 2010 at 7:37 AM

Adding Release