Published on

Sentry & TYPO3

Authors

Empowering TYPO3 Development with Sentry

Sentry helps you track runtime errors and performance bottlenecks in your TYPO3 projects. This guide shows a minimal setup and options to tailor it to your stack.

Why Sentry for TYPO3?

  • Automatic error grouping and stack traces
  • Release tracking and performance (APM)
  • Alerting via your preferred channels (email, Slack, …)

Install SDK

Install the PHP SDK (and optionally the Symfony bridge) via Composer:

composer require sentry/sdk:^4.0 sentry/sentry-symfony:^4.0

Minimal bootstrap (TYPO3)

Register the Sentry client early in your bootstrap (e.g. in an ext_localconf.php or a dedicated PSR-15 middleware):

<?php
\Sentry\init([
    'dsn' => getenv('SENTRY_DSN') ?: '',
    'environment' => getenv('APP_ENV') ?: 'production',
    'release' => getenv('RELEASE') ?: null,
    'traces_sample_rate' => 0.0, // set > 0.0 to enable APM
]);

Wrap custom code to capture exceptions, or rely on the framework integration to capture unhandled ones:

try {
    // risky operation
} catch (\Throwable $e) {
    \Sentry\captureException($e);
    throw $e; // rethrow or handle
}

Using the Symfony bridge in TYPO3

TYPO3 uses Symfony components. With sentry/sentry-symfony you can wire Sentry into the DI container and error listener automatically.

  1. Enable the bundle in a small integration package or your site extension:
// Configuration/Services.yaml
services:
  _defaults:
    autowire: true
    autoconfigure: true

  Sentry\Symfony\Bundle\SentryBundle: ~
  1. Configure options:
# Configuration/Packages/sentry.yaml (or similar)
sentry:
  dsn: '%env(SENTRY_DSN)%'
  options:
    environment: '%env(APP_ENV)%'
    release: '%env(RELEASE)%'
    traces_sample_rate: 0.1 # enable performance tracing

Best practices

  • Use environment variables for secrets (DSN, environment, release)
  • Tag events (site, context, TYPO3 version) to help triage
  • Rate-limit and filter noisy exceptions (e.g. 404)
\Sentry\configureScope(function (\Sentry\State\Scope $scope): void {
    $scope->setTag('typo3_version', \TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version());
});

Performance monitoring (optional)

Enable tracing to see transaction spans for requests. Start with a low traces_sample_rate and increase as needed.

Conclusion

With a few lines of configuration, Sentry gives you instant visibility into production errors and performance issues in TYPO3.