comsolit/sentry_client

TYPO3 extension for PHP error and exception logging with Sentry, https://sentry.io

Installs: 1 220

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 5

Forks: 35

Open Issues: 1

Type:typo3-cms-extension

8.0.0 2018-08-31 09:50 UTC

This package is auto-updated.

Last update: 2024-10-29 05:22:36 UTC


README

A TYPO3 extension for PHP exception logging with Sentry, https://www.sentry.io

Logs frontend PHP errors and exceptions to your Sentry instance. Note that logging backend issues is not yet supported by TYPO3 (it's on the todo list for v9, according to core developer Markus Klein).

Based on the official Sentry PHP client, sentry/sentry.

Installation

  1. Add something like this to your project's composer.json, and run composer install:
  "repositories": [
    {
      "type": "composer",
      "url": "https://packagist.org/"
    },
    {
      "url": "https://github.com/comsolit/sentry_client.git",
      "type": "git"
    }
  ],
  "require": {
    "comsolit/sentry_client": "dev-master"
  }
  1. Make sure your typo3conf/LocalConfiguration.php contains something like this in the SYS section:
    'SYS' => [
        // ...
        'devIPmask' => '',
        'displayErrors' => '0',
        'enable_errorDLOG' => '1',
        'enable_exceptionDLOG' => '1',
        'enableDeprecationLog' => 'devlog',
        'systemLog' => '',
        'systemLogLevel' => '0',
        'syslogErrorReporting' => E_ALL,
        'belogErrorReporting' => E_ALL,
        'exceptionalErrors' => E_RECOVERABLE_ERROR | E_USER_DEPRECATED,
        'errorHandlerErrors' => E_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED,
        'errorHandler' => 'SentryClient\\ErrorHandler',
        'debugExceptionHandler' => 'SentryClient\\DebugExceptionHandler',
        'productionExceptionHandler' => 'SentryClient\\ProductionExceptionHandler',
    ]

Alternatively, you can set those values via the Install Tool or in typo3conf/AdditionalConfiguration.php.

Configuration

Set the Sentry DSN (e.g. https://public_key:secret_key@your-sentry-server.com/project-id) in the Extension Manager.

This will be added in your typo3conf/LocalConfiguration.php file at:

'EXT' => [
    'extConf' => [
        'sentry_client' => ...

NOTE: For professional deployments you should consider using something like phpdotenv to manage your secrets instead of using the Extension Manager, and leave your LocalConfiguration under version control.

JavaScript Error Logging

For logging your JavaScript errors to Sentry see the JavaScript Sentry docs.

If you include your JavaScript sources via TypoScript it can be handy to avoid hard-coding and define a SENTRY_DSN_PUBLIC value in your system environment (e.g. via a .env file read by phpdotenv). You can read the value in TypoScript using the getenv command like this:

page.headerData {
  999 = COA
  999 {
    10 = TEXT
    10.value = <script src="https://cdn.ravenjs.com/3.16.0/raven.min.js" crossorigin="anonymous"></script>
    20 = TEXT
    20.value = <script>Raven.config('
    30 = TEXT
    30.data = getenv : SENTRY_DSN_PUBLIC
    30.stdWrap.wrap = |
    40 = TEXT
    40.value = ', {release: '
    50 = TEXT
    50.data = getenv : PROJECT_VERSION
    50.stdWrap.wrap = |
    60 = TEXT
    60.value = '}).install();</script>
  }
}

Development

Your contributions are welcome! Please fork the repo, make your changes, and open a pull request.