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 @@ -4,6 +4,7 @@

### Features

- Added option to enable/disable automatic capture of `Debug.LogError` as event. ([#2009](https://github.com/getsentry/sentry-unity/pull/2009))
- The `Ignore CLI Errors` checkbox in the Debug Symbols tab now applies to all supported platforms. ([#2008](https://github.com/getsentry/sentry-unity/pull/2008))
- The SDK now provides stacktraces when capturing events created via `Debug.LogError`. Note, that the SDK is currently not able to provide line numbers for these events. ([#1965](https://github.com/getsentry/sentry-unity/pull/1965))

Expand Down
19 changes: 12 additions & 7 deletions src/Sentry.Unity.Editor/ConfigurationWindow/EnrichmentTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,31 @@ internal static void Display(ScriptableSentryUnityOptions options)
EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 1), Color.gray);
EditorGUILayout.Space();

GUILayout.Label("Automatically capture and send events for:", EditorStyles.boldLabel);
EditorGUILayout.Space();

options.CaptureLogErrorEvents = EditorGUILayout.Toggle(
new GUIContent("Capture LogError as Event", "Whether the SDK automatically captures events for 'Debug.LogError'."),
new GUIContent("Debug.LogError", "Whether the SDK automatically captures events for 'Debug.LogError'."),
options.CaptureLogErrorEvents);

GUILayout.Label("Breadcrumbs automatically added for LogType:", EditorStyles.boldLabel);
EditorGUILayout.Space();
GUILayout.Label("Automatically create breadcrumbs for:", EditorStyles.boldLabel);
EditorGUILayout.Space();

options.BreadcrumbsForLogs = EditorGUILayout.Toggle(
new GUIContent("Log", "Whether the SDK automatically adds breadcrumbs 'Debug.Log'."),
new GUIContent("Debug.Log", "Whether the SDK automatically adds breadcrumbs 'Debug.Log'."),
options.BreadcrumbsForLogs);
options.BreadcrumbsForWarnings = EditorGUILayout.Toggle(
new GUIContent("Warning", "Whether the SDK automatically adds breadcrumbs for 'Debug.LogWarning'."),
new GUIContent("Debug.Warning", "Whether the SDK automatically adds breadcrumbs for 'Debug.LogWarning'."),
options.BreadcrumbsForWarnings);
options.BreadcrumbsForAsserts = EditorGUILayout.Toggle(
new GUIContent("Assert", "Whether the SDK automatically adds breadcrumbs for 'Debug.Assert'."),
new GUIContent("Debug.Assert", "Whether the SDK automatically adds breadcrumbs for 'Debug.Assert'."),
options.BreadcrumbsForAsserts);
options.BreadcrumbsForErrors = EditorGUILayout.Toggle(
new GUIContent("Error", "Whether the SDK automatically adds breadcrumbs for 'Debug.LogError'."),
new GUIContent("Debug.Error", "Whether the SDK automatically adds breadcrumbs for 'Debug.LogError'."),
options.BreadcrumbsForErrors);
options.BreadcrumbsForExceptions = EditorGUILayout.Toggle(
new GUIContent("Exception", "Whether the SDK automatically adds breadcrumbs for exceptions and 'Debug.LogException'."),
new GUIContent("Debug.Exception", "Whether the SDK automatically adds breadcrumbs for exceptions and 'Debug.LogException'."),
options.BreadcrumbsForExceptions);

EditorGUILayout.Space();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,26 @@ public void OnLogMessageReceived_LogContainsSentryTag_NotCaptured()
}

[Test]
public void OnLogMessageReceived_LogTypeError_CaptureEvent()
[TestCase(true)]
[TestCase(false)]
public void OnLogMessageReceived_LogTypeError_CaptureEvent(bool captureLogErrorEvents)
{
_fixture.SentryOptions.CaptureLogErrorEvents = captureLogErrorEvents;
var sut = _fixture.GetSut();
var message = TestContext.CurrentContext.Test.Name;

sut.OnLogMessageReceived(message, string.Empty, LogType.Error);

Assert.AreEqual(1, _fixture.Hub.CapturedEvents.Count);
Assert.NotNull(_fixture.Hub.CapturedEvents[0].Message);
Assert.AreEqual(message, _fixture.Hub.CapturedEvents[0].Message!.Message);
if (captureLogErrorEvents)
{
Assert.AreEqual(1, _fixture.Hub.CapturedEvents.Count);
Assert.NotNull(_fixture.Hub.CapturedEvents[0].Message);
Assert.AreEqual(message, _fixture.Hub.CapturedEvents[0].Message!.Message);
}
else
{
Assert.AreEqual(0, _fixture.Hub.CapturedEvents.Count);
}
}

[Test]
Expand Down
Loading