in Apps/Contoso.WinUI.Desktop.Puppet/Contoso.WinUI.Desktop.Puppet/App.xaml.cs [30:92]
public App()
{
// Init settings.
localSettings = ApplicationData.Current.LocalSettings;
TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs args) =>
{
// If you see this message while testing the app and if the stack trace is SDK related, we might have a bug in the SDK as we don't want to leak any exception from the SDK.
AppCenterLog.Error("AppCenterPuppet", "Unobserved exception observed=" + args.Observed, args.Exception);
};
CoreApplication.EnablePrelaunch(true);
InitializeComponent();
AppCenter.LogLevel = LogLevel.Verbose;
AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
// Set data from local storage.
var countryCode = localSettings.Values[Constants.KeyCountryCode] as string;
if (!string.IsNullOrEmpty(countryCode))
{
AppCenter.SetCountryCode(countryCode);
}
var storageSize = localSettings.Values[Constants.KeyStorageMaxSize] as long?;
if (storageSize != null && storageSize > 0)
{
AppCenter.SetMaxStorageSizeAsync((long)storageSize);
}
var isManualSessionTrackerEnabled = localSettings.Values[Constants.KeyEnableManualSessionTracker] as bool?;
if (isManualSessionTrackerEnabled != null && isManualSessionTrackerEnabled.Value)
{
Analytics.EnableManualSessionTracker();
}
// User callbacks.
Crashes.ShouldProcessErrorReport = (report) =>
{
Log($"Determining whether to process error report with an ID: {report.Id}");
return true;
};
Crashes.GetErrorAttachments = GetErrorAttachmentsHandler;
// Event handlers.
Crashes.SendingErrorReport += (_, args) => Log($"Sending error report for an error ID: {args.Report.Id}");
Crashes.SentErrorReport += (_, args) => Log($"Sent error report for an error ID: {args.Report.Id}");
Crashes.FailedToSendErrorReport += (_, args) => Log($"Failed to send error report for an error ID: {args.Report.Id}");
// Start App Center.
AppCenter.Start("2daf2955-b4e4-4206-b38a-fedcdc6f4f84", typeof(Analytics), typeof(Crashes));
// Set userId.
var userId = localSettings.Values[Constants.KeyUserId] as string;
if (!string.IsNullOrEmpty(userId))
{
AppCenter.SetUserId(userId);
}
Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
{
Log("Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
});
Crashes.GetLastSessionCrashReportAsync().ContinueWith(task =>
{
Log("Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace);
});
}