config/sentry.php
<?php
use Sentry\Event;
return [
'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),
'before_send' => function (Event $event): ?Event {
// literally anything
return $event;
},
];
php artisan config:cache

Yes, that is because you are using a closure in your configuration file which is not allowed :)
This is a Laravel limitation (and a good one because serializing closures is a hack).
You can get around this limitation by doing the following:
<?php
namespace App\Exceptions;
use Sentry\Event;
class Sentry
{
public static function before(Event $event): ?Event
{
// literally anything
return $event;
}
}
Which you can set in your configuration like:
<?php
return [
'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),
'before_send' => [App\Exceptions\Sentry::class, 'before'],
];
This works because we allow PHP callables to be passed for all callbacks.
Because I have not heard back I am going to assume my directions were sufficient and the problem was solved, closing this issue, feel free to reopen or open a new one if there are still unsolved issues.
Yes, that is because you are using a closure in your configuration file which is not allowed :)
This is a Laravel limitation (and a good one because serializing closures is a hack).
You can get around this limitation by doing the following:
<?php namespace App\Exceptions; use Sentry\Event; class Sentry { public static function before(Event $event): ?Event { // literally anything return $event; } }Which you can set in your configuration like:
<?php return [ 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), 'before_send' => [App\Exceptions\Sentry::class, 'before'], ];This works because we allow PHP callables to be passed for all callbacks.
doing the following on which file?
doing the following on which file?
config/sentry.php
It's not explicitly documented as the config options are passed through directly to Sentry. So when you read something like https://docs.sentry.io/platforms/php/#tagging-events , it's basically the content of config/sentry.php passed internally to this init.
doing the following on which file?
config/sentry.phpIt's not explicitly documented as the config options are passed through directly to Sentry. So when you read something like https://docs.sentry.io/platforms/php/#tagging-events , it's basically the content of
config/sentry.phppassed internally to this init.
i don't have that file in config folder
Seems to me you didn't follow the installation guide then, see e.g. https://sentry.io/for/laravel/
Especially the last step ("create the sentry configuration")
Most helpful comment
Yes, that is because you are using a closure in your configuration file which is not allowed :)
This is a Laravel limitation (and a good one because serializing closures is a hack).
You can get around this limitation by doing the following:
Which you can set in your configuration like:
This works because we allow PHP callables to be passed for all callbacks.