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

Conversation

bitsandfoxes
Copy link
Contributor

No description provided.

…d added explainer on how the SDK captures errors
Copy link

vercel bot commented Mar 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 4:11pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Mar 4, 2025 4:11pm
develop-docs ⬜️ Ignored (Inspect) Visit Preview Mar 4, 2025 4:11pm

Copy link

codecov bot commented Mar 3, 2025

Bundle Report

Changes will increase total bundle size by 210 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.2MB 216 bytes (0.0%) ⬆️
sentry-docs-client-array-push 9.39MB -6 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.46MB -0.0%
../instrumentation.js -3 bytes 791.26kB -0.0%
9523.js -3 bytes 767.46kB -0.0%
../app/[[...path]]/page.js.nft.json 75 bytes 382.67kB 0.02%
../app/platform-redirect/page.js.nft.json 75 bytes 382.59kB 0.02%
../app/sitemap.xml/route.js.nft.json 75 bytes 380.56kB 0.02%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 868.04kB -0.0%
static/chunks/4028-*.js -3 bytes 393.29kB -0.0%
server/middleware-*.js -5.55kB 1.0kB -84.74%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
static/HAc9eHz5txc7pLmjmYJzo/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/HAc9eHz5txc7pLmjmYJzo/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/MD1ig-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
static/MD1ig-*.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️

Copy link
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating! 🤠


<ConfigKey name="database-path" supported={["native"]}>
Sets the release. Some SDKs will try to automatically configure a release out of the box but it's a better idea to manually set it, guaranteeing that the release is in sync with your deploy integrations or source map uploads. Release names are strings, but some formats are detected by Sentry and might be rendered differently. Learn more about how to send release data so Sentry can tell you about regressions between releases and identify the potential source in [the releases documentation](/product/releases/) or the <SandboxLink scenario="releases">sandbox</SandboxLink>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Some SDKs" seems generic. Here we know it's Unity. Is it benefitial to set something manually in Unity? I think our auto detection is quite on point since it relies on the Unitys' version already right?

Suggested change
Sets the release. Some SDKs will try to automatically configure a release out of the box but it's a better idea to manually set it, guaranteeing that the release is in sync with your deploy integrations or source map uploads. Release names are strings, but some formats are detected by Sentry and might be rendered differently. Learn more about how to send release data so Sentry can tell you about regressions between releases and identify the potential source in [the releases documentation](/product/releases/) or the <SandboxLink scenario="releases">sandbox</SandboxLink>.


By default, the SDK reports `editor` when running inside the Unity Editor. Otherwise, the default environment is `production`.
Sentry differentiates stack frames that are directly related to your application ("in application") from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The application package is automatically marked as `inApp`. The difference is visible in [sentry.io](https://sentry.io), where only the "in application" frames are displayed by default.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about being specific here too (what lingo makes more sense for Unity devs?)

Suggested change
Sentry differentiates stack frames that are directly related to your application ("in application") from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The application package is automatically marked as `inApp`. The difference is visible in [sentry.io](https://sentry.io), where only the "in application" frames are displayed by default.
Sentry differentiates stack frames that are directly related to your application ("in application") from stack frames that come from other packages such Unity's APIs, .NET's APIs, or other packages and dependencies. The application package is automatically marked as `inApp`. The difference is visible in [sentry.io](https://sentry.io), where only the "in application" frames are displayed by default.

Comment on lines +152 to +155
- Universal Windows platform (UWP) applications
- WinForms applications
- Windows Presentation Foundation (WPF) applications
- Single user console applications
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about listing Unity deployment types here? Unity Server, vs Unity on a Mobile, Desktop or Web app?

- Windows Presentation Foundation (WPF) applications
- Single user console applications

Defaults to `false`, unless in Blazor WASM, MAUI, Unity, or Xamarin where the default is `true`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant

Suggested change
Defaults to `false`, unless in Blazor WASM, MAUI, Unity, or Xamarin where the default is `true`.

Once enabled, this feature automatically captures HTTP client errors, like bad response codes, as error events and reports them to Sentry.
This option can be used to supply a server name. When provided, the name of the server is sent along and persisted in the event. For many integrations, the server name actually corresponds to the device hostname, even in situations where the machine is not actually a server.

For ASP.NET and ASP.NET Core applications, the value will default to the server's name. For other application types, the value will default to the computer's name only when the `SendDefaultPii` is set to `true`, because the computer's name can be considered personally identifiable information (PII) in the case of a desktop or mobile application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pro not relevant either


## 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 and those log messages are added as breadcrumbs to future events. By default, the SDK will also automatically capture messages logged via `Debug.LogError` as error events and send them to Sentry. This behaviour can be disabled by unchecking the automatic capture of `Debug.LogError` on the `Enrichment` tab, or programmatically, by setting the `CaptureLogErrorEvents` option to `false` in the [configure callback](/platforms/unity/configuration/options/programmatic-configuration).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tab could be in Sentry (sentry.io)

Suggested change
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 and those log messages are added as breadcrumbs to future events. By default, the SDK will also automatically capture messages logged via `Debug.LogError` as error events and send them to Sentry. This behaviour can be disabled by unchecking the automatic capture of `Debug.LogError` on the `Enrichment` tab, or programmatically, by setting the `CaptureLogErrorEvents` option to `false` in the [configure callback](/platforms/unity/configuration/options/programmatic-configuration).
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 and those log messages are added as breadcrumbs to future events. By default, the SDK will also automatically capture messages logged via `Debug.LogError` as error events and send them to Sentry. This behaviour can be disabled by unchecking the automatic capture of `Debug.LogError` on the `Enrichment` tab in the editor (Tools->Sentry), or programmatically, by setting the `CaptureLogErrorEvents` option to `false` in the [configure callback](/platforms/unity/configuration/options/programmatic-configuration).


### Stack Trace Support & Line Numbers

If [configured](https://docs.unity3d.com/6000.0/Documentation/Manual/stack-trace.html), Unity will include the stack traces with the log messages as raw strings. The SDK is able to parse and display this stack trace in the issues details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If [configured](https://docs.unity3d.com/6000.0/Documentation/Manual/stack-trace.html), Unity will include the stack traces with the log messages as raw strings. The SDK is able to parse and display this stack trace in the issues details.
If [configured](https://docs.unity3d.com/6000.0/Documentation/Manual/stack-trace.html), Unity will include the stack traces with the log messages as raw strings. The Sentry SDK is able to parse and display this stack trace in the issue details page.


If [configured](https://docs.unity3d.com/6000.0/Documentation/Manual/stack-trace.html), Unity will include the stack traces with the log messages as raw strings. The SDK is able to parse and display this stack trace in the issues details.

If you're using Unity 6 or newer, you have the option to to 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 stack trace and will be parsed by the SDK. Unfortunately, since there is no native exception at the time of logging, the SDK is not be able to provide line numbers otherwise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you're using Unity 6 or newer, you have the option to to 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 stack trace and will be parsed by the SDK. Unfortunately, since there is no native exception at the time of logging, the SDK is not be able to provide line numbers otherwise.
If you're using Unity 6 or newer, you have the option to to 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 stack trace and will be parsed by the SDK. In order to get line number for log messages, this option must be turned on. For `Log.LogException`, this option isn't required since Sentry can [symbolicate server-side](/platforms/unity/configuration/il2cpp/) the stack trace and add line mumbers.


<Alert>

The Unity SDK does not provide stack traces for messages.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flip it around by saying what we do have, to help clarify what we don't.

Suggested change
The Unity SDK does not provide stack traces for messages.
The Sentry SDK for Unity only provides stack traces for captured Exceptions. Logged messages won't have line numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants