Skip to content

chore(deps): update .NET SDK to v7.1.0 - #2967

Draft
bitsandfoxes wants to merge 10 commits into
mainfrom
spire/upgrade-sentry-unity-to-sentry-dotnet-7
Draft

bitsandfoxes wants to merge 10 commits into
mainfrom
spire/upgrade-sentry-unity-to-sentry-dotnet-7

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

sentry-unity is still on sentry-dotnet 6.12.1. Newer .NET SDK features, such as the session replay hook in sentry-dotnet 7.1 (getsentry/sentry-dotnet#5990), can't reach Unity until it builds against 7.x. sentry-dotnet 7.0 removed or hid APIs that sentry-unity and its users rely on, so moving the submodule alone doesn't build. One of them, SentryOptions.EnableLogs, was the master switch behind Unity's structured logs, while the Godot and Unreal SDKs already pick logs per log type, with no master switch.

How

src/sentry-dotnet points at sentry-dotnet 7.1 from main, plus one commit that adds Sentry.Unity.Native.PlayStation, .Switch, .Xbox and .Android to the InternalsVisibleTo list in Sentry.Unity.props. global.json follows the submodule to .NET SDK 11.0.100.

Structured logs work per log type, as in the Godot and Unreal SDKs:

  • The Logging tab has no "Enable Structured Logging" switch. The toggles under "Automatically forward logs to Sentry for:" stand on their own, and they and CaptureStructuredLogsForLogType are off by default.
  • Existing projects keep sending what they send. When an options asset that had the old switch off loads, all five toggles are turned off once. An asset that had it on keeps its toggles, and later changes stick.
  • SentryUnityOptions.EnableLogs and ScriptableSentryUnityOptions.EnableStructuredLogging are [Obsolete] and have no effect, so code that sets them still compiles, with a warning that points to the per-type options.
  • A log type that's sent as a structured log adds a breadcrumb only with "Attach logs as breadcrumbs in addition to sending them as structured logs" on. Every other type follows its own Breadcrumbs toggle, which the Logging tab greys out only where it has no effect.
  • When the Unity SDK starts sentry-java or sentry-cocoa at runtime, logs are enabled in them, so logs that native code sends reach Sentry. This starts no automatic capture of native log output.
  • Logs written through SentrySdk.Logger are always sent, and SetBeforeSendLog drops them. Its doc comment now says so.

Minified Android builds get all of the Unity SDK's options applied to the Android SDK at runtime start. The ProGuard rules keep SentryOptions$Logs, so the call that enables logs no longer fails and stops the options after it (screenshots, automatic session tracking, activity lifecycle and user interaction breadcrumbs, user interaction tracing) from being turned off.

The CHANGELOG's Breaking Changes section lists the APIs 7.x removed or hid, each with its replacement: Scope.Release/Distribution, ApplyDefaultTags, EnableMetrics, EnableLogs, and ScopeObserver/EnableScopeSync/CrashedLastRun. It also covers the logging changes above.

Sentry.Unity.Native.csproj compiles SentryNative.cs again into a separate assembly for each console and for Android. 7.x made CrashedLastRun internal and ScopeObserver/EnableScopeSync protected internal, so those assemblies need the InternalsVisibleTo entries to set them. NativePropagationContext takes the scope parameter that 7.x added to IExternalPropagationContext.GetDynamicSamplingContext, and passes it on when it builds the sampling context. The old switch's serialized value is read into a hidden "migrated" flag: an asset where it was off has its toggles turned off on load and the flag set, so the migration runs once per asset, and new assets start migrated.

Caveats

  • The submodule commit is on the sentry-dotnet branch unity/internals-visible-to-native-platforms. It has to be merged into getsentry/sentry-dotnet before this PR merges. Once it merges, the submodule moves to the merged commit.
  • With build-time native initialization on Android or iOS, the native SDKs keep logs off, as before.
  • The integration test app no longer sets EnableLogs, so it sends no Debug.Log structured logs and adds breadcrumbs for warnings, asserts and errors again. Its checks cover only the logs and breadcrumbs it sends itself.

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.

1 participant