Git Product home page Git Product logo

sentry_client's Introduction

Sentry Client for TYPO3

ci Latest release on GitHub Latest TER release 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 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://[email protected]/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

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

LogWriter

The extension comes with a LogWriter which forwards messages to Sentry which normally are just logged. You can enable it in 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 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, log messages are reported to Sentry
  • LogWriter Component blacklist

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.

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

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 blacklist
  • 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 bergo avatar brotkrueml avatar christophlehmann avatar cweiske avatar derhansen avatar extcode avatar ger4003 avatar jrenggli avatar konafets avatar leoniephiline avatar susannemoog avatar tlueder avatar

Watchers

 avatar

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.