I have always been interested in learning which features of my application users are using as well as if they are using it. I have done this with other applications by using my own “home-grown” version of web services etc. Since I have been working a lot with Windows Phone 7 lately I decided to learn how to do this and share with the community. Before you get started you will be pleased to know that you won’t have to spend any money *at least until 2012* to do this with your existing phone apps.
To get started:
Download Dotfuscator at http://www.preemptive.com/windowsphone7.html. After it is downloaded you will want to add your WP7 .XAP file to Dotfuscator. This will allow you to setup analytics and obfuscation of your application.
After it is loaded then you will want to click on the Input tab and take a look at the .DLL’s referenced in your project. You will want to exclude any third party dll’s from the package. Don’t worry as they are not excluded entirely. The only thing you want left in here is your main application .dll and the Package Artifacts. So in the example below I removed the Telerik 3rd party controls and only left my michaelcrump.net.dll and Package Artifacts.
You will now want to click on Settings and look for Instrumentation. Make sure that the first three are set to Yes.
Now we are going to click on the Instrumentation Tab and right click our main application .dll and add an attribute.
You should have this screen now. This allows you to setup the Application Type and give it a name that you can see in your Preemptive Solution Dashboard. Go ahead and fill in your applications info. You can uniquely generate a GUID by clicking on the ellipse button in the right hand corner box.
Once that is complete you are going to want to add a BusinessAttribute. So right click again and select BusinessAttribute.
At this point you will want to fill in your company name as well as the CompanyKey that was provided in an email from Preemptive Solutions.
Now that we have included our Application and Business information to our project. We will need to setup our SetupAttribute and TearDown Attribute.
Starting with the SetupAttribute:
Navigate inside your Application until you get to App –> Then InitializeComponent: void(). Right click on this field and add a SetupAttribute. You will want to make sure the Custom EndPoint is set to wp7data.runtimeintelligence.com/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx. This is a selectable option so you will not have to type it. This is basically a web service that will collect data as your users click on different items in your application.
Now the TeardownAttribute:
Navigate inside your Application until you get to App –> Then Application_Closing event. Right click on this field and add a TearDownAttribute. You can leave all the options on this page as the default.