statikbe/craft-sentry integration for Craft CMS

Installs: 9 162

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 10

Forks: 1

Open Issues: 0


5.0.0 2024-03-26 20:12 UTC

This package is auto-updated.

Last update: 2024-05-26 20:27:18 UTC

README integration for Craft CMS. Inspired by born05/craft-sentry, but with our own twist.


To install the plugin, follow these instructions in your terminal.

cd /path/to/project
composer require statikbe/craft-sentry
./craft plugin/install craft-sentry


Create a config/craft-sentry.php config file with the following contents:


return [
    'enabled'       => true,
    'anonymous'     => true,
    'clientDsn'     => getenv('SENTRY_DSN') ?: '',
    'excludedCodes' => ['400', '404', '429'],
    'release'       => getenv('SENTRY_RELEASE') ?: null,


To let Sentry log your exception, you don't really need to do anything. Install the plugin and add your DSN and you're set.

When you're writing your own custom code and throwing your own exception, you'll also want to catch those and send them to Sentry. That can be done like this:


use statikbe\sentry\Sentry;
use yii\base\InvalidConfigException; // Don't copy this line, it's just here to make the example theoractically correct ;) 

try {
    throw new InvalidConfigException("Something went wrong here...");
} catch (Exception $e) {

The plugin works for exceptions thrown in web requests as well as console requests. For web requests, the url where the error happened is included.

Brought to you by