Fix MAUI missing breadcrumbs for lifecycle and UI events #2170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm really not sure when this started happening, but I noticed that we are no longer getting any breadcrumbs for lifecycle and UI events in MAUI apps.
Running our MAUI sample shows only these:
The two breadcrumbs before the exception are from logging that the MAUI sample does, and are picked up by
Sentry.Extensions.Logging
. There's no indication of Application, Windows, or Button events as there used to be.The last time I worked on this part of the MAUI code was with #2001 / #2006. It's possible the issue was introduced then. If so, I'm surprised we didn't notice until now. It's also possible that something changed in MAUI between then and now.
On investigation, it seems that MAUI's
IPlatformApplication.Application
property is not set until after the event we use. See here in the MAUI source code.Thus, there are two options:
Application
property has been resolvedApplication
property ourselves through theServices
container.This PR takes the second approach, which appears to work:
I also went back and validated that this didn't regress #2001.