Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Features

- The SDK no longer ends sessions as crashed when capturing unhandled or logged exceptions. Instead, sessions get correctly marked as `SessionEndStatus.Unhandled` ([#2376](https://github.com/getsentry/sentry-unity/pull/2376))
- Added support for Structured Logging. The `SentrySdk.Logger` API is now exposed for Unity users, enabling structured log capture. The SDK can also automatically capture and send Debug logs based on the options configured. ([#2368](https://github.com/getsentry/sentry-unity/pull/2368))

### Dependencies
Expand Down
7 changes: 4 additions & 3 deletions src/Sentry.Unity/Integrations/UnityErrorLogException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ internal class UnityErrorLogException : Exception
private readonly SentryOptions? _options;
private readonly IDiagnosticLogger? _logger;

public UnityErrorLogException(string logString, string logStackTrace, SentryOptions? options)
: base(logString)
public UnityErrorLogException(string logString, string logStackTrace, SentryOptions? options) : base(logString)
{
_logString = logString;
_logStackTrace = logStackTrace;
Expand Down Expand Up @@ -55,7 +54,9 @@ public SentryException ToSentryException()
Mechanism = new Mechanism
{
Handled = true,
Type = "unity.log"
Type = "unity.log",
Synthetic = true,
Data = { { Mechanism.TerminalKey, false } }
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ internal void ProcessException(Exception exception, UnityEngine.Object? context)
// NOTE: This might not be entirely true, as a user could as well call `Debug.LogException`
// and expect a handled exception but it is not possible for us to differentiate
// https://docs.sentry.io/platforms/unity/troubleshooting/#unhandled-exceptions---debuglogexception
exception.Data[Mechanism.HandledKey] = false;
exception.Data[Mechanism.MechanismKey] = "Unity.LogException";
exception.SetSentryMechanism("Unity.LogException", handled: false, terminal: false);
_ = _hub.CaptureException(exception);

if (_options.Experimental.CaptureStructuredLogsForLogType.TryGetValue(LogType.Exception, out var captureException) && captureException)
Expand Down
8 changes: 6 additions & 2 deletions test/Sentry.Unity.Tests/UnityErrorLogExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public void ToSentryException_ParsingTestCases(
Mechanism = new Mechanism
{
Handled = true,
Type = "unity.log"
Type = "unity.log",
Synthetic = true,
Data = { {Mechanism.TerminalKey, false} }
}
}
},
Expand Down Expand Up @@ -189,7 +191,9 @@ public void ToSentryException_ParsingTestCases(
Mechanism = new Mechanism
{
Handled = true,
Type = "unity.log"
Type = "unity.log",
Synthetic = true,
Data = { {Mechanism.TerminalKey, false} }
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/Sentry.Unity.Tests/UnityLogHandlerIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public void CaptureException_ExceptionCapturedAndMechanismSet()

Assert.IsTrue(capturedEvent.Exception!.Data.Contains(Mechanism.MechanismKey));
Assert.AreEqual("Unity.LogException", (string)capturedEvent.Exception!.Data[Mechanism.MechanismKey]);

Assert.IsTrue(capturedEvent.Exception!.Data.Contains(Mechanism.TerminalKey));
Assert.IsFalse((bool)capturedEvent.Exception!.Data[Mechanism.TerminalKey]);
}

[Test]
Expand Down
Loading