Skip to content

Commit 1e692f9

Browse files
authored
fix: Lifecycle breadcrumb format (#2407)
1 parent 17cf494 commit 1e692f9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Fixes
1212

13+
- Fixed the breadcrumb format for lifecycle events ([#2407](https://github.com/getsentry/sentry-unity/pull/2407))
1314
- When targeting iOS, the `WatchdogTerminationIntegration` now defaults to `false` as to not report false positives. Users can control this through the option `IosWatchdogTerminationIntegrationEnabled` ([#2403](https://github.com/getsentry/sentry-unity/pull/2403))
1415
- The SDK now correctly sets the currently active scene's name on the event ([#2400](https://github.com/getsentry/sentry-unity/pull/2400))
1516
- Fixed an issue where screenshot capture triggered on a burst job would crash the game. The SDK can now also capture screenshots on events that occur outside of the main thread ([#2392](https://github.com/getsentry/sentry-unity/pull/2392))

src/Sentry.Unity/Integrations/LifeCycleIntegration.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
using System;
2+
using System.Collections.Generic;
23
using Sentry.Extensibility;
34
using Sentry.Integrations;
45

56
namespace Sentry.Unity.Integrations;
67

78
internal class LifeCycleIntegration : ISdkIntegration
89
{
10+
private static readonly Dictionary<string, string> ForegroundData = new() { { "state", "foreground" } };
11+
private static readonly Dictionary<string, string> BackgroundData = new() { { "state", "background" } };
12+
913
private IHub? _hub;
1014
private SentryUnityOptions _options = null!; // Set during register
1115

@@ -36,19 +40,28 @@ public void Register(IHub hub, SentryOptions sentryOptions)
3640
return;
3741
}
3842

39-
hub.AddBreadcrumb(message: "App regained focus.", category: "app.lifecycle");
43+
hub.AddBreadcrumb(new Breadcrumb(
44+
type: "navigation",
45+
category: "app.lifecycle",
46+
data: ForegroundData,
47+
level: BreadcrumbLevel.Info));
4048

4149
_options.DiagnosticLogger?.LogDebug("Resuming session.");
4250
hub.ResumeSession();
4351
};
52+
4453
_sentryMonoBehaviour.ApplicationPausing += () =>
4554
{
4655
if (!hub.IsEnabled)
4756
{
4857
return;
4958
}
5059

51-
hub.AddBreadcrumb(message: "App lost focus.", category: "app.lifecycle");
60+
hub.AddBreadcrumb(new Breadcrumb(
61+
type: "navigation",
62+
category: "app.lifecycle",
63+
data: BackgroundData,
64+
level: BreadcrumbLevel.Info));
5265

5366
_options.DiagnosticLogger?.LogDebug("Pausing session.");
5467
hub.PauseSession();

0 commit comments

Comments
 (0)