Unity
Our Unity SDK builds on top of the .NET SDK and extends it with Unity specific features. It gives developers helpful hints for where and why an error or performance issue might have occurred.
Additional Features:
- Native support for automatic crash error tracking by using the
- iOS SDK to support Objective-C, Swift, C and C++
- Android SDK to support Java, Kotlin, C and C++
- Offline caching stores event data to disk in case the device is not online
- Release Health to keep track of crash free users and sessions
- Breadcrumbs automatically captured for
- Unity's
Debug.Log
andDebug.LogWarning
- Scene load, unload, active change
- Unity's
- Event debouncing to handle high amounts of log output i.e. during
Update
On this page, we get you up and running with Sentry's SDK, so that it will automatically report errors and exceptions in your application.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
Install
Sentry captures data by using an SDK within your application’s runtime.
Install the package via the Unity Package Manager using a Git URL to Sentry's SDK repository:
https://github.com/getsentry/unity.git#2.1.3
Confirm the URL doesn't have a trailing whitespace at the end. The Unity Package Manager will fail to find the package if a trailing whitespace is appended.
Configure
The minimum configuration required is the DSN to your project.
https://examplePublicKey@o0.ingest.sentry.io/0
If you are logged in you can also select your project and copy its DSN directly from here.
Sentry can be configured via the Sentry configuration window or programatically.
The window can be accessed by going to Unity's top menu: Tools
> Sentry
.
Sentry saves your configuration to Assets/Resources/Sentry/SentryOptions.asset
and reads from there at runtime.
Verify
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up:
using Sentry;
using UnityEngine;
public class TestMonoBehaviour : MonoBehaviour
{
private GameObject testObject = null;
void Start()
{
Debug.Log("Captured Log"); // Breadcrumb
Debug.LogWarning("Captured Warning"); // Breadcrumb
Debug.LogError("Captured Error"); // Captured Error
// This will throw a Null Reference Exception
testObject.GetComponent<Transform>(); // Captured error
}
}
Learn more about manually capturing an error or message in our Usage documentation.
To view and resolve the recorded error, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
- Package:
- upm:sentry-unity
- Version:
- 2.1.3
- Repository:
- https://github.com/getsentry/sentry-unity