Git Product home page Git Product logo

sentry_client's Introduction

Sentry Client for TYPO3

ci Latest release on GitHub Downloads per month

TYPO3 logs error messages and exceptions to logfiles and the backend log module. This extension sends them to Sentry, a SaaS/self-hosted application which aggregates them and informs you by mail. In Sentry you see a error messages with additional information like stacktrace, HTTP headers and submitted request/form data.

Technical decisions

Exceptions through database outages (imagine a mysql server restart) should not be reported, so the db connection is checked before. Exceptions may be excluded via regexp on their message (won't fix this error => exclude it). TYPO3 throws a lot of PHP Notices and they are not really interesting in production, they are excluded by default.

Installation

$ composer require networkteam/sentry-client

The TER version will not receive updates anymore. Feel free to send us a crate of beer and we will make a new TER release.

Configuration

File: system/settings.php or system/additional.php

Register the exception handlers.

$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = Networkteam\SentryClient\ProductionExceptionHandler::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = Networkteam\SentryClient\DebugExceptionHandler::class;

The DebugExceptionHandler is also used in production environment when SYS/displayErrors is enabled and your IP matches SYS/devIPmask.

Optional: Forward non-exceptional errors to Sentry, that normally are logged only. Consider using LogLevel::WARN

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::ERROR => [
        \Networkteam\SentryClient\SentryLogWriter::class => [],
    ],
];

Optional: Set sentry/sentry options (https://docs.sentry.io/platforms/php/configuration/options/)

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sentry_client']['options']['server_name'] = 'web3';

Environment variables

Since Sentry SDK 2.x there are environment variables which can be used, for example in a .htaccess file:

SetEnv SENTRY_DSN http://[email protected]/project-id
SetEnv SENTRY_RELEASE 1.0.7
SetEnv SENTRY_ENVIRONMENT Staging

Feature Toggles

  • Ignore database connection errors (they should better be handled by a monitoring system)
  • Report user information: Select one of none | userid
  • Ignore exception message regular expression
  • Ignore LogWriter Components

How to test if the extension works?

page = PAGE
page.20 = USER
page.20 {
  userFunc = Networkteam\SentryClient\Client->captureException
}

This triggers an error that will be reported.

Request ID

If the web server has set a request ID header X-Request-Id, this is transmitted as a tag to trace errors to logs.

Issue tracker

This extension is managed on GitHub. Feel free to get in touch at https://github.com/networkteam/sentry_client

Help

There is a Slack channel #ext-sentry_client

Changelog

5.1.0

  • Use sentry/sentry ^4.6

5.0.0

  • New option "disableDatabaseLogging": When enabled, exceptions are not written to database table sys_log
  • Introduce Sentry Integrations
  • Allow passing sentry/sentry options via EXTCONF
  • Ignore exceptions, that are ignore in TYPO3 core
  • Use sentry/sentry instead of sentry/sdk (Thanks to @derhansen)
  • !!! Option "logWriterLogLevel" removed. LogWriter needs to be configured in system/additional.php
  • !!! Option "messageBlacklistRegex" renamed to "ignoreMessageRegex"
  • !!! Option "logWriterComponentBlacklist" renamed to "logWriterComponentIgnorelist"
  • !!! The old option names still work
  • !!! Drop support for TYPO3 v10
  • !!! Drop support for non-composer usage

4.2.0

  • Add log message interpolation (Thanks to @sascha-egerer)
  • Add Fingerprint to log messages
  • Deprecated: Usage of DebugExceptionHandler

4.1.0

  • Client IP is anonymized with IpAnonymizationUtility::anonymizeIp(). Thanks to @extcode
  • Add X-Request-Id as tag. Thanks to @bergo
  • Small code optimizations. Thanks to @tlueder and @LeoniePhiline

4.0.0

  • Add stacktrace to LogWriter messages for message grouping in Sentry
  • Add LogWriter component ignorelist
  • Add v11.5 support
  • Drop v9.5 support

3.0..3.1

  • Add experimental LogWriter
  • Remove setting activatePageNotFoundHandling
  • Ignore PageNotFoundException by default
  • Support TYPO3 proxy setting
  • Use sentry/sdk:3.1

2.0..3.0

  • Use sentry/sdk:2.0
  • Remove setting productionOnly
  • Remove setting reportWithDevIP
  • Rename setting activatePageNotFoundHandlingActive to activatePageNotFoundHandling
  • Report E_ALL ^ E_NOTICE
  • Strip project root
  • Show event id in FE

sentry_client's People

Contributors

abeutel avatar achimfritz avatar bergo avatar bmack avatar brotkrueml avatar christophlehmann avatar cweiske avatar derhansen avatar extcode avatar ger4003 avatar jrenggli avatar konafets avatar leoniephiline avatar sascha-egerer avatar susannemoog avatar tlueder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry_client's Issues

Add the option to anonymize the IP address

We have customers who attach great importance to data protection and it is a problem if the IP address of the user is transmitted in full.

TYPO3 offers here a class that allows to mask the IP accordingly.

Temporary deactivation and maintenance mode

As a site administrator i like to have an option to deactivate sentry temporary. Sometimes you know things may fail and you won't get a mail storm.

  • Add toggle icon in the Top bar (beside Favorites/Cache menu) for admins.
  • Have a nice maintenance page which will be shown (In 9.5 as a site configuration option)

Use `sentry/sentry` instead of `sentry/sdk`

sentry/sdk bundles an own HTTP client (symfony/http-client), which however is superfluous, since TYPO3 bundles a HTTP client too (guzzle/guzzle).

I therefore suggest to use sentry/sentry, which uses php-http/discover to discover any HTTP clients used by depending packages. For TYPO3, the php-http/guzzle7-adapter will be added to composer.json by the plugin.

[FEATURE REQUEST] Support TYPO3 9

Hi we are currently working on switching to TYPO3 9 for new projects especially cause the new LTS version gets released tomorrow.
Would be nice to have this extension available :)

Uncaught Error: Typed static property

Hello

I've tried everything but still have problem with this extension under v12.

What else I can check?

My error

[Fri Dec 22 08:55:16.316584 2023] [php:error] [pid 16] [client 127.0.0.1:40404] PHP Fatal error:  Uncaught Error: Typed static property TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility::$packageManager must not be accessed before initialization in /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Utility/ExtensionManagementUtility.php:110\nStack trace:\n#0 /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php(2613): TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility::resolvePackagePath('EXT:core/Resour...')\n#1 /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Controller/ErrorPageController.php(46): TYPO3\\CMS\\Core\\Utility\\GeneralUtility::getFileAbsFileName('EXT:core/Resour...')\n#2 /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php(2986): TYPO3\\CMS\\Core\\Controller\\ErrorPageController->__construct()\n#3 /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Error/ProductionExceptionHandler.php(63): TYPO3\\CMS\\Core\\Utility\\GeneralUtility::makeInstance('TYPO3\\\\CMS\\\\Core\\\\...')\n#4 /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Error/AbstractExceptionHandler.php(72): TYPO3\\CMS\\Core\\Error\\ProductionExceptionHandler->echoExceptionWeb(Object(TypeError))\n#5 /home/hdai/d2v12/vendor/networkteam/sentry-client/Classes/ProductionExceptionHandler.php(29): TYPO3\\CMS\\Core\\Error\\AbstractExceptionHandler->handleException(Object(TypeError))\n#6 [internal function]: Networkteam\\SentryClient\\ProductionExceptionHandler->handleException(Object(TypeError))\n#7 {main}\n  thrown in /home/hdai/d2v12/vendor/typo3/cms-core/Classes/Utility/ExtensionManagementUtility.php on line 110

Typo3 v12

composer.json

		"networkteam/sentry-client": "^5.0",
		"php-http/guzzle7-adapter": "^1.0",

system/additional.php

$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sentry_client']['dsn'] = 'https://***@sentry/17';

if (TYPO3\CMS\Core\Core\Environment::getContext()->isProduction()) {
    // Register exception handler
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = Networkteam\SentryClient\ProductionExceptionHandler::class;
    // Forward log messages to Sentry
    $GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
        \TYPO3\CMS\Core\Log\LogLevel::ERROR => [
            \Networkteam\SentryClient\SentryLogWriter::class => [],
        ],
    ];
    // Set sentry/sentry options
    $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['sentry_client']['options']['server_name'] = 'node1';
}

Composer

Use composer and allow installing using composer

Missing initialization of SentryService in SentryLogWriter

The SentryLogWriter by now only works in combination with one of the ExceptionHandler-Classes.
The SentryService gets only initialized in the ExceptionHandler-Classes.
Using the Logging-Framework without an exception, the data will not be send to sentry, because to SentryService::isEnabled() check always returns false because of the missing SentryService::initialize() call.

Tested with
TYPO3 12.4
sentry_client: 5.0.1

Testing code does not work

the proposed testing code in readme does not work

page.20 = USER
page.20 {
    userFunc = Networkteam\SentryClient\Client->captureException
}

as it throws an exception:

TypeError
Networkteam\SentryClient\Client::captureException(): Argument #1 ($exception) must be of type Throwable, string given, called in /var/www/html/app/site/vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php on line 4752

a possible implementation to test could be

    public static function captureTestException(): ?EventId
    {
        $exception = new \Exception('Test exception');
        return captureException($exception);
    }

No applicationType in cli mode

In cli mode (e.g. running a Symfony command), there is a frontend request but it doesn't contain an attribute applicationType. Thus ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST']) throws an exception in Client.php (lines 92 and 128).

Class 'DebugExceptionHandler' not found

During deployments we had the following error:

Fatal error: Uncaught Error: Class 'Networkteam\SentryClient\DebugExceptionHandler' not found in /var/www/site/htdocs/typo3_src/typo3/sysext/core/Classes/Utility/GeneralUtility.php:3443
--
Stack trace:
#0 /var/www/site/htdocs/typo3_src/typo3/sysext/core/Classes/Core/Bootstrap.php(430): TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance()
#1 /var/www/site/htdocs/typo3_src/typo3/sysext/core/Classes/Core/Bootstrap.php(100): TYPO3\CMS\Core\Core\Bootstrap::initializeErrorHandling()
#2 /var/www/site/htdocs/typo3_src/typo3/sysext/core/bin/typo3(23): TYPO3\CMS\Core\Core\Bootstrap::init()
#3 /var/www/site/htdocs/typo3_src/typo3/sysext/core/bin/typo3(24): {closure}()
#4 {main}
thrown in /var/www/site/htdocs/typo3_src/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 3443

We did have the autoloader pre-generated, and still it failed.

The source of the problem was that we used TYPO3_CONTEXT=Testing for our test environment, which is wrong - Testing may only be used for unit tests. After changing the application context, the error was gone.
(Testing uses its own autoloader directory "typo3conf/autoloader-testing", not the standard typo3conf/autoloader)


I created this issue only to close it immediately, for others to find when searching for that error message.

Deprecation of DebugExceptionHandler - alternatives?

The README's changelog says:

4.2.0
Deprecated: Usage of DebugExceptionHandler

(this came with 2e34725, but no further explanation)

In #76 you remove the debugexceptionhandler class, but the commit also does not tell what the alternative is.

How can we get exceptions into sentry on testing and staging systems, while at the same time see the full exception trace when an error occurs?

Missing support for Sentry Web Vitals

Hi folks,

in order to allow profiling, the configuration option traces_sample_rate needs to be set which is currently not possible as the set of options is controlled by this package. See https://docs.sentry.io/platforms/php/performance/ for reference.

It would be nice if the package supported either adding arbitrary configuration or the full set of options sentry offers. Especially this option should be easy to pass through via EXTCONF.

Greetings,
Alex

Allow setting additional Sentry configuration options

Currently, this extension only allows configuring a handful of the available Sentry options.
They are dsn, release, environment and in_app_include. Other options such as error_types, http_proxy, attach_stacktrace, and before_send are set automatically.
However, there are a lot more configuration options available (see https://docs.sentry.io/platforms/php/configuration/options/), and I would like to make use of them, but I don't see any way how I can modify the $options array myself (https://github.com/networkteam/sentry_client/blob/master/Classes/Client.php).

Specific use case: I am not seeing the body of a POST request in the Sentry backend when additional files were uploaded with the request.
This is because the default configuration value for max_request_body_size is medium (10 KB), and although the uploaded files are not passed to Sentry, the SDK is calculating the body size by using the PSR-17 request's Content-Length field (see https://github.com/getsentry/sentry-php/blob/1ad6831202b6d739bf820a6bea6735d32af610b2/src/Integration/RequestIntegration.php#L210).

There are two possible ways to solve this specific problem:
You can either set the max_request_body_size value to always, or register a custom RequestFetcherInterface that modifies the value of the Content-Length field to match the "actual" body size before passing the request to the Sentry SDK.

Unfortunately, this extension doesn't allow configurating either of these options.

I think the best way to do this would be to allow setting additional options in the extension configuration, and then pass them to the Sentry SDK.
My suggestion would be $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sentry_client']['additionalConfiguration'] = [...] and merging this into the existing $options array.
I was thinking about using a PSR-14 event for this, but since the code is called when an exception is thrown and TYPO3 is about to shut down, it might not be a good idea.

I could create a pull request for this myself, but wanted to ask for your opinion on this first.

"messageBlacklistRegex" Setting array with multiple Expression instead of one string

Hello,

I have a question about the settings "messageBlacklistRegex". I want to add multiple regex expressions to be ignored, but only have one string to put it in. My question is: How do you manage multiple exceptions to be excluded? Do you write them all in one expression with the Pipe ( | ) Operator?

My Suggestion would be that the "messageBlacklistRegex" gets from string to array and that you can add every statement standalone.

What do you think about it?
If it's needed, I would build this and pr you.

Best Regards
Fabio

[Question] Typo3 Repo still 1.2.0

Hi networkteam,
on the typo3 repository the version is still 1.2.0 but when downloading i get the latest version of github 1.4.0 .
Could you tell which version i can use for now?

"Uncaught" TYPO3 errors

Hey, in TYPO3 i get errors like this:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Call to a member function getRecurrence() on null | Error thrown in file /var/www/typo3/www.mysite.si/typo3conf/ext/dated_news/Classes/Controller/NewsController.php in line 624. Requested URL: https://www.mysite.si/subpage1/subpage2...../

But sentry dont recognize them. Is there a problem in my configuration?

Call to undefined method TypoScriptFrontendController::pageNotFoundAndExit()

When throwing a TYPO3\CMS\Core\Error\Http\PageNotFoundException inside an extension, sentry_client wants to call the TSFE 404 page:

$GLOBALS['TSFE']->pageNotFoundAndExit($reason);

This method does not exist anymore in TYPO3v10: https://docs.typo3.org/c/typo3/cms-core/10.4/en-us/Changelog/9.2/Deprecation-83883-PageNotFoundAndErrorHandlingInFrontend.html


This happens with sentry_client 3.0.2 on TYPO3 v10.4.14

Error message:

Call to undefined method TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::pageNotFoundAndExit()
in /var/www/site/htdocs/typo3conf/ext/sentry_client/Classes/Content/ProductionExceptionHandler.php line 63

Best way to disable on local development systems?

We use sentry_client to capture errors in our TYPO3 installations on testing, staging and production environments.
On local development environments we disable sentry_client, because those errors are handled by the developer instantly.

We disable sentry_client by adding some code to AdditionalConfiguration.php:

$env = (string) \TYPO3\CMS\Core\Core\Environment::getContext();
if ($env === 'Development/Local') {
    $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sentry_client']['dsn'] = '';
}

This works but has one problem: When someone installs an extension or modifies extension configuration in the TYPO3 backend, the empty DSN is written into LocalConfiguration.php. When committing changes, people need to take care to not commit that line.

Is there a better way to disable sentry_client locally?

Exception logged when page is disabled: The requested page does not exist!

On TYPO3 v10, sentry_client logs an exception to sentry when a normal user (not logged in) tries to access a hidden page:

The requested page does not exist!

component: TYPO3.CMS.Frontend.Controller.TypoScriptFrontendController

The reason is that TypoScriptFrontendController logs an error before calling the page not found handler - see https://git.typo3.org/Packages/TYPO3.CMS.git/blob/9f8b73eb73f0f9834979641c02708dc168e36eda:/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php#l1386 (typo3 v10.4.14)

We cannot configure sentry_client to ignore this message because it's a log message and not an exception message.


This happens with sentry_client v3.0.2 and TYPO3 v10.4.14.

Implement improved ignore list

Goals:

  • Deprecate "blacklist" because of inappropriate naming (but still accept the old configuration option to keep it compatible)
  • Use "ignorelist" as the new name (configuration options and classes)
  • Extend exception ignore lists based on:
    • Message regexp
    • Class regexp -> provide examples due to escaping / backslashes
    • Exception code
  • Document example to readme

This way we could configure a common list of "client" exceptions that cause too much noise in Sentry and are due to e.g. bad route parameters, property mapping or form validation.

Earlier instantiation

Sentry has an Integration for catching Errors that occur when reaching memory_limit. Currently this is not active. The client needs to be setup earlier.

Consider adding a workaround for GitLab's sentry-payload error collector

See https://gitlab.com/gitlab-org/gitlab/-/issues/340178#note_845578316

GitLab is able to collect sentry payload, but fails if $_SERVER['PATH_INFO'] is an empty string.

The debug and production error handlers could set (and optionally reset afterwards) the following:

if ($_SERVER['PATH_INFO'] === '') {
    $_SERVER['PATH_INFO'] = null;
}

This fixes an Validation failed: Actor can't be blank response caused by an empty "transaction" key in the sentry JSON payload.

Duplicate sentry tickets when using SentryLogWriter + productionExceptionHandler

When following the README and configuring the productionExceptionHandler as well as the log writerConfiguration, exceptions are reported twice to Sentry.

One is reported by the as "level: error"

TYPO3\CMS\Core\Error\Exception
PHP Warning: Undefined array key "category" in /var/www/typo3/...php line 71

stack trace:

  1. TYPO3\CMS\Core\Error\ErrorHandler::handleError line 138
  2. Sentry\ErrorHandler::handleError line 342
  3. MyClass

the other one is "level: warning"

ErrorException
Warning: Undefined array key "category"

stack trace:

  1. MyClass

The duplicate reports go away when I disable the log writer.

Now my questions:

  • Is the log writer enough and the exception handler is not needed at all?
  • If both should be used, how can I get rid of the duplicates?

This happens with TYPO3 12.4.13 and sentry_client 5.0.2.

My config/system/additional.php contains:

// Register exception handler                                    
$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler']
    = Networkteam\SentryClient\ProductionExceptionHandler::class;
// Forward log messages to Sentry                                
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::ERROR => [
        \Networkteam\SentryClient\SentryLogWriter::class => [],
    ],
];

Uncaught error usage of PackageManager in TYPO3 12

URL while it occured: https://customer.dev.foo/typo3/ajax/icons"

Error: Uncaught Error: Typed static property TYPO3\CMS\Core\Utility\ExtensionManagementUtility::$packageManager must not be accessed before initialization in /usr/www/users/customerdev/app/releases/20230913112216/vendor/typo3/cms-core/Classes/Utility/ExtensionManagementUtility.php:110
Stack trace:
#0 /usr/www/users/customerdev/app/releases/20230913112216/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php(2596): TYPO3\CMS\Core\Utility\ExtensionManagementUtility::resolvePackagePath()
#1 /usr/www/users/customerdev/app/releases/20230913112216/vendor/typo3/cms-core/Classes/Controller/ErrorPageController.php(46): TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName()
#2 /usr/www/users/customerdev/app/releases/20230913112216/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php(2969): TYPO3\CMS\Core\Controller\ErrorPageController->__construct()
#3 /usr/www/users/customerdev/app/releases/20230913112216/vendor/typo3/cms-core/Classes/Error/ProductionExceptionHandler.php(64): TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance()
#4 /usr/www/users/customerdev/app/releases/20230913112216/vendor/typo3/cms-core/Classes/Error/AbstractExceptionHandler.php(71): TYPO3\CMS\Core\Error\ProductionExceptionHandler->echoExceptionWeb()
#5 /usr/www/users/customerdev/app/releases/20230913112216/vendor/networkteam/sentry-client/Classes/ProductionExceptionHandler.php(22): TYPO3\CMS\Core\Error\AbstractExceptionHandler->handleException()
#6 [internal function]: Networkteam\SentryClient\ProductionExceptionHandler->handleException()
#7 {main}
  thrown

Set sentry project environment by default

First of all, thanks for your work and your extension! :-)

Since sentry provides environments for all projects, I think, it would be great to automatically use the TYPO3 application context name as environment name in sentry. Or are you leaving the environment empty intentionally and it is only me, setting the environment?

If you confirm, it would be a good idea, to set sentrys environment to TYPO3's application context name, I could offer a tiny merge request.

Make configurable on TYPO3 context

It seems it's not possible to set the logging and debug handling based on context?

When I put in AdditionalConfiguration.php for the isDevelopment context an override like

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [ \TYPO3\CMS\Core\Log\LogLevel::ERROR => [ \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [], ], ];

This just gets ignored and still everything is send to Sentry. Easy fix, make an option to set it globally (like now in ext_localconf.php) or set it manually yourself.

Client::captureException(new \Exception($exceptionMessage)); should then still work but send stuf to TYPO3 log / debughandler

Support JavaScript error reporting

Sentry can also be used to report error on web pages using JavaScript.

This can normally be done by adding a HTML snippet or by bundling the JavaScript-file with the JavaScript sources. In both cases, the sentry configuration can be provided by adding window.SENTRY_... variables.

Since these information are available already, I think it is a good idea to extend this extension to output the values to the frontend. The frontend part will be active only, if the TypoScript template is included. Therefore this feature will become "optional" to use.

The acceptance criteria for including the JavaScript SDK in this extension are the following:

  1. The JavaScript will be included and configured if the TypoScript setup of this extension is included in the site package’s template.
  2. The Sentry JavaScript SDK is loaded either from:
    2.a. CDN by Sentry
    2.b. a copy in this Extension
    2.b. disabled, because it is bundled with the JavaScript from the project.
  3. Sentry is initialized either:
    3.a. automatically, because the extension adds the Sentry.init() call
    3.b. by the projects JavaScript (no Sentry.init() is added)

Do you think that it makes sense to add this feature to this extension? In that case I can check if I can work on a Merge Request.

Re-add support for PHP 7.4 in sentry-client 5

Hey @christophlehmann ,

just wanted to set up this extension in v11 project (which is PHP 7.4), in order to track existing issues with PHP before we upgrade to PHP 8 (and then to TYPO3 v12).

Seems like there are some problems with sentry/sdk and the combination with the http client implemented (we have heavy proxy settings going), as torben suggested last week to use sentry/sentry instead.

Error message is as follows:

Fatal error: Uncaught Symfony\Component\OptionsResolver\Exception\InvalidOptionsException: The option "http_proxy" with value array is expected to be of type "null" or "string", but is of type "array". in vendor/symfony/options-resolver/OptionsResolver.php:1060 Stack trace: #0 vendor/symfony/options-resolver/OptionsResolver.php(924): Symfony\Component\OptionsResolver\OptionsResolver->offsetGet('http_proxy') #1 vendor/sentry/sentry/src/Options.php(58): Symfony\Component\OptionsResolver\OptionsResolver->resolve(Array) #2 vendor/sentry/sentry/src/ClientBuilder.php(78): Sentry\Options->__construct(Array) #3 vendor/sentry/sentry/src/functions.php(20): Sentry\ClientBuilder::create(Array) #4  in vendor/symfony/options-resolver/OptionsResolver.php on line 1060

However, in order to get this "fixed", I would need to update to sentry_client 5, which supports TYPO3 v11 and v12, but only with PHP 8. From the dependencies, I do think it's possible to lift the extension v5 to also support PHP 7.4 AND PHP 8. What do you think? Would that be possible?

Mute exceptions by default

  • Unsupported HTTP method "UKKC". (TYPO3\CMS\Core\Http\Request::validateMethod)
  • The given string was not appended with a valid HMAC. (HashService::validateAndStripHmac), already 404 in 11.5?
  • The HMAC of the form could not be validated. (TYPO3\CMS\Core\Error\Http\BadRequestException)

Ignore ImmediateResponseException

The old way of sending a 404 page from an extbase extension does not work anymore with TYPO3 v10:

$GLOBALS['TSFE']->pageNotFoundAndExit('Record not found');

Instead, the way used by news and other extensions is to generate a 404 response and throw an TYPO3\CMS\Core\Http\ImmediateResponseException:

$response = GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
    $GLOBALS['TYPO3_REQUEST'],
    $message
);
throw new ImmediateResponseException($response, 1590468229);

Unfortunately, sentry_client catches and logs this exception.
And since that Exception has no string message, it cannot be excluded via the messageBlacklistRegex setting.

sentry_client should skip such exceptions.


This happens with sentry_client v3.0.2 and TYPO3 v10.4.14.

PHP Warning: Undefined array key "X-REQUEST-ID" // PHP 8.0 + TYPO3 11

Hello,

i coudn´t find any PHP recommendation so i want to ask if the extension is compatible with PHP 8.0 in combination with TYPO3 11.
In my case if get the followed exception:

Fatal error: Uncaught TYPO3\CMS\Core\Error\Exception: PHP Warning: Undefined array key "X-REQUEST-ID" in /var/www/html/public/typo3conf/ext/sentry_client/Classes/Client.php line 129 in /var/www/html/public/typo3/sysext/core/Classes/Error/ErrorHandler.php:137 Stack trace: #0 /var/www/html/vendor/sentry/sentry/src/ErrorHandler.php(305): TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'Undefined array...', '/var/www/html/p...', 129, Array) #1 /var/www/html/public/typo3conf/ext/sentry_client/Classes/Client.php(129): Sentry\ErrorHandler->handleError(2, 'Undefined array...', '/var/www/html/p...', 129) #2 /var/www/html/vendor/sentry/sentry/src/State/Hub.php(104): Networkteam\SentryClient\Client::Networkteam\SentryClient\{closure}(Object(Sentry\State\Scope)) #3 /var/www/html/vendor/sentry/sentry/src/functions.php(87): Sentry\State\Hub->configureScope(Object(Closure)) #4 /var/www/html/public/typo3conf/ext/sentry_client/Classes/Client.php(137): Sentry\configureScope(Object(Closure)) #5 /var/www/html/public/typo3conf/ext/sentry_client/Classes/Client.php(62): Networkteam\SentryClient\Client::setTagsContext() #6 /var/www/html/public/typo3conf/ext/sentry_client/Classes/Client.php(73): Networkteam\SentryClient\Client::init() #7 /var/www/html/public/typo3conf/ext/sentry_client/Classes/DebugExceptionHandler.php(13): Networkteam\SentryClient\Client::captureException(Object(TypeError)) #8 [internal function]: Networkteam\SentryClient\DebugExceptionHandler->handleException(Object(TypeError)) #9 {main} thrown in /var/www/html/public/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 137

I tried to debug the place with something like this:

protected static function setTagsContext(): void

{
    configureScope(
        function (Scope $scope): void {

            if (isset($GLOBALS['TYPO3_REQUEST']) && class_exists(ApplicationType::class)) {
                $mode = ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend() ? 'FE' : 'BE';
            } elseif (defined('TYPO3_MODE')) {
                // deprecated in TYPO3 v11
                $mode = TYPO3_MODE;
            }
            $requestId = '';

            if (isset($_SERVER['X-REQUEST-ID'])) {
                $requestId = $_SERVER['X-REQUEST-ID'];
            }

            if (isset($_SERVER['HTTP_X_REQUEST_ID'])) {
                $requestId = $_SERVER['HTTP_X_REQUEST_ID'];
            }

            $scope->setTags(
                array_merge(
                    ['typo3_version' => GeneralUtility::makeInstance(Typo3Version::class)->getVersion()],
                    ($mode ? ['typo3_mode' => $mode] : []),
                    ($requestId ? ['request_id' => $requestId] : [])
                )
            );
        }
    );
}

but then i got new errors in "Networkteam\SentryClient\Client::captureException"

(1/1) TypeError Networkteam\SentryClient\Client::captureException(): Argument #1 ($exception) must be of type Throwable, string given, called in /var/www/html/public/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php on line 5381

at Networkteam\SentryClient\Client::captureException('', array('userFunc' => 'Networkteam\\SentryClient\\Client->captureException'), object(TYPO3\CMS\Core\Http\ServerRequest))

So i just want to ask if its compatible or if i got any errors in my configuration. The system i use was on TYPO9 and PHP 7.2 and got updated to TYPO 11 with PHP 8. In the old version the sentry integration worked perfectly.

The error can be reproduced with the throw exception TYPOSCRIPT config from your read.me.

If this wasn´t intended to work with PHP 8.0 i can try to fix the issues by myself and create a pull request if i get it done.

Best regards
Fabio

Edit:
used Version -> networkteam/sentry-client 4.1.0

Exception if extension not fully configured

If extension is just installed but no settings set, the following exception is thrown

Networkteam\SentryClient\Service\ConfigurationService::getReportUserInformation(): Return value must be of type string, null returned

reason is

public static function getReportUserInformation(): string
    {
        return self::getExtensionConfiguration(self::REPORT_USER_INFORMATION);
    }

suggestion: add additional ?? ''

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.