At .NET conf 2019, Microsoft announced that the Visual Studio App Center now provides support for WinForms and WPF applications. What the App Center provides is an environment to build your app, test it on real devices, distribute to users and instrument it with analytics.
After .Net conf, I tested this new feature in a Telerik UI for WinForms application that I am developing. At this point, I am amazed how easy it is to plug your application to the AppCenter and collect data.
Let me take you through the process of how to instrument your WinForms and WPF application with the AppCenter. The first step is to go to https://appcenter.ms/apps, log-in, and create a new app. Give it a name and select the appropriate type.
Once you have added the app, you will see the brief steps on your screen.
The steps are easy to follow. First install the Microsoft.AppCenter.Analytics and Microsoft.AppCenter.Crashes Nuget packages. It can take some time since the packages depend on other stuff as well.
Then you need to add the code to your application. Please note that the getting started page contains the actual key that you need to add in your app. There is just one line that you should add to the Program.cs file.
Once this is done, you can start tracking general information like sessions, user counts, user-related information like country and see some info about the used devices. At this point you can add some events to your application so you can track specific actions. You can add some data as parameter by using as Dictionary.
After using your application for some time, you can see the data that is collected.
Here is the data shown on the main page.
And the custom event used in the application.
That is all you need to do to collect user data. I encourage you to try it since it's easy and can provide valuable info for your WinForms and WPF applications.
Check out the Telerik UI for WinForms and Telerik UI for WPF components suites to learn more on how to deliver high quality, feature rich, modern and engaging desktop applications with WinForms and WPF.
Dimitar Karamfilov is a Support Officer in the UI for WinForms team. He joined Telerik after graduating from the Telerik Academy in 2013. Apart from work he likes outdoor activities and reading philosophy literature.
Subscribe to be the first to get our expert-written articles and tutorials for developers!