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:
- Supports C# errors on multiple platforms, including: Android, iOS, macOS, Linux, Windows, and WebGL
- Line numbers for C# exceptions in IL2CPP builds.
- Native support for automatic crash error tracking for
- Android by using the Android SDK to support Java, Kotlin, C and C++
- iOS by using the iOS SDK to support Objective-C, Swift, C and C++
- Windows and Linux by using the Native SDK to support C and C++ with minidumps
- macOS by using the macOS SDK to support Objective-C, Swift, C and C++
- Screenshot attachments for errors
- 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.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
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.4.0
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.
The minimum configuration required is the DSN to your project.
___PUBLIC_DSN___
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.
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
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 an unhandled Null Reference Exception
testObject.GetComponent<Transform>(); // Captured error
}
}
Additionally, the packages includes a sample called "Unity of bugs" that can optionally be imported into your project through the package manager. The samples contain a variety of common bugs, including native errors, so you don't have to write them.
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 select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").