pluswerk / sentry
+Pluswerk TYPO3 extension: Sentry Client
Installs: 15 402
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 2
Type:typo3-cms-extension
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- composer-runtime-api: ^2
- ext-fileinfo: *
- http-interop/http-factory-guzzle: ^1.0
- sentry/sentry: ^3.22.1
- typo3/cms-core: ^11.5 || ^12.4
- typo3/cms-frontend: ^11.5 || ^12.4
Requires (Dev)
- pluswerk/grumphp-config: ^7
- saschaegerer/phpstan-typo3: ^1.10.0
- ssch/typo3-rector: ^2.4.0
- symfony/http-client: ^5.4 || ^6
README
Pluswerk TYPO3 Sentry PHP Client
Features:
- has LogWriter that enables you to write any log entries into sentry
- Logs all exceptions caught by the TYPO3 error handling.
- Logs all exceptions that are caught by the TYPO3 ProductionExceptionHandler ContentObject.
- This handles the
Oops, an error occurred! code: 2023080912232477707e9b
errors in your site. - It displays the error message as normal + a link with only a after the code. So a normal user will not see the link.
- The link directly opens the sentry with the correct error.
- This handles the
Quickstart:
- Add environment variables:
SENTRY_DSN=https://dsn-to-your@sentry.io/instance
SENTRY_ORGANISATION=sentry
(optional) if the organisation of your sentry is different. is used in eg. the Oops, an error occurred! Code: 2023080912232477707e9bDISABLE_SENTRY
(optional) Disable Sentry by setting this to 1SENTRY_QUEUE
(optional) Enable queue system by setting this to 1SENTRY_ERRORS_TO_REPORT
(optional) The Errors to Report as number, e.g. 4096 for E_REVOERABLE_ERROR
- Add the following line to your
AdditionalConfiguration.php
(new \Pluswerk\Sentry\Bootstrap())->initializeHandler();
- If you enabled SENTRY_QUEUE
- Add
typo3 pluswerk:sentry:flush
to your scheduling service - Add environment before the command if you want to report errors while running the command
SENTRY_QUEUE=0 typo3 pluswerk:sentry:flush
- Add
Settings
The Extension comes with a couple of settings in the TYPO3-Backend:
force_disable_sentry
-> Forcefully override the ENV by disabling Sentry in backendenable_git_hash_releases
(default yes) -> Automatically track releases with the current git hash (only works if git is installed)
Configuring the scope
Sometimes it might be necessary to additionally configure the scope of a sentry event.
For this, the method \Pluswerk\Sentry\Sentry::withScope($exception, $scopeCallback)
comes in play.
The arguments are similar to https://docs.sentry.io/platforms/php/enriching-events/scopes/#local-scopes
.
The first argument requires the exception to be thrown and the second is a callback,
for where you can apply custom settings to the Sentry Scope.
There is no need to additionally write captureException
within that callback.
Example:
Sentry::getInstance()->withScope($exception, fn(Scope $scope) => $scope->setTag('oops_code', $oopsCode));
SentryLogger
You can write this in your additional.php if you want all warnings from the TYPO3 log to be logged in Sentry:
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'][LogLevel::WARNING] = [ SyslogWriter::class => [], SentryLogger::class => [], ];