What is the “ApplicationInsights” package in Windows 10 universal apps, and do you need it?

Technical stuff, Universal Windows Platform UWP, Visual Studio, Windows 10, Work
See comments

When you create a new Windows 10 universal application in Visual Studio, you might have noticed that a reference to Microsoft.ApplicationInsights is added to the references folder. In fact, there are three Nuget packages, and one ApplicationInsights.config file in your project. So what is this, and can you remove it?

What’s ApplicationInsights?

ApplicationInsights is an analytics and telemetry solution proposed by Microsoft. When added to an app, it allows you to monitor what your user does in your application, either by tracing standard events like application startup and end, record crashes, or allow you, the developer, to add events in your code, for instance to see how many users are using a specific functionality. In essence, it is quite similar to Google analytics or other popular packages.

In Windows Phone 8.1 and Windows 8 store apps, you could select either ApplicationInsights or any analytics package you prefer to monitor your application. However in Windows 10, it seems that Microsoft is adding this package automatically, without asking you first. To be honest I don’t like this much, especially because it slows down the creation of a new app and bloats the project, and so I asked the team what this is about.

The answer is that ApplicationInsights is used for the developer dashboard integration. If you want to see any information about your app once it is published in the Windows store, you will need ApplicationInsights in your app.

What if I already use another analytics package?

Well you can choose. You can either use ApplicationInsights for the dashboard integration only, and add your favorite analytics solution to the application, and use that for your own reporting. Or you can of course choose to move all your analytics to ApplicationInsights. But the fact remains, if you remove ApplicationInsights, you will lose dashboard integration.

Can I publish an app to Windows Store without ApplicationInsights?

As far as I know, it is possible to publish without ApplicationInsights, but then your dashboard events will remain empty. I am not 100% sure as I didn’t try it myself.

Do I need ApplicationInsights during the development?

The answer is no. In fact you can even create an application from scratch without ApplicationInsights. This is not immediately visible but when you inspect the “File / New Project” dialog, you will see a checkbox labeled “Show telemetry in the Windows Dev Center”. By default, this checkbox is checked, but if you uncheck it, it will create a ””real blank application”, i.e an app without ApplicationInsights.

2015-09-24_16-52-45

If you forget to uncheck the box, or if you change your mind later after the application was created, you can also remove ApplicationInsights with the following steps:

  • Right click on the Project in the Solution Explorer and select Manage Nuget Packages from the context menu.
  • In the Filter combobox, select Installed.
  • Select Microsoft.ApplicationInsights.WindowsApp from the list of installed packages.
  • In the Action combobox, select “Uninstall”
  • Finally, click on the Uninstall button

2015-09-24_16-56-48
 
2015-09-24_16-57-30

2015-09-24_16-57-56

Yes, this is a horrible UX, and I know that the Nuget team wants to improve it. Believe me, they heard our feedback.

Repeat these steps in order to also remove Microsoft.ApplicationInsights.PersistenceChannel and Microsoft.ApplicationInsights. Unfortunately you need to remove these three packages one by one, and in this order, or else it will fail.

Do NOT remove Microsoft.NETCore.UniversalWindowsPlatform as it contains all your application needs to work on the Windows 10 API. If you remove it, nothing will work anymore.

Not quite done yet! Then you need to remove the ApplicationInsights.config file from your project. You can do that in the Solution Explorer.

2015-09-24_17-00-58

Finally, open App.xaml.cs and locate these lines of code:

Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
    Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
    Microsoft.ApplicationInsights.WindowsCollectors.Session);

If you try to build your app without removing these 3 lines, it will fail to build. Removing them is the last step you need to completely remove ApplicationInsights from your existing app.

How do I add ApplicationInsights back?

If you decide to add ApplicationInsights again (for example before publishing to the Windows store, in order to get the Dashboard telemetry), you can do as follows:

  • Right click on your project in the Solution Explorer.
  • Select “Add ApplicationInsights telemetry” from the context menu.

2015-09-24_17-09-54

This will start a wizard and require you to log into your Azure account in order to set everything up, so it’s not something you want to do at the last minute before publishing your app.

Hopefully these few explanations will be useful!

Happy coding
Laurent

Previous entry | Next blog entry

Comments for What is the “ApplicationInsights” package in Windows 10 universal apps, and do you need it?