MSAF in WP7 Only Showing WP7 Started Event in Google

Nov 12, 2010 at 6:01 PM

I've followed the instructions at http://kodierer.blogspot.com/2010/11/tracking-sales-statistics-with.html to ad tracking of application Launch for different versions (Trial, Full) of my Windows Phone app, but in Google Reports and in Fiddler I'm only seeing WP7 Started (which I having added myself, this must be built-in) and NOT the "Launch All" or "Launch Trial" events that I added to be logged.  Has anyone else seen this or does anyone have any suggestions?

It sounds like I might be having a similar problem to the person that posted this: http://msaf.codeplex.com/Thread/View.aspx?ThreadId=230875 , but they didn't receive a reply, so I have nothing to try from that, but it does seem to validate that there is an issue or a common foible.

I am using the 1.4.9 Installer version of MSAF and the latest version of WPDT.

Thanks.

Nov 15, 2010 at 11:48 PM

I am having the same problem. Going to try to look into this and see what I can come up with.

Nov 17, 2010 at 4:14 AM

Thanks for your reply - it's a relief to know I'm not the only one with the problem - sorry that's at your expense :)  I am going to try adding it to another project to see if it's a problem with that project and some of the other APIs I'm using in it.  Will post if I find a resolution.

Nov 17, 2010 at 6:06 AM

Same thing is happening in another project that I tried it in, so I'm stuck on this ATM.  Any thoughts?  Thanks.

Nov 17, 2010 at 8:18 PM

If I could step into the code I can't imagine it would be too hard to figure out, but I can't get the source to build. I'm still trying to figure this out if I'm missing dependencies or something. PreEmptive still hasn't contacted me back about their WP7 analytics solution, and with the marketplace not implementing any reporting yet, I am at a loss.

Nov 24, 2010 at 6:47 AM

I have the same problem.  I put Fiddler on it, and I can see the WP7 Started, but it's not sending anything in response to the AnalyticsHelper.Log method.  Has anyone made any progress on this?  I have an app to submit, but need to either get the analytics working correctly, or remove it all together.

Nov 24, 2010 at 7:32 AM

Debugging through the code, I found that in DataCollector.cs, in this block:

            if (NetworkInterface.GetIsNetworkAvailable())
            {
                if (!this.EventDispatcher.DispatchEvents(logEvent, false))
                {
                    this.EventLog.WriteEntry(logEvent);
                }
            }
            else
            {
                this.EventLog.WriteEntry(logEvent);
            }

The "EventDispatcher.DispatchEvents" returns true, so the "WriteEntry" call is not made.  When moving the IP to the WriteEntry line, Fiddler shows the "Launch All" event is sent.  Will try to debug more and post findings later.

Nov 24, 2010 at 4:47 PM

Great find, coose.  Keep up the good work!

Nov 25, 2010 at 12:39 AM
Edited Nov 25, 2010 at 12:41 AM

Here is the code for EventDispatcher.DispatchEvents, in WebAnalyticsEvents.cs (EventDispatcher is of type WebAnalyticsEvents):

        internal bool DispatchEvents(AnalyticsEvent analyticsEvent, bool fromCache)
        {
            if (this.TrackEvent == null)
            {
                System.Diagnostics.Debug.WriteLine("Caching {0} event because no trackers are connected yet.", analyticsEvent.Name);

                return false;
            }

            var args = new AnalyticsEventArgs(analyticsEvent, fromCache);

            try
            {
                this.TrackEvent(this, args);
            }
            catch (System.Exception se)
            {
                System.Diagnostics.Debug.WriteLine("Error dispatching event to subscriber(s): {0}", se.Message);
            }

            return true;
        }

Is there something about all three of our implementations that is causing this problem?

Nov 25, 2010 at 12:42 AM

Had the value return value of DispatchEvents confused, edited above comment.  Will now ponder over this situation now that I have the facts straight in my mind.

Nov 25, 2010 at 1:12 AM

So now my question is: what is supposed to handle TrackEvent and why is it obviously not being successfully handled so that the event makes it to Google Ananlytics?

Nov 27, 2010 at 2:27 AM

I am having the same problems as everyone above.  On a whim, I moved the logging logic out of the 'App.Application_Launching()' eventhandler and into my initial application silverlight page 'PivotTitlePage'.  I now see the events being logged.  If I had to guess, I would imagine that the logging framework is not entirely bootstrapped by the time the App.Application_Launching method is called in some cases. 

 

 

       // constructor
       public PivotTitlePage()
        {
            InitializeComponent();
           
            if (!alreadyLogged)
            {
                logStartUp();
                alreadyLogged = true;
            }
        }

        private static bool alreadyLogged = false;

        private void logStartUp()
        {
            var analyticsHelper = new AnalyticsHelper();

            // Get device id
            var value = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
            var id = Convert.ToBase64String(value);

            // Track launch
            analyticsHelper.Track("Launch All", id);

            // Track if paid
            if (!new LicenseInformation().IsTrial())
            {
                analyticsHelper.Track("Launch Paid", id);
            }
        }

 

Nov 28, 2010 at 11:54 PM

Thanks for sharing, tschacht!  I'll give that a try.  I still wonder what's going on with our cases that makes this happen.  Is there anyone that doesn't have this problem or are we the only ones being vocal about it?

Nov 29, 2010 at 5:02 PM

I have moved the analytics code to the MainPage constructor and found that it is working, so thanks again for that tschacht.

I have added a line of code to track all launches as well so that I can easily see the total install base without having to add trial + paid (I know, lazy), but it doesn't get sent to Google Analytics even though the code is verified to be hit.  Maybe only one message can be logged at a time for some reason?  I noticed that the traffic to Google doesn't show up right after the AnalyticsHelper.Log() is called, so this makes me think only one event can be logged before the log is sent.  I wonder if there is any way to change this?

Nov 29, 2010 at 5:13 PM

My code with the added line to track "Launch All", in case that makes any difference:


                var analyticsHelper = new AnalyticsHelper();
                // Get device id
                var value = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
                var id = Convert.ToBase64String(value);
                // Track launch
                analyticsHelper.Track("Launch All", id);
                // Track if paid
                if (!App.isTrial)
                {
                    analyticsHelper.Track("Launch Paid", id);
                }
                // Track if trial
                else
                    analyticsHelper.Track("Launch Trial", id);
                isLogged = true; 


Dec 1, 2010 at 1:30 PM
Edited Dec 3, 2010 at 8:59 AM

I had the same problem.. trying out the suggested solution as we speak.

*edit*
Yep.. moving the code to the main page works!