Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Classes/ClientProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Iresults\SentryClient;
namespace SentryClient;

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -94,6 +94,7 @@ private static function createClient()
$client = new \Raven_Client(static::getDsn(), self::getClientOptions());
$client->user_context(static::getUserContext());
$client->tags_context(static::getTagsContext());
$client->setRelease(getenv('APP_VERSION'));

return $client;
} else {
Expand Down
12 changes: 2 additions & 10 deletions Classes/DebugExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: cod
* Date: 16.12.16
* Time: 14:15
*/

namespace Iresults\SentryClient;

namespace SentryClient;

class DebugExceptionHandler extends \TYPO3\CMS\Core\Error\DebugExceptionHandler
{
/**
* Displays the given exception
*
* @param \Exception|\Throwable $exception The exception(PHP 5.x) or throwable(PHP >= 7.0) object.
* @TODO #72293 This will change to \Throwable only if we are >= PHP7.0 only
*
* @throws \Exception
*/
public function handleException($exception)
public function handleException(\Throwable $exception)
{
ClientProvider::captureException($exception);

Expand Down
2 changes: 1 addition & 1 deletion Classes/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Time: 11:43
*/

namespace Iresults\SentryClient;
namespace SentryClient;


class ErrorHandler extends \TYPO3\CMS\Core\Error\ErrorHandler
Expand Down
18 changes: 3 additions & 15 deletions Classes/ProductionExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
<?php
/**
* Created by PhpStorm.
* User: cod
* Date: 16.12.16
* Time: 14:15
*/

namespace Iresults\SentryClient;

namespace SentryClient;

class ProductionExceptionHandler extends \TYPO3\CMS\Core\Error\ProductionExceptionHandler
{
/**
* Displays the given exception
*
* @param \Exception|\Throwable $exception The exception(PHP 5.x) or throwable(PHP >= 7.0) object.
* @TODO #72293 This will change to \Throwable only if we are >= PHP7.0 only
*
* @throws \Exception
* @param \Exception|\Throwable $exception
*/
public function handleException($exception)
public function handleException(\Throwable $exception)
{
ClientProvider::captureException($exception);

Expand Down
3 changes: 3 additions & 0 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Allow Sentry to log exceptions in frontend when rendering content.
# See: https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#contentobjectexceptionhandler
config.contentObjectExceptionHandler = 0
118 changes: 100 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,120 @@
Sentry Client for TYPO3
=======================

This is a TYPO3 Extension for exception logging with sentry, see http://www.getsentry.com
A TYPO3 extension for PHP exception logging with Sentry, https://www.sentry.io

It's based on https://github.com/getsentry/sentry-php
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`](https://packagist.org/packages/sentry/sentry).

Installation
------------

1. Clone the repository
```bash
git clone https://github.com/iresults/sentry_client.git
```

2. Install the Sentry Library (e.g. with [CunddComposer](https://github.com/cundd/CunddComposer))
1. Add something like this to your project's `composer.json`, and run
`composer install`:

3. Register the handlers in the `Install Tool` or `typo3conf/AdditionalConfiguration.php`
```php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = 'Iresults\\SentryClient\\DebugExceptionHandler';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = 'Iresults\\SentryClient\\ProductionExceptionHandler';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] = 'Iresults\\SentryClient\\ErrorHandler';
```
``` json
"repositories": [
{
"type": "composer",
"url": "https://packagist.org/"
},
{
"url": "https://github.com/comsolit/sentry_client.git",
"type": "git"
}
],
"require": {
"comsolit/sentry_client": "dev-master"
}
```

2. Make sure your `typo3conf/LocalConfiguration.php` contains something like
this in the `SYS` section:

``` php
'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](
https://github.com/comsolit/sentry_client/blob/master/ext_localconf.php#L6-L19)
via the `Install Tool` or in `typo3conf/AdditionalConfiguration.php`.

Configuration
-------------

Set the dsn (e.g. `http://public_key:secret_key@your-sentry-server.com/project-id`) in the `Extension Manager`.
Set the [Sentry DSN](https://docs.sentry.io/quickstart/#about-the-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:

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

NOTE: For professional deployments you should consider using something like
[phpdotenv](https://packagist.org/packages/vlucas/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](
https://docs.sentry.io/clients/javascript/).

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](https://packagist.org/packages/vlucas/phpdotenv)).
You can read the value in TypoScript using the [`getenv` command](
https://docs.typo3.org/typo3cms/TyposcriptReference/DataTypes/Gettext/Index.html#getenv)
like this:

``` typo3_typoscript
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
-----------

Development of this fork happens on https://github.com/iresults/sentry_client

The original version can be found on https://github.com/networkteam/sentry_client
Your contributions are welcome! Please fork the repo, make your changes, and
[open a pull request](https://github.com/comsolit/sentry_client/pulls).
16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "lemming/sentry_client",
"description": "TYPO3 Extension for exception logging with sentry, see http://www.getsentry.com",
"name": "comsolit/sentry_client",
"description": "TYPO3 extension for PHP error and exception logging with Sentry, https://sentry.io",
"type": "typo3-cms-extension",
"version": "8.0.0",
"require": {
"typo3/cms-core": ">=6.2.0,<8.9.99"
"typo3/cms-core": ">=6.2.0,<8.9.99",
"sentry/sentry": "^1.7"
},
"license": [
"GPL-2.0+"
"GPL-3.0+"
],
"authors": [
{
Expand All @@ -16,6 +18,10 @@
{
"name": "Daniel Corn",
"email": "daniel@iresults.li"
},
{
"name": "Peter Bittner",
"email": "bittner@comsolit.com"
}
],
"replace": {
Expand All @@ -24,7 +30,7 @@
},
"autoload": {
"psr-4": {
"Iresults\\SentryClient\\": "Classes"
"SentryClient\\": "Classes"
}
}
}
30 changes: 0 additions & 30 deletions cundd_composer.json

This file was deleted.

30 changes: 12 additions & 18 deletions ext_emconf.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<?php

$EM_CONF[$_EXTKEY] = array (
$EM_CONF[$_EXTKEY] = [
'title' => 'Sentry Client',
'description' => 'Sentry Client for TYPO3 - https://www.getsentry.com/',
'description' => 'TYPO3 extension for PHP error and exception logging with Sentry, https://sentry.io',
'category' => 'services',
'version' => '1.1.0',
'state' => 'beta',
'version' => '8.0.0',
'state' => 'stable',
'uploadfolder' => false,
'createDirs' => '',
'clearcacheonload' => true,
'author' => 'Christoph Lehmann',
'author_email' => 'christoph.lehmann@networkteam.com',
'author_company' => 'networkteam GmbH',
'constraints' =>
array (
'depends' =>
array (
'typo3' => '6.2.0-7.9.99',
),
'conflicts' =>
array (
),
'suggests' =>
array (
),
),
);
'constraints' => [
'depends' => [
'typo3' => '6.2.0-8.9.99',
],
'conflicts' => [],
'suggests' => [],
],
];
15 changes: 15 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}

$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = ''; // show default TYPO3 error message
$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = '0'; // don't turn errors into exceptions, use productionExceptionHandler
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_errorDLOG'] = '1'; // developer log ('devlog' extension)
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_exceptionDLOG'] = '1'; // developer log ('devlog' extension)
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = 'devlog';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'] = ''; // no local logging (= maximum performance)
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = '0'; // log everything
$GLOBALS['TYPO3_CONF_VARS']['SYS']['syslogErrorReporting'] = E_ALL;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting'] = E_ALL;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['exceptionalErrors'] = E_RECOVERABLE_ERROR | E_USER_DEPRECATED;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors'] = E_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandler'] = 'SentryClient\\ErrorHandler';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['debugExceptionHandler'] = 'SentryClient\\DebugExceptionHandler';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['productionExceptionHandler'] = 'SentryClient\\ProductionExceptionHandler';