Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Unity): Updated options and error capture explainer #12904

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/platforms/unity/configuration/error-capture.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Error Capture
sidebar_order: 60
description: "Learn more about how to configure your SDK to automatically send events to Sentry."
---

The SDK relies on two integrations to capture errors: `UnityLogHandlerIntegration` and the `UnityApplicationLoggingIntegration`. While they sound similar, they serve different purposes.

## UnityLogHandlerIntegration

The SDK uses the `UnityLogHandlerIntegration` to hook into Unity's logging system. From there it receives all log messages that are logged via the `Debug.Log`, `Debug.LogWarning`, and `Debug.LogError` methods. These log messages are also added as breadcrumbs to future events. By default, the SDK will automatically capture messages logged via `Debug.LogError` as error events. This can be disabled by unchecking the automatic capture of `Debug.LogError` on the `Enrichment` tab, or by setting the `CaptureLogErrorEvents` option to `false`.

https://docs.unity3d.com/6000.0/Documentation/Manual/stack-trace.html

If configured, the SDK receives the stacktrace as part of the logging messages in a raw string format. The SDK is able to parse this format and display it in the Sentry UI. Unfortunately, to provide line numbers, the SDK needs to have an actual thrown exception object to fetch the required information for symbolication. Read more about the IL2CPP error symbolication works [here](/platforms/unity/configuration/il2cpp). If you're using Unity 6 or newer, you can enable the source code line numbers in the [player settings](https://docs.unity3d.com/6000.0/Documentation/Manual/il2cpp-managed-stack-traces.html). These line numbers are then part of the stringified stacktrace and will be parsed by the SDK.

## UnityApplicationLoggingIntegration

The SDK uses the `UnityApplicationLoggingIntegration` to add its own log handler right before Unity's logging system and passes the logs back to Unity. This allows the SDK to capture errors from the `Application.logMessageReceived` method. All handled exceptions (i.e., those captured via `Log.LogException` calls) and unhandled exceptions are captured by the SDK. These messages contain the actual exception object, which allows the SDK to fetch the required information for symbolication.
Loading
Loading