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:

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:

Copied
https://github.com/getsentry/unity.git#2.1.3

Configure

The minimum configuration required is the DSN to your project.

Copied
https://examplePublicKey@o0.ingest.sentry.io/0

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 window

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:

Copied
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
    }
}

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.