Skip to content

fix: Updated breadcrumb type for scene changes #2028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/macOS/Sentry/Sentry.dylib.dSYM"));

if (isMono)
{
{
addFilesMatching(buildOutputDir, new[] { "*.pdb" });

// Unity stores the .pdb files in './Library/ScriptAssemblies/' and starting with 2020 in
Expand Down
9 changes: 6 additions & 3 deletions src/Sentry.Unity/Integrations/SceneManagerIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ void OnSceneManagerOnSceneLoaded(SceneAdapter scene, LoadSceneMode mode)

hub.AddBreadcrumb(
message: $"Scene '{scene.Name}' was loaded",
category: "scene.loaded");
category: "scene.loaded",
type: "navigation");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigation breadcrumbs should also have data. From the develop docs:

navigation
A navigation event can be a URL change in a web application, or a UI transition in a mobile or desktop application, etc.
Internally we display breadcrumbs of type default that contain category navigation as a breadcrumb of type navigation.

Its data property has the following sub-properties:

from (Required)

A string representing the original application state / location.

to (Required)

A string representing the new application state / location.

{
  "type": "navigation",
  "category": "navigation",
  "timestamp": "2016-04-20T20:55:53.845Z",
  "data": {
    "from": "/login",
    "to": "/dashboard"
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking out loud here: You can load scenes additionally, how'd that work with the from->to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be current vs previous ? it can be anything that makes sense here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then, I guess it's not a navigation event

Copy link
Contributor Author

@bitsandfoxes bitsandfoxes Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd actually make sense. As in: Which scene cause which other scene to load. That'd be actually super useful in specifically that case. How else would you know where this scene is coming from?

Copy link
Contributor Author

@bitsandfoxes bitsandfoxes Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - doesn't work. The fromScene in the ActiveSceneChanged call is always null. In all Unity versions. So all the change to type really does is change the icon.

}

void SceneManagerOnSceneUnloaded(SceneAdapter scene)
Expand All @@ -42,7 +43,8 @@ void SceneManagerOnSceneUnloaded(SceneAdapter scene)

hub.AddBreadcrumb(
message: $"Scene '{scene.Name}' was unloaded",
category: "scene.unloaded");
category: "scene.unloaded",
type: "navigation");
}

void SceneManagerOnActiveSceneChanged(SceneAdapter fromScene, SceneAdapter toScene)
Expand All @@ -57,7 +59,8 @@ void SceneManagerOnActiveSceneChanged(SceneAdapter fromScene, SceneAdapter toSce
message: fromScene.Name == null
? $"Changed active scene to '{toScene.Name}'"
: $"Changed active scene '{fromScene.Name}' to '{toScene.Name}'",
category: "scene.changed");
category: "scene.changed",
type: "navigation");
}
}
}
3 changes: 3 additions & 0 deletions test/Sentry.Unity.Tests/SceneManagerIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void SceneLoaded_EnabledHub_CrumbAdded()

Assert.AreEqual($"Scene '{sceneName}' was loaded", actualCrumb.Message);
Assert.AreEqual("scene.loaded", actualCrumb.Category);
Assert.AreEqual("navigation", actualCrumb.Type);
}

[Test]
Expand Down Expand Up @@ -72,6 +73,7 @@ public void SceneUnloaded_EnabledHub_CrumbAdded()

Assert.AreEqual($"Scene '{sceneName}' was unloaded", actualCrumb.Message);
Assert.AreEqual("scene.unloaded", actualCrumb.Category);
Assert.AreEqual("navigation", actualCrumb.Type);
}

[Test]
Expand Down Expand Up @@ -106,6 +108,7 @@ public void ActiveSceneChanged_EnabledHub_CrumbAdded()

Assert.AreEqual($"Changed active scene '{expectedFromScene.Name}' to '{expectedToScene.Name}'", actualCrumb.Message);
Assert.AreEqual("scene.changed", actualCrumb.Category);
Assert.AreEqual("navigation", actualCrumb.Type);
Assert.Null(actualCrumb.Data);
}

Expand Down
Loading