-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat (Unity): Updated options #12636
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
841549d
updated option section
bitsandfoxes 86be1e2
updated migration guide
bitsandfoxes 4beb634
whitespace
bitsandfoxes 3a25712
Apply suggestions from code review
bitsandfoxes a8b46a6
added cli explainer
bitsandfoxes 1384c13
runtime/buildTime explainer
bitsandfoxes e6ff0e9
updated troubleshooting
bitsandfoxes 4ae15e5
Merge branch 'master' into feat/update-unity-options
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+99.4 KB
...unity/configuration/options/cli-options/img/sentry-cli-option-configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions
65
docs/platforms/unity/configuration/options/cli-options/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
title: Sentry CLI Options | ||
description: "Learn more about how to configure the options used by Sentry CLI." | ||
sidebar_order: 30 | ||
--- | ||
|
||
The Unity SDK includes [Sentry CLI](/product/cli/) as a tool to upload debug symbols to Sentry. These debug symbols are used in processing events sent to Sentry to provide stacktraces and linenumbers. This page describes the options available to configure the Sentry CLI. | ||
|
||
## Programmatic Configuration | ||
|
||
Similar to the [programmatic configuration](/platforms/unity/configuration/options/programmatic-configuration/) of the SDK itself, the debug symbol upload via Sentry CLI also supports programmatic configuration. | ||
|
||
 | ||
|
||
The `Configure` callback gets invoked during the build process and allows you to modify the options used by Sentry CLI. | ||
|
||
## Sentry CLI Options | ||
|
||
<ConfigKey name="upload-symbols" supported={["dotnet"]}> | ||
|
||
Whether the SDK should automatically upload debug symbols to Sentry. This requires a valid auth token, organization, and project. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="upload-development-symbols" supported={["dotnet"]}> | ||
|
||
Whether the SDK should automatically upload debug symbols to Sentry for development builds. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="upload-sources" supported={["dotnet"]}> | ||
|
||
Whether the SDK should automatically upload sources to Sentry; this enables Sentry to provide source-context on events. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="url-override" supported={["dotnet"]}> | ||
|
||
This option allows you to override the default Sentry URL in case you are using a self-hosted Sentry instance or a custom domain. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="auth" supported={["dotnet"]}> | ||
|
||
The auth token to use when uploading symbols to Sentry. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="organization" supported={["dotnet"]}> | ||
|
||
The organization to use when uploading symbols to Sentry. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="project" supported={["dotnet"]}> | ||
|
||
The project to use when uploading symbols to Sentry. | ||
|
||
</ConfigKey> | ||
|
||
<ConfigKey name="ignore-cli-errors" supported={["dotnet"]}> | ||
|
||
If set to true, the Sentry CLI will not exit with an error code if it encounters an error. **BE AWARE** you might have unminified/unsymbolicated crashes in production if the debug symbol upload fails. When using this flag, you should store built sourcemaps and debug files, to re-run the upload symbols command at a later point. | ||
|
||
</ConfigKey> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+72.3 KB
...ty/configuration/options/programmatic-configuration/img/initialization-flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+104 KB
...guration/options/programmatic-configuration/img/unity-options-configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions
64
docs/platforms/unity/configuration/options/programmatic-configuration/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Programmatic Configuration | ||
description: "Learn more about how to configure the Unity SDK programmatically." | ||
sidebar_order: 20 | ||
--- | ||
|
||
We've added `Sentry Options Configuration` to the `Options Config` tab in the Sentry editor window to provide a way to modify options programmatically. | ||
|
||
 | ||
|
||
## Programmatic Configuration | ||
|
||
The Sentry SDK for Unity includes [platform-specific (that is, Native)](/platforms/unity/native-support/) SDKs, such as [Android](/platforms/android/), [Apple](/platforms/apple/guides/ios/), and [Native](/platforms/native/) to provide native crash suppport. These SDKs share the options with which they get initialized. | ||
|
||
The C# layer self-initializes through the use of the [SubsystemRegistration RuntimeInitializeOnLoadMethodAttribute](https://docs.unity3d.com/ScriptReference/RuntimeInitializeLoadType.SubsystemRegistration.html). | ||
|
||
 | ||
|
||
If provided, the `Option Configuration Script` is executed on each app startup. The options are first used to initialize the native SDKs, then the managed (C#) SDK. This means that the options you set in your `Configure` callback will also apply on the native layer. For example: | ||
|
||
```csharp | ||
public override void Configure(SentryUnityOptions options) | ||
{ | ||
// BeforeSend is currently limited to C# code. Native errors - such as crashes in C/C++ code - are getting | ||
// captured by the native SDKs, but the native SDKs won't invoke this callback. | ||
options.SetBeforeSend((sentryEvent, _) => | ||
{ | ||
if (sentryEvent.Tags.ContainsKey("SomeTag")) | ||
{ | ||
// Don't send events with a tag "SomeTag" to Sentry | ||
return null; | ||
} | ||
|
||
return sentryEvent; | ||
}); | ||
|
||
// Native SDK initialization timing options: | ||
// Build-time initialization: | ||
// + Can capture Unity engine errors | ||
// - Options are fixed at build time | ||
// Runtime initialization: | ||
// + Allows dynamic configuration | ||
// - May miss some early errors | ||
#if UNITY_ANDROID | ||
options.AndroidNativeInitializationType = NativeInitializationType.Runtime; | ||
#elif UNITY_IOS | ||
options.IosNativeInitializationType = NativeInitializationType.Runtime; | ||
#endif | ||
} | ||
``` | ||
|
||
### Initialize Native SDKs first when targeting iOS or Android | ||
|
||
On mobile, the Unity SDK automatically modifies the generated Xcode and Gradle project to also contain the Cocoa and Java SDK respectively. These SDKs are capable of self-initializing before the Unity engine itself is started. This allows us to capture bugs/crashes happening within the engine itself. | ||
There are two initialization types: | ||
|
||
- `NativeInitializationType.Runtime`: Native SDKs initialize during runtime alongside the C# SDK | ||
- `NativeInitializationType.BuildTime`: Native SDKs initialize before Unity engine starts | ||
|
||
### Runtime Initialization (Default) | ||
With runtime initialization, the native SDKs are initialized at runtime alongside the C# SDK. This allows all options to be dynamically configured through C# code during execution. | ||
|
||
### Build Time Initialization | ||
When using build time initialization, the native SDKs are configured during build time and initialize before the Unity engine starts. This means the options are baked into the outputted projects and cannot be modified at runtime via C# code. Changes to properties like `Release` and `Environment` will not apply to events generated by the native SDKs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-61.6 KB
platform-includes/configuration/config-intro/img/unity-options-configuration.png
Binary file not shown.
Binary file removed
BIN
-61.6 KB
platform-includes/configuration/config-intro/unity-options-configuration.png
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.