Setting up Crash and Exception Reporting
Before setting up Crash and Exception reporting for your project, make sure you’ve followed the basic setup requirements outlined in our Getting Started guide. It’s important to have a Project ID to connect the project to the Unity Dashboard. Once your Dashboard is set up with your basic project credentials, you can enable Crash and Exception Reporting for your project in the Unity Editor.
To enable Crash and Exception Reporting:
- Open your project in the Unity Editor.
- From the Unity Editor menu, select Window > General > Services to open the Services window.
- From the Services window, select Cloud Diagnostics.
- Select the toggle beside Crash and Exception Reporting to turn on the service.
Setting up customized reports with Advanced Cloud Diagnostics
By default, crash and exception reports are configured with standard metadata such as device OS. With Advanced Cloud Diagnostics, you can also add custom metadata for even more debugging capacity. This custom metadata can be captured at any point, such as when the game first initializes, a new level loads, or even when the player takes a specific action.
Crash and exception reports include a CrashReportHandler class for configuring crash reports and custom metadata. Use the SetUserMetadata method to add up to 64 custom metadata entries to your report.
Request a new piece of metadata to track with this statement:
Triggering a test report
Test the Cloud Diagnostics service by triggering a report and viewing it within the Unity Dashboard. Create a report by throwing an exception or logging an exception message via the Debug.LogException()method. To do this, locate a method within your C# script where you’d like the test exception to occur, such as the one that runs when the first screen is loaded, and add the following line:
Debug.LogException(new Exception(“Testing Cloud Diagnostics reports”));
Save the script and run your game in Play Mode. You should be able to view the Debug.LogException message in your console within the Editor.
Viewing your test report
View Cloud Diagnostic reports from the Unity Dashboard:
- Open the Unity Dashboard.
- Select the project enabled with Cloud Diagnostics from the project selector on the top navigation menu.
- From the main navigation menu, go to Suites > DevOps > Cloud Diagnostics > Crash and Exception Reporting.
- Your test report will be located in the Problems section. Select the title of the test report to view its data.
Setting up notifications for new reports
Cloud Diagnostics supports report notifications via integration so you can connect your development workflow to non-Unity tools. Instead of manually checking the Dashboard to see if any new problems have been reported, you can instead receive a notification via 3rd party integrations such as email, Slack, Discord, Trello, and more.
To set up report notifications:
Open the Unity Dashboard.
Select your project from the project selector on the top navigation menu.
- Note: Make sure you’ve enabled Crash and Exception reporting for this project before setting up report notifications.
From the main navigation menu, select Projects.
From the expanded dropdown list, select Project settings > Integrations.
Select the New Integration button and follow the instructions in the pop-up modal.
Batch mode support
As of 2018.4.1+ and 2019.1.3+, native crash reporting is now supported when running Unity in -batchmode. Native crash reporting is also supported when running apps as a Server Build. Be sure to specify both -username and -password in the command line when running in batch mode to avoid running into a USYM_UPLOAD_AUTH_TOKEN error.
Now that you’ve enabled Crash and Exception reports, learn how to understand and manage them.