In some cases the user may be logged out because we inject the UserContextInterface before Magento has had the chance to populate it.
Result
With this change we check wether the area code can be fetched, and if it is an area code where user context might be available.
And only then inject the userContext so. This should ensure user context is already compiled and added.
Summary
Fixes: https://github.com/justbetter/magento2-sentry/issues/79#issuecomment-2476730789
In some cases the user may be logged out because we inject the
UserContextInterface
before Magento has had the chance to populate it.Result
With this change we check wether the area code can be fetched, and if it is an area code where user context might be available. And only then inject the userContext so. This should ensure user context is already compiled and added.
Checklist
composer run codestyle
composer run phpstan