When building any type of application which is going to be deployed to the masses it is always important to know and understand how your application is being used in order to make more informed decisions on how to maintain or extend your application. When it comes to adding in runtime intelligence into your application the team over at PreEmptive (the same folks that make Dotfuscator) have a killer product that is dead easy to use and gives you great results.
Lets get started and take a look at how to add Runtime Intelligence into your application
Step 0 - Getting up and running:
In order to add this runtime intelligence into your application you will need to download the WP7 Edition of Dotfuscator and have it installed. Once you have it installed you will want to create a new project. After the new project is created the area in the app we are going to focus on is found on the Instrumentation Tab. The screenshot below shows this tab in action.

Step 1: Adding the ApplicationAttribute
In order to identify your application to the RuntimeIntelligence portal you must provide your application an ApplicationAttribute. This should be placed on your main runtime exe/dll (your UI project for WP7). Here is how we can do this.
- Right click the main dll in the Instrumentation Screen as such:
- Choose Add Attribute and then select the PreEmptive.Attributes.ApplicationAttribute and click ok
- Provide the details of your application:
- For Application Type you can put anything you want there, I just like putting the platform
- For Guid click the ellipse and it will grab the GUID off your selected dll to use
- For Name provide anything you want to identify your application
- For Version this can be anything, I started with 1.0.0.0
Step 2: Adding the BusinessAttribute
In the step above we provided an attribute which identifies your application in the portal, this time we need to provide an attribute which identifies the app again, but this time from the perspective of your company and your license with PreEmptive. Here is how we do this.
- Right click the main dll in the Instrumentation Screen as such:
- Choose Add Attribute and then select the PreEmptive.Attributes.BusinessAttribute and click ok
- Provide the details of your business:
- For CompanyKey provide the GUID which is provided to you from the http://wp7.runtimeintelligence.com/ portal (not that in this screenshot I did not provide the real key). If you do not provide a valid key you will get the following runtime/compile error - Attribute validation error: The BusinessAttribute on assembly [Assembly name goes here] must have a valid company key.
- For CompanyName provide the name of the company
Step 3: Adding the SetupAttribute
Once we have the Application and Business Attributes setup in order to ID your product we now must create a setup attribute. This SetupAttribute is an instrumentation time attribute for methods. This attribute can be used to guide Application Analytics instrumentation. This is REQUIRED and you will get an error if you do not have this setup. Here is how we do this.
- Find the entry point in your application. For a WP7 application that will be in the App.xaml.cs file and you want to attach to the Application_Launching method. Once you have found this method right click and and add an attribute as such:
- Choose Add Attribute and then select PreEmptive.Attributes.SetupAttribute and click ok:
- Provide the details:
- For CustomEndpoint click the ellipse and choose the WP7 endpoint
- For ExtendedKeySourceOwner click the ellipse and find the entry point into your WP7 app.
- For InstanceIdSourceOwner click the ellipse and find the entry point into your WP7 app.
- Make sure the UseSSL is set to true
Step 4: Adding the TeardownAttribute
In the same manor we needed to create a Setup Attribute we need to setup the TeardownAttribute. The TeardownAttribute is an instrumentation time attribute for methods. This attribute can be used to guide Application Analytics instrumentation. This will be used to tell the portal that your application has been closed. This is REQUIRED and you will get an errorif you do not have this setup. Here is how we do this.
- Find the exit point in your application. For a WP7 application this can be in the App.xaml.cs file and you want to attached to the Application_Closing method. Once you have found this method right click and add an attribute as such:
- Choose Add Attribute and then select PreEmptive.Attributes.TeardownAttribute and click ok:
- Provide the details (well in this on you can leave all the defaults if you want)
Step 5: Adding a Feature Tracking Attribute
Ok, so we have done all the upfront busy work to enable us to get to this point. The main point of adding intelligence is to do things like track feature usage or to enable performance tracking. We will focus here on how to create feature tracking.
- Find an point/feature in your application which you want to track. In our case we are going to track each time that a video is played so we are going to find the ‘HandlePlayEpisode’ method and right click this to add a new attribute as such:
- Choose Add Attribute and then select PreEmptive.Attributes.FeatureAttribute and click ok:
- Provide the details
In this example we do not care about extended key values (these are custom data points which can be sent with your messages to give more context) - Set the FeatureEventType to Tick (which is the default)
- Provide a Name, this is required and should be unique. I have a convention I follow in order to allow the names to be searchable and consistent.
Step 6: Rebuild your .Xap with the analytics
Once you are done building your .xap you can then decompile the application via Reflector or what ever and take a look at the code which is injected via the PreEmptive process.
Step 7: Log into the WP7.Runtimeintelligence.com portal and see your information
There you have, the 7 steps needed to go from 0 to runtime intelligence. Adding this information is not difficult and can yield great information on how your application is being used in the field by REAL users.
Till next time,
Posted
03-31-2011 6:07 AM
by
Derik Whittaker