Skip to content

Conversation

@bitsandfoxes
Copy link
Contributor

Fixes #2411

Problem

The DisableUnityApplicationLoggingIntegration extension method was effectively a no-op - it removed the wrong integration in the best of cases, and did nothing in the worst.

Root Cause

Unity log/exception handling is split across two integrations:

  • UnityLogHandlerIntegration - captures actual exception objects from Debug.LogException (non-WebGL only)
  • UnityApplicationLoggingIntegration - captures logs, warnings, errors, breadcrumbs, and structured logs

WebGL requires special handling because UnityLogHandlerIntegration doesn't work on that platform. Previously in #2322, I added exception capture directly into UnityApplicationLoggingIntegration via a captureExceptions flag, configured in the SentryWebGL.Configure() callback.

This created two issues:

  1. Mixed responsibilities - UnityApplicationLoggingIntegration handled both logs AND exceptions (but only on WebGL)
  2. The extension method DisableUnityApplicationLoggingIntegration was incorrectly removing UnityLogHandlerIntegration instead of UnityApplicationLoggingIntegration

Solution

This PR cleanly separates concerns and fixes the extension methods:

  1. Created UnityWebGLExceptionHandler - dedicated integration for WebGL exception handling via Application.LogMessageReceived
  2. Simplified UnityApplicationLoggingIntegration - removed exception handling, now only handles logs/warnings/errors/breadcrumbs
  3. Centralized platform branching - all integration selection now happens in SentryUnityOptions constructor, removed from SentryWebGL.Configure() - This also restores the extension method functionality
  4. Fixed and renamed extension methods:
    • DisableUnityLoggingIntegration() - disables log/warning/error capture
    • DisableUnhandledExceptionCapture() - disables exception capture (both WebGL and non-WebGL handlers)

Added tests for both extension methods to prevent future regressions.

@bitsandfoxes bitsandfoxes merged commit ec8cc5b into main Nov 12, 2025
7 of 14 checks passed
@bitsandfoxes bitsandfoxes deleted the fix/unity-logging-and-disable branch November 12, 2025 13:32
@github-actions
Copy link
Contributor

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- `options.DisableLoggingIntegration()` is no longer no-op ([#2413](https://github.com/getsentry/sentry-unity/pull/2413))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 5f8662e

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.

DisableUnityApplicationLoggingIntegration invalid

3 participants