Derik Whittaker

Syndication

News


Adding Runtime Intelligence to your Windows Phone 7 Application

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.

image

 

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.

  1. Right click the main dll in the Instrumentation Screen as such:
    image
  2. Choose Add Attribute and then select the PreEmptive.Attributes.ApplicationAttribute and click ok
    image
  3. Provide the details of your application:
    image
    1. For Application Type you can put anything you want there, I just like putting the platform
    2. For Guid click the ellipse and it will grab the GUID off your selected dll to use
    3. For Name provide anything you want to identify your application
    4. 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.

  1. Right click the main dll in the Instrumentation Screen as such:
    image
  2. Choose Add Attribute and then select the PreEmptive.Attributes.BusinessAttribute and click ok
    image
  3. Provide the details of your business:
    image
    1. 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.
    2. 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.

  1. 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:
    image
  2. Choose Add Attribute and then select PreEmptive.Attributes.SetupAttribute and click ok:
    image
  3. Provide the details:
    image
    1. For CustomEndpoint click the ellipse and choose the WP7 endpoint
    2. For ExtendedKeySourceOwner click the ellipse and find the entry point into your WP7 app.
    3. For InstanceIdSourceOwner click the ellipse and find the entry point into your WP7 app.
    4. 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.

  1. 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:image
  2. Choose Add Attribute and then select PreEmptive.Attributes.TeardownAttribute and click ok:
    image
  3. Provide the details (well in this on you can leave all the defaults if you want)
    image


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. 

  1. 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:
    image
  2. Choose Add Attribute and then select PreEmptive.Attributes.FeatureAttribute and click ok:
    image
  3. Provide the details
    image
    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)
    1. Set the FeatureEventType to Tick (which is the default)
    2. 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
Filed under: ,

[Advertisement]

Comments

austin avrashow wrote re: Adding Runtime Intelligence to your Windows Phone 7 Application
on 04-08-2011 7:34 PM

Didnt know easy way to reach you Derik. On your VS2010 Safari videos, Tuples & Named Params videos are switched in TOC. FYI. {PS enjoying them much}

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)