networkteam/sentry-client

Sentry Client for TYPO3

Installs: 79 431

Dependents: 0

Suggesters: 0

Security: 0

Stars: 21

Watchers: 9

Forks: 25

Open Issues: 6

Type:typo3-cms-extension

3.0.2 2020-04-02 19:02 UTC

README

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 enriched error messages with 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

The preferred way is with Composer:

$ composer require networkteam/sentry-client

The TER version includes some composer dependencies locally, which may lead to problems in the future (one package with multiple version in the project).

Configuration

// Extension Configuration
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sentry_client']['dsn'] = 'http://public_key@your-sentry-server.com/project-id';

// LocalConfiguration.php (New since 3.0!!!)
$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = 'Networkteam\SentryClient\ProductionExceptionHandler';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = 'Networkteam\SentryClient\DebugExceptionHandler';

Environment variables

The new Sentry SDK 2.x has some environment variables which can be used, for example in a .htaccess file:

SetEnv SENTRY_DSN http://public_key@your-sentry-server.com/project-id
SetEnv SENTRY_RELEASE 1.0.7
SetEnv SENTRY_ENVIRONMENT Staging

LogWriter

The extension comes with a LogWriter which is enabled by default for the error loglevel and forward messages to Sentry. You can disable (EM) or configure it for specific components:

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

Feature Toggles

  • Ignore PageNotFoundException and trigger 404 handling instead
  • Ignore database connection errors (they should better be handled by a monitoring system)
  • Report user information: Select one of none | userid | usernameandemail
  • Blacklist exception message regular expression
  • LogWriter Loglevel: If set, messages are reported which normally are just logged

How to test if the extension works?

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

This triggers an exception which will be reported.

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

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