DotNetT Dark_870x220

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.

app_center_blog001

Once you have added the app, you will see the brief steps on your screen.


app_center_blog002

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.

static void Main()
{
    AppCenter.Start("your code", typeof(Analytics), typeof(Crashes));
  
 
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new MainForm());
}

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.

var data = new Dictionary<string, string>();
data.Add("Rows", rows.Count.ToString());
data.Add("Columns", columns.Count.ToString());
 
Analytics.TrackEvent("Data Loaded", data);

After using your application for some time, you can see the data that is collected.

Here is the data shown on the main page.

app_center_blog003

And the custom event used in the application.

app_center_blog004

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.


About the Author

Dimitar Karamfilov

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.

Related Posts

Comments

Comments are disabled in preview mode.