Sentry-laravel: The option "user_context" does not exist.

Created on 6 Feb 2019  路  12Comments  路  Source: getsentry/sentry-laravel

I used "sentry/sentry-laravel": "^0.12.0@dev" earlier and it worked with user_context correctly. How to resolve this error for version 1.0-beta?

enhancement question

Most helpful comment

Alternatively you can remove the config cache file manually: bootstrap/cache/config.php.

All 12 comments

Look for user_context in the upgrade documentation of the sentry-php the Laravel integration uses.

I see the user context documentation is currently missing from the Laravel documentation so that will be added back later.

The gist is to do instead of $client->user_context(['email' => '[email protected]']); this:

use Sentry\Hub;
use Sentry\Scope;

Hub::getCurrent()->configureScope(function (Scope $scope): void {
    $scope->setUser(['email' => '[email protected]']);
});

Indeed. Would be great to update examples configs as well.

We never had ik documented in the example since there is no user context in a clean Laravel setup, but it is documented correctly now!

https://docs.sentry.io/platforms/php/laravel/#user-context

Ah, OK, these old examples are supposed to stick at the version < 1.
But they are partly been updated, that why it raises some confusions.

@LeoColomb good point, totally missed those :( Thanks for letting me know!

I updated those example to reflect the config option changes here: #197

For those who had cache config on remote server and are now trapped in a loop with that error, you must uninstall sentry/sentry-laravel by removing it from composer.json, deploy and do composer install, clear config, reinstall sentry, and deploy again.

Alternatively you can remove the config cache file manually: bootstrap/cache/config.php.

It's a real shame that this package stopped supporting sending user details out of the box. It feels incredibly lazy that I need to create a middleware to configure Sentry myself because the Laravel-specific Sentry bridge doesn't do it by itself.

Sorry you feel this way so strongly.

However, the option to add the user context is not gone but it鈥檚 called differently now.

You might have missed it in the new docs:

Starting with Laravel 5.3 we can automatically add the authenticated user id to the scope if send_default_pii option is set to true in your config/sentry.php.

So this option send_default_pii should be documented in the config/sentry.php

I think we shouldn't because then where do we stop with documenting options in there and syncing their defaults with the base package, there are quite a few and more may be added later at any time. Better to keep that in the documentation IMHO.

For reference, they are all documented here: https://docs.sentry.io/error-reporting/configuration/?platform=php

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vladislavtkachenko picture vladislavtkachenko  路  4Comments

acidjazz picture acidjazz  路  4Comments

errogaht picture errogaht  路  8Comments

andrey-helldar picture andrey-helldar  路  6Comments

andrey-helldar picture andrey-helldar  路  7Comments