0 Comments

If you've been using Application Insights for a while now you would have noticed that with recent Visual Updates the Application Insights SDK had been updated to use a new version that logs AI data into the new Azure Portal. From this if you use Windows Store Apps you would probably have noticed that if you instrument a Windows Store application with the new SDK that you can't actually find your data anywhere although you can see it being logged from the Visual Studio Output window and using Fiddler. The good news is that you will soon be able to have a great experience with the new AI SDK for Windows Store apps as you do for your currently for your web applications, the better news is that below you'll see how to use the new SDK for your Store Apps and see the data in the Azure Portal.

Create a new AI Resource

First off head over to the Azure Portal and create a new Application Insights Resource

image

Give it a name and choose a Resource Group, It's fine that the Application Type is set to ASP.net web application.

image

After the resource has been created you are ready to add AI to your store app in visual studio

Adding AI to your Windows Store App

Open your store app in visual studio and make sure you have the latest AI SDK installed (2.4 at the moment) and no other AI artifacts left in your project. Right click on the store app solution and click on Add Application Insights Telemetry...

image

At this point if you haven't signed in you will be promoted to sign in, click Gain insights into your application now button

image

After you have signed in you will be presented with the Add Application Insights to Project window

image

On this window click on Use advanced mode

image

which will now ask you for all your AI settings

image

We'll get all of these from the portal. Open your AI resource in the portal and click on Properties

image

This will show you your Subscription ID, Resource Group, Application Insights Resource (name) and Instrumentation Key. Copy these and place them in the window. Once you have filled in all of those fields and clicked Add Application Insights To Project you are ready to run your app and see some data. 

pastedImage

For now it's good enough to see what's happening in your app and some insight is infinity better than no insight =)

0 Comments

So you have a project that uses Application Insights and want to share it with the world. Sure you just post it to CodePlex, GitHub or some other place that allows publishing of code don't you.

NO!!!

Something that you don't want to do is share your code without removing some of the values under the ComponentSettings node in your ApplicationInsights.config. I see 3 possible ways of doing this, possibly each being used in a specific scenario.

1.) Delete and publish

When: I foresee this scenario being for when you have not made any custom changes to your Application Insights configuration.

The first way is to simple delete the Application.config and publish the source code.

image

This will mean that when somebody that downloads your code wants to run it and use the Application Insights bits they will need to add new Application Insights configuration

image

After they have done that they can use your solution with Application Insights no problem

2.) Blank out or token the ComponentSettings section

When: I see this option being for when you have made modifications to the Application Insights config that you feel other users would need in order to effectively use App Insights in the application.

You could for example specify that for the Development Profile you don't want to collection user and machine names.

image

The pieces you will want to blank out or token are below

  • ComponentSettings\ComponentId
  • ComponentSettings\DevelopmentMode\ComponentId
  • ComponentSettings\DevelopmentMode\PortalURI
  • ComponentSettings\DevelopmentMode\DashboardId
  • ComponentSettings\AccountId
  • ComponentSettings\LicenseKey

image

After you have done this you are good to share your code Smile

3.) Split source control

When: You want to share the code but also want to use the application for "real", i.e.: Windows Store Application

What I have started doing for applications that I want to share the source for but also want to use the app in the real world is connecting to a public source control like CodePlex or GitHub and then also to private source control like VSO. The way I do it is to have a public GitHub repo that contains all the logic for my app, this repo is then pushed into a VSO repo as well where I do all my Application Insights stuff. Using this method allows me to work on my app normally as I would with source control and allows the community to be evolved as well with them having to worry about App Insights configuration (sometimes you would want them to be adding App Insights to the code as they add it in which case you will just keep the config separate) and then for when I publish to the store I don't have to have to add a bunch of App Insights code everywhere and keep it out of source control. All I need to do is push to my VSO account, merge any conflicts (which shouldn't happen if I'm just doing App Insights in VSO) and then possible add any additional telemetry that I want and then finally I publish to the store and everything is awesome Open-mouthed smile.

Conclusion

These are just my thoughts and there are probably other ways that people currently do it. One thing you don't want to do is share you keys because then you need to reset them and then update all applications in the wild connected to your account.

if you have other ways of handling this today give me a shout at @GordonBeeming with some details Smile

2 Comments

If you haven't heard or read about Application Insights you should go to MSDN and read up on all the awesomeness that you can get by using this new feature of VSO. You can also take a look at the Channel 9 series on Application Insights for Visual Studio Online by Charles Sterling.

Also see Using Application Insights with a new Windows Store App for an example of adding Application Insights from the creation of a new project.

Installing Application Insights from NuGet

To add Application Insights to your project install the Application Insights Telemetry SDK for Windows Store Apps (Id: Microsoft.ApplicationInsights.Telemetry.WindowsStore)

Install through the Manage NuGet Packages

image

or using Package Manger Console

Install-Package Microsoft.ApplicationInsights.Telemetry.WindowsStore

image

The Application Insights NuGet package is now installed in your application

Getting your instrumentation key

Navigate to a dashboard on VSO and click the admin/settings button in the top right and then click on Keys & Downloads, or browse to https://AccountName.visualstudio.com/_appanalytics/_admin/keysanddownloads. Select the application you are wanting to collect usage data for

image

and then navigate down to the Windows 8.1 Store SDK section and you will see your instrumentation key

image

From here on it's the same as if you started with a clean application and opted to install Application Insights with the start of your application

Changing App Configuration

All applications (at the moment) new or current will get the error below if you haven't already changed the Platform of your store application

image_thumb[12]_thumb

To get rid of this message and put Application Insights in a state where you can start logging application usage you will need to change the configuration of your app to not be Any CPU.

Open Configuration Manager

image[29]_thumb

Set the platform to x86, x64, or ARM

image_thumb[2]

Initializing Application Insights

Open the App.xaml.cs file and at the end of the App() method add the following code

Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsSession.Default.Start("the instrumentation key from VSO");

At this point you can run your application and you will get some basic information like the Operating System, Screen Resolution and a view metrics like session time. You'll need to wait about 15 minutes for the information to display on your dashboard but will look something like below.

clip_image002_thumb[1]

To see the data head over to the Usage Tab on VSO Application Insights

image_thumb[7]

Logging app feature usage

My existing application happens to be an empty Split Page application so I will just log which of the groups the user clicks into. To do this (if you are using the Split Page Application) navigate to ItemsPage.xaml.cs file and change the ItemView_ItemClick method to be like below

/// <summary>
/// Invoked when an item is clicked.
/// </summary>
/// <param name="sender">The GridView (or ListView when the application is snapped)
/// displaying the item clicked.</param>
/// <param name="e">Event data that describes the item clicked.</param>
void ItemView_ItemClick(object sender, ItemClickEventArgs e)
{
var properties = new Dictionary<string, object>() {{"Title", ((SampleDataGroup)e.ClickedItem).Title}};
Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsChannel.Default.LogEvent("Store/ItemView", properties);

// Navigate to the appropriate destination page, configuring the new page
// by passing required information as a navigation parameter
var groupId = ((SampleDataGroup)e.ClickedItem).UniqueId;
this.Frame.Navigate(typeof(SplitPage), groupId);
}

We are simple logging that the Item Click event was fired and logging the title of the group that was clicked. This when you click around in the sample app will log to Application Insights as you click around and generate some data. To see the features that were logged head over to Event Insights under the Features tab

image_thumb[11]

Conclusion

It's really simple to get started with Application Insights and get that feedback from your application when it's out there in the wild.

2 Comments

If you haven't heard or read about Application Insights you should go to MSDN and read up on all the awesomeness that you can get by using this new feature of VSO. You can also take a look at the Channel 9 series on Application Insights for Visual Studio Online by Charles Sterling.

Also see Using Application Insights with an existing Windows Store App for an example of adding Application Insights to an existing application that could already be in the store.

Create a new Application

If you you have the Application Insights Tools for Visual Studio installed that Brian Harry mention in one of his latest blog posts and you are creating a new application, this is much similar for you. Click the Add Application Insights to Project drop down, that will make sure you are authenticated to VSO.

image_thumb[1]

Once done you will be able to choose which VSO account you want to connect to and then you can click Configure to choose the application name (if you haven't created an application in Application Insights yet just type the name and one will be created for you automatically).

image_thumb[3]

At this point the application is opened in your default browser

image_thumb[8]

and a solution is created like

image_thumb[10]

Changing App Configuration

All applications (at the moment) new or current will get the error below if you haven't already changed the Platform of your store application

image_thumb[12]

To get rid of this message and put Application Insights in a state where you can start logging application usage you will need to change the configuration of your app to not be Any CPU.

Open Configuration Manager

image[29]

Set the platform to x86, x64, or ARM

image

Initializing Application Insights

Open the App.xaml.cs file and at the end of the App() method add the following code

Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsSession.Default.Start("license key from ApplicationInsights.config");

As the snippet mentions you need to grab the license key (aka: instrumentation key) from the ApplicationInsights.config

image

At this point you can run your application and you will get some basic information like the Operating System, Screen Resolution and a view metrics like session time. You'll need to wait about 15 minutes for the information to display on your dashboard but will look something like below.

clip_image002

To see the data head over to the Usage Tab on VSO Application Insights

image

Logging app feature usage

Because I am using a new application I will just log which of the groups the user clicks into. To do this (if you are using the Split Page Application) navigate to ItemsPage.xaml.cs file and change the ItemView_ItemClick method to be like below

/// <summary>
/// Invoked when an item is clicked.
/// </summary>
/// <param name="sender">The GridView (or ListView when the application is snapped)
/// displaying the item clicked.</param>
/// <param name="e">Event data that describes the item clicked.</param>
void ItemView_ItemClick(object sender, ItemClickEventArgs e)
{
var properties = new Dictionary<string, object>() {{"Title", ((SampleDataGroup)e.ClickedItem).Title}};
Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsChannel.Default.LogEvent("Store/ItemView", properties);

// Navigate to the appropriate destination page, configuring the new page
// by passing required information as a navigation parameter
var groupId = ((SampleDataGroup)e.ClickedItem).UniqueId;
this.Frame.Navigate(typeof(SplitPage), groupId);
}

We are simple logging that the Item Click event was fired and logging the title of the group that was clicked. This when you click around in the sample app will log to Application Insights as you click around and generate some data. To see the features that were logged head over to Event Insights under the Features tab

image

Conclusion

It's really simple to get started with Application Insights and get that feedback from your application when it's out there in the wild.