When debugging Sitecore xDB issues, it is a pain that data is not written to MongoDB directly, but you have to wait for your session to end.
The legend said that you could either set the session timeout to 1 minute, or call Session.Abandon() to write to MongoDB. None of this have ever worked for me, until my colleague Lasse Pedersen found the final, bullet-proof way of having the xDB session data written to MongoDB.
Create a page with the following contents, and call it when you wish to flush data from xDB to MongoDB:
Sitecore.Analytics.Tracker.Current.EndTracking(); HttpContext.Current.Session.Abandon();
We will all pray to the debugging gods that this fix will work in every scenario.
