Issue with exceptPatterns on Craft 4 ?
Closed this issue · 3 comments
Description
Hi,
Since Craft 4 I'm seeing some warnings that are supposed to be ignored still reported in Sentry.
Example with the category craft\web\User::_validateUserAgentAndIp
, reported in Sentry :
category : craft\web\User::_validateUserAgentAndIp
level : warning
url : https://site.com/login
Here's my Sentry config, defined in config/app.php
:
'class' => SentryTarget::class,
'enabled' => App::env('CRAFT_ENVIRONMENT') == 'production',
'anonymous' => false,
'dsn' => App::env('SENTRY_DSN'),
'release' => App::env('SENTRY_RELEASE'),
'environment' => App::env('CRAFT_ENVIRONMENT'),
'levels' => ['error', 'warning'],
'options' => [],
'exceptCodes' => [400, 403, 404, 418, 503],
'exceptPatterns' => [
'craft\web\User::_validateUserAgentAndIp',
'yii\web\User::getIdentityAndDurationFromCookie',
'craft\elements\User::_validateUserAgent',
'craft\errors\VolumeObjectNotFoundException',
'craft\elements\Asset::_dimensions',
'craft\services\Users::isVerificationCodeValidForUser',
'yii\web\User::renewAuthStatus',
'craft\db\mysql\Schema::releaseSavepoint',
'aelvan\imager\services\ImagerService::removeTransformsForAsset',
'craft\services\AssetTransforms::deleteAllTransformData',
'craft\services\Assets::getThumbPath',
'craft\web\twig\Extension::svgFunction',
'Embed\Exceptions\InvalidUrlException',
'yii\web\User::getIdentityAndDurationFromCookie'
]
I have lots of websites on Craft 3 that do not report this warning.
Additional info
- Plugin version: 4.1.1
- Craft version: 4.4.1
- PHP version: 8.1
- Configuration method: Advanced
Hi @ryssbowh, the exceptPatterns
parameter only looks for patterns in the text of the exception message. If you want to completely ignore the class name, you will need to use the except
parameter.
https://github.com/diginov/craft-sentry-logger/blob/main/README.md#except
https://www.yiiframework.com/doc/api/2.0/yii-log-target#$except-detail
You'd think the name "exceptPatterns" would have led me to figure that one out by myself... :)
Thanks
Hi @ryssbowh, you have all the documentation at your disposal for you to read.
https://github.com/diginov/craft-sentry-logger/blob/main/README.md#exceptpatterns