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 #12636

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Feb 10, 2025

This addresses the bigger changes introduced with 3.0.0 and cleans up the documentation around Unity SDK's options and their programmatic configuration.

  1. Merging of Runtime and BuildTime Configuration
  2. Defaulting to runtime initialization for native SDKs now on all platforms
  3. Opt-In to restore previous behaviour.
  4. Sentry CLI options and their programmatic configuration
  5. Migration Guide for 3.0.0 (and the missing 2.4.0)

Also fixes getsentry/sentry-unity#1795

Copy link

vercel bot commented Feb 10, 2025

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

Name Status Preview Comments Updated (UTC)
sentry-docs ❌ Failed (Inspect) Feb 14, 2025 2:31pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 2:31pm
develop-docs ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 2:31pm

Copy link

codecov bot commented Feb 10, 2025

Bundle Report

Changes will increase total bundle size by 1.34kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.71MB 1.34kB (0.01%) ⬆️
sentry-docs-client-array-push 9.38MB -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.64MB -0.0%
../instrumentation.js -3 bytes 968.3kB -0.0%
9523.js -3 bytes 944.51kB -0.0%
../app/[[...path]]/page.js.nft.json 451 bytes 376.93kB 0.12%
../app/platform-redirect/page.js.nft.json 451 bytes 376.85kB 0.12%
../app/sitemap.xml/route.js.nft.json 451 bytes 374.82kB 0.12%
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 865.95kB -0.0%
static/chunks/7801-*.js -3 bytes 391.02kB -0.0%
server/middleware-*.js -5.55kB 1.0kB -84.74%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
static/Hl8bSRhMdRg6xZqZOR_Qt/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/Hl8bSRhMdRg6xZqZOR_Qt/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/eXwqyac51RmWNbUAPllRK/_buildManifest.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️
static/eXwqyac51RmWNbUAPllRK/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️


![Options Configuration](./img/sentry-cli-option-configuration.png)

The `Configure` callback gets invoked during the build process and allows you to modify the options used by Sentry CLI.
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth clarifying a bit what is going on here? LIke we have a CLI, and it has options. But we also inlude the CLI in the SDK, and the options for it are configurable via the editor (right?) but also via C# code (what you already said below):

Suggested change
The `Configure` callback gets invoked during the build process and allows you to modify the options used by Sentry CLI.
While the options below describe the arguments accepted by [Sentry CLI](https://docs.sentry.io/cli/), the Sentry SDK for Unity includes the CLI within it. And exposes a way to configure it through the editor itself, as well as through code. The `Configure` callback gets invoked during the build process and allows you to modify the options used by Sentry CLI.

Copy link
Member

Choose a reason for hiding this comment

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

❤️


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 of even the engine.

The options to enable self-initialization are accessible via `AndroidNativeInitializationType` and `IosNativeInitializationType`. They default to `NativeInitializationType.Runtime`. When set to `Buildtime`, the native SDKs are configured and set up during `build time` and initialize themselves before the Unity engine. This means, that these options are baked into the outputted projects and cannot be changed at runtime via C# code. Changes to i.e. `Release` and `Environment` will not apply to events generated by the native SDKs. If you need to change these options at runtime, consider keepting the initialization type to `runtime`.
Copy link
Member

Choose a reason for hiding this comment

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

They default to NativeInitializationType.Runtime.

This concept wasn't introduced yet. how about right above this paragraph, having a two bullet points one for each value of They default to NativeInitializationType and describe what they do roughly. Then the paragraph is further explanation of the inner workkings?


## Migrating to 2.4.0

### Breaking Changes
Copy link
Member

Choose a reason for hiding this comment

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

Is it a breaking change on 2.4.0? I thought the old code worked fine, we just introduced some new way.


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 of even the engine.

The options to enable self-initialization are accessible via `AndroidNativeInitializationType` and `IosNativeInitializationType`. They default to `NativeInitializationType.Runtime`. When set to `Buildtime`, the native SDKs are configured and set up during `build time` and initialize themselves before the Unity engine. This means, that these options are baked into the outputted projects and cannot be changed at runtime via C# code. Changes to i.e. `Release` and `Environment` will not apply to events generated by the native SDKs. If you need to change these options at runtime, consider keepting the initialization type to `runtime`.
Copy link
Contributor

@coolguyzone coolguyzone Feb 10, 2025

Choose a reason for hiding this comment

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

Suggested change
The options to enable self-initialization are accessible via `AndroidNativeInitializationType` and `IosNativeInitializationType`. They default to `NativeInitializationType.Runtime`. When set to `Buildtime`, the native SDKs are configured and set up during `build time` and initialize themselves before the Unity engine. This means, that these options are baked into the outputted projects and cannot be changed at runtime via C# code. Changes to i.e. `Release` and `Environment` will not apply to events generated by the native SDKs. If you need to change these options at runtime, consider keepting the initialization type to `runtime`.
The options to enable self-initialization are accessible via `AndroidNativeInitializationType` and `IosNativeInitializationType`. They default to `NativeInitializationType.Runtime`. When set to `Buildtime`, the native SDKs are configured and set up during `build time` and initialize themselves before the Unity engine. This means that these options are baked into the outputted projects and cannot be changed at runtime via C# code. Changes to `Release` and `Environment` will not apply to events generated by the native SDKs. If you need to change these options at runtime, consider keepting the initialization type to `runtime`.


### Breaking Changes

The Runtime- and BuildTime-Configuration have been merged into a single OptionsConfiguration script. This allows for programmatic configuration of the SDK in one place using precompile directives instead of having to duplicate setting options in two different files.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The Runtime- and BuildTime-Configuration have been merged into a single OptionsConfiguration script. This allows for programmatic configuration of the SDK in one place using precompile directives instead of having to duplicate setting options in two different files.
The Runtime- and BuildTime-Configuration have been merged into a single OptionsConfiguration script. This allows for programmatic configuration of the SDK in one place using precompiled directives instead of having to duplicate setting options in two different files.

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.

Looks good! Thanks for updating.

Co-authored-by: Alex Krawiec <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
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.

Document IgnoreCliErrors
3 participants