Crash reporting for Windows apps

You need to do a minimum configuration to get started with Apptics crashes. Before you begin, make sure that your app is already registered and configured in Zoho Apptics.

  • If not, then create a project and add your app in Apptics and download the config.plist file for your app.
  • Crashes are automatically tracked in Apptics using the (init) method when you do the initialization for Analytics by subscribing to the UnhandledException.
  • If App.Unhandled_Exception event is subscribed , please note that Apptics library wouldn't be able to track crash automatically.

Customized crash handling:

  • You can handle the crash (unhandled exception) using the event Instance_UnhandledException which provides the exception which caused the crash.
  • Subscribe to the event Initializer.Instance.UnhandledException.

For UWP apps

CopiedInitializer.Instance.UnhandledException += this.Instance_UnhandledException;

For WinUI apps

CopiedInitializer.Instance.UnhandledException += this.Instance_UnhandledException;
  • Implement the event in your code as given below: 

For UWP apps

Copiedprivate void Instance_UnhandledException(Exception exception, string Message)
 {
	//Your Code here ...      
            this.Exit();
 }

For WinUI apps

Copiedprivate void Instance_UnhandledException(Exception exception, string Message)
 {
/*your code here  */  
            this.Exit();
 }

Note:

  • Make sure that you call this.Exit() in the Instance_UnhandledException event handler, else the app stays alive and the crashes are not reported.
  • Crash reports will be collected by default, irrespective of user consent. Based on the consent provided we will sync the data.​
  • We will send it to the server if the user opted in, or else the developer will have to call the "SendCrashIfAny" function.
  • On-call of that function, we will show a crash consent popup, if the user opted out to send a crash.
  • If you have registered an UnhandledException event in your App.xaml.cs, you need to call the below function to add crash.

For UWP apps

Copiedprivate async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
        {
            var exception = e.Exception;
		    e.Handled = true;
           await AppticsAnalytics.AppticsTracker.AddCrashData(exception);
        }

For WinUI apps

Copiedprivate async void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
    e.Handled = true;
    Exception unhandledException = e.Exception;
    await WinUISdkBase.Initializer.Instance.SaveAppticsData().ContinueWith(async (t1) =>
    {
        await AppticsWindowsBase.Analytics.AnalyticsHelper.AddCrashData(unhandledException).ContinueWith((t2) =>
        {
            System.Diagnostics.Process.GetCurrentProcess().Kill();
        });
    });
}

NOTE: 

  • Crash reports are collected by default irrespective of user consent.
  • We will send the crash reports to the server only if the user has opted in, or else the developer will have to call the "SendCrashIfAny" function.
  • On-call of that function we will show a crash consent popup if the user opted out to send a crash.
  • The data is synced based on the consent provided.

You can also add your crash as string params like below function.

CopiedAppticsWindowsBase.Analytics.AnalyticsHelper.AddCrashData(issueName,fullCrashDataWithTrace)