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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Breaking Changes

- Renamed the option `AttachBreadcrumbsToEvents` to `AddBreadcrumbsWithStructuredLogs` to better reflect its purpose. The option controls if the SDK does BOTH: attach logs as breadcrumbs to events and send them as structured logs ([#2455](https://github.com/getsentry/sentry-unity/pull/2455))

### Dependencies

- Bump Cocoa SDK from v9.0.0 to v9.1.0 ([#2454](https://github.com/getsentry/sentry-unity/pull/2454))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ MonoBehaviour:
<StructuredLogOnDebugLogAssertion>k__BackingField: 1
<StructuredLogOnDebugLogError>k__BackingField: 1
<StructuredLogOnDebugLogException>k__BackingField: 1
<AttachBreadcrumbsToEvents>k__BackingField: 0
<AddBreadcrumbsWithStructuredLogs>k__BackingField: 0
<BreadcrumbsForLogs>k__BackingField: 1
<BreadcrumbsForWarnings>k__BackingField: 1
<BreadcrumbsForAsserts>k__BackingField: 1
Expand Down Expand Up @@ -73,6 +73,7 @@ MonoBehaviour:
<MacosNativeSupportEnabled>k__BackingField: 1
<LinuxNativeSupportEnabled>k__BackingField: 1
<XboxNativeSupportEnabled>k__BackingField: 1
<PlayStationNativeSupportEnabled>k__BackingField: 1
<Il2CppLineNumberSupportEnabled>k__BackingField: 1
<OptionsConfiguration>k__BackingField: {fileID: 11400000, guid: cea63afb7c75f429799422326f926abe, type: 2}
<Debug>k__BackingField: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public override void Configure(SentryUnityOptions options)
options.Enabled = false;
}

// BeforeSend is currently limited to C# code. Native errors - such as crashes in C/C++ code - are getting
// BeforeSend is currently limited to C# code. Native errors - such as crashes in C/C++ code - are getting
// captured by the native SDKs, but the native SDKs won't invoke this callback.
options.SetBeforeSend((sentryEvent, _) =>
{
Expand All @@ -31,13 +31,24 @@ public override void Configure(SentryUnityOptions options)
return sentryEvent;
});

options.SetBeforeSendLog(log =>
{
// You can filter logs based on tags
if (log.Message.StartsWith("Sensitive:"))
{
return null;
}

return log;
});

// Native SDK initialization timing options:
// Build-time initialization:
// + Can capture Unity engine errors
// - Options are fixed at build time
// Runtime initialization:
// + Allows dynamic configuration
// - May miss some early errors
// - Miss some early errors that happen before the SDK initialized
#if UNITY_ANDROID
options.AndroidNativeInitializationType = NativeInitializationType.Runtime;
#elif UNITY_IOS
Expand Down
12 changes: 6 additions & 6 deletions src/Sentry.Unity.Editor/ConfigurationWindow/LoggingTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ internal static class LoggingTab
internal static void Display(ScriptableSentryUnityOptions options)
{
{
GUILayout.Label("Structured Logging - Experimental", EditorStyles.boldLabel);

options.EnableStructuredLogging = EditorGUILayout.BeginToggleGroup(
new GUIContent("Send Logs for:", "Enables the SDK to forward log messages to Sentry " +
new GUIContent("Enable Structured Logging", "Enables the SDK to forward log messages to Sentry " +
"based on the log level."),
options.EnableStructuredLogging);

GUILayout.Label("Automatically forward logs to Sentry for:", EditorStyles.boldLabel);

EditorGUI.indentLevel++;

options.StructuredLogOnDebugLog = EditorGUILayout.Toggle(
Expand Down Expand Up @@ -52,11 +52,11 @@ internal static void Display(ScriptableSentryUnityOptions options)

if (options.EnableStructuredLogging)
{
EditorGUILayout.LabelField("Note: With sending structured logs enabled you have to opt-into adding breadcrumbs to events.", EditorStyles.boldLabel);
EditorGUILayout.LabelField("Note: With Structured Logging enabled you have to opt-into adding breadcrumbs to events.", EditorStyles.boldLabel);

options.AttachBreadcrumbsToEvents = EditorGUILayout.BeginToggleGroup(
options.AddBreadcrumbsWithStructuredLogs = EditorGUILayout.BeginToggleGroup(
new GUIContent("Attach logs as breadcrumbs in addition to sending them as structured logs", "Whether the SDK should attach breadcrumbs to events in addition to structured logging."),
options.AttachBreadcrumbsToEvents);
options.AddBreadcrumbsWithStructuredLogs);
}

EditorGUI.indentLevel++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void ProcessBreadcrumbs(string message, LogType logType)
}

// Breadcrumb collection on top of structure log capture must be opted in
if (_options is { EnableLogs: true, AttachBreadcrumbsToEvents: false })
if (_options is { EnableLogs: true, AddBreadcrumbsWithStructuredLogs: false })
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry.Unity/ScriptableSentryUnityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null)
[field: SerializeField] public bool StructuredLogOnDebugLogError { get; set; } = true;
[field: SerializeField] public bool StructuredLogOnDebugLogException { get; set; } = true;

[field: SerializeField] public bool AttachBreadcrumbsToEvents { get; set; } = false;
[field: SerializeField] public bool AddBreadcrumbsWithStructuredLogs { get; set; } = false;

[field: SerializeField] public bool BreadcrumbsForLogs { get; set; } = true;
[field: SerializeField] public bool BreadcrumbsForWarnings { get; set; } = true;
Expand Down Expand Up @@ -204,7 +204,7 @@ internal SentryUnityOptions ToSentryUnityOptions(
[LogType.Error] = StructuredLogOnDebugLogError,
[LogType.Exception] = StructuredLogOnDebugLogException
},
AttachBreadcrumbsToEvents = AttachBreadcrumbsToEvents
AddBreadcrumbsWithStructuredLogs = AddBreadcrumbsWithStructuredLogs
};

// By default, the cacheDirectoryPath gets set on known platforms. We're overwriting this behaviour here.
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Unity/SentryUnityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public sealed class SentryUnityOptions : SentryOptions
/// When set to true, breadcrumbs will be added on top of structured logging.
/// Defaults to false.
/// </summary>
public bool AttachBreadcrumbsToEvents { get; set; } = false;
public bool AddBreadcrumbsWithStructuredLogs { get; set; } = false;

/// <summary>
/// Whether the SDK automatically captures events for 'Debug.LogError'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void OnLogMessageReceived_AddAsBreadcrumbDisabled_NotAddedAsBreadcrumb(Lo
public void OnLogMessageReceived_ExperimentalLogsEnabledWithAttachBreadcrumbsFalse_BreadcrumbsNotAdded(LogType unityLogType)
{
_fixture.SentryOptions.EnableLogs = true;
_fixture.SentryOptions.AttachBreadcrumbsToEvents = false;
_fixture.SentryOptions.AddBreadcrumbsWithStructuredLogs = false;
_fixture.SentryOptions.AddBreadcrumbsForLogType[unityLogType] = true;
var sut = _fixture.GetSut();
var message = TestContext.CurrentContext.Test.Name;
Expand All @@ -192,7 +192,7 @@ public void OnLogMessageReceived_ExperimentalLogsEnabledWithAttachBreadcrumbsFal
public void OnLogMessageReceived_ExperimentalLogsEnabledWithAttachBreadcrumbsTrue_BreadcrumbsAdded(LogType unityLogType)
{
_fixture.SentryOptions.EnableLogs = true;
_fixture.SentryOptions.AttachBreadcrumbsToEvents = true;
_fixture.SentryOptions.AddBreadcrumbsWithStructuredLogs = true;
_fixture.SentryOptions.AddBreadcrumbsForLogType[unityLogType] = true;
var sut = _fixture.GetSut();
var message = TestContext.CurrentContext.Test.Name;
Expand Down
Loading