Closed dustinwalker closed 4 years ago
@dustinwalker, thanks for the issue! To be clear are you seeing a similar error caused by the sentry plugin, or are you seeing the error caused by the link field plugin? If you could provide a stacktrace it would help a lot.
Attached is the stacktrace. The error is thrown with the Link field plugin but my understanding is that it is caused because this plugin assumes the app is fully bootstrapped and should instead fire on the EVENT_AFTER_LOAD_PLUGINS : https://github.com/craftcms/cms/issues/4944#issuecomment-532258934
You should be able to replicate it locally by having the sentry plugin installed then installing: "sebastianlenz/linkfield": "^2.0.0-beta.10",
As soon as I'm in an environment that sentry is reporting, the admin throws the error below.
Hope that helps.
Stack trace:
@roelvanhintum I had a similar problem with the 2-factor authentication plugin.
https://github.com/ethercreative/craft-twofactorauthentication/blob/master/src/Plugin.php#L51
Adding Event::on(Plugins::class, Plugins::EVENT_AFTER_LOAD_PLUGINS, function () { ... }
around the plugin initialisation seems to fix the issue 👍🏻
I just tried it locally and it resolves the issue with this plugin, too.
Just pushed to master. @dustinwalker and @jamesedmonston does this work for you? I'll wait with the release because it's friday. ;) @jamesedmonston same goes for the 2fa plugin.
Because sentry needs to load as soon as possible, i've only moved the part where data from the user identity is loaded.
@roelvanhintum Thanks for looking into this quickly. Makes sense about only moving the required bit into the event!
@roelvanhintum Thanks for the update! I tested it quickly and got the following error. That may be something on my end. I can test more throughly, but thought I'd share now in case it's something that makes sense to you.
Undefined variable: app
$options['default_integrations'] = false;
}
Sentry\init($options);
/**
* Setup user
*/
Event::on(Plugins::class, Plugins::EVENT_AFTER_LOAD_PLUGINS, function () {
$user = $app->getUser()->getIdentity();
Sentry\configureScope(function (Scope $scope) use ($settings, $user) {
if ($user && !$settings->anonymous) {
$scope->setUser([
'ID' => $user->id,
'Username' => $user->username,
'Email' => $user->email,
'Admin' => $user->admin ? 'Yes' : 'No',
]);
When Sentry is enabled, I'm running across this issue: https://github.com/sebastian-lenz/craft-linkfield/issues/79
It seems to stem from a change in Craft 3.3+ but I'm linking references that seem to better understand the core issue:
I'm running:
Let me know if you need any more info. Thanks! Dustin