PHPackages                             phptek/sentry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. phptek/sentry

ActiveSilverstripe-vendormodule[Logging &amp; Monitoring](/categories/logging)

phptek/sentry
=============

Sentry.io integration for SilverStripe. Binds Sentry.io to SilverStripe's error &amp; exception handling subsystem.

6.0.0(5mo ago)15203.5k—0.6%28[8 issues](https://github.com/phptek/silverstripe-sentry/issues)[2 PRs](https://github.com/phptek/silverstripe-sentry/pulls)3BSD-3-ClausePHPPHP ^8.3CI failing

Since Feb 27Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/phptek/silverstripe-sentry)[ Packagist](https://packagist.org/packages/phptek/sentry)[ RSS](/packages/phptek-sentry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (79)Used By (3)

Sentry.io integration for SilverStripe
======================================

[](#sentryio-integration-for-silverstripe)

[![CI](https://github.com/phptek/silverstripe-sentry/actions/workflows/ci.yml/badge.svg)](https://github.com/phptek/silverstripe-sentry/actions/workflows/ci.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d1469f2064e849b54aae0ba614e46c561aea832b8b9afe6756fee464c66901cc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70687074656b2f73696c7665727374726970652d73656e7472792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phptek/silverstripe-sentry/?branch=master)[![License](https://camo.githubusercontent.com/74fb77c2c371d43152f5ea93a28818612c552352fec6f43d807bef160ca1f82b/68747470733a2f2f706f7365722e707567782e6f72672f70687074656b2f73656e7472792f6c6963656e73652e737667)](https://github.com/phptek/silverstripe-sentry/blob/master/LICENSE.md)

[Sentry](https://sentry.io) and [Glitchtip](https://glitchtip.com) are error and exception aggregation services. Systems like these take your application's errors, aggregate them alongside configurable context and store them for triage and analysis.

Imagine this: You see errors and exceptions before your clients do. The error &gt; report &gt; debug &gt; patch &gt; deploy cycle is therefore the most efficient it can possibly be.

This module binds sentry.io, app.glitchtip.com and on-prem hosted Sentry/Glitchtip installations to the Monlog error logger in Silverstripe. If you've used systems like [RayGun](https://raygun.com), [Rollbar](https://rollbar.com), [AirBrake](https://airbrake.io/) and [BugSnag](https://www.bugsnag.com/) before, you'll know roughly what to expect.

Requirements
------------

[](#requirements)

See `composer.json`

Setup:
------

[](#setup)

```
composer require phptek/sentry

```

Notes:
------

[](#notes)

- Version 6.x is aimed at Silverstripe 6.
- Version 5.x is aimed at Silverstripe 5.
- Versions 2.x, 3.x and 4.x should work with the same Silverstripe v4 setups. v3+ simply use newer versions of the Sentry PHP SDK and have additional bugfixes and features.
- Version 3.x `SentryClientAdaptor` has been renamed to `SentryAdaptor` and `SentryLogWriter` was renamed to `SentryLogger`, so your existing configuration(s) may need to be updated accordingly.

Config
------

[](#config)

You can set your DSN as a first-class environment variable in `.env` or your CI config:

```
SENTRY_DSN="http://deacdf9dfedb24ccdce1b90017b39dca:deacdf9dfedb24ccdce1b90017b39dca@sentry.mydomain.nz/44"

```

You can also set it in your project's YML config:

```
---
Name: my-project-config-sentry
After:
  - 'sentry-config'
---

# Send errors reported for all environment modes: `dev`, `test` and `live` envs

PhpTek\Sentry\Adaptor\SentryAdaptor:
  opts:
    # Example DSN only. Obviously you'll need to setup your own Sentry "Project"
    dsn: http://deacdf9dfedb24ccdce1b90017b39dca:deacdf9dfedb24ccdce1b90017b39dca@sentry.mydomain.nz/44

```

### Conditional Config

[](#conditional-config)

```
---
Name: my-project-config-sentry
After:
  - 'sentry-config'
---

# Send errors reported just in `test` and `live`, but not `dev` envs

---
Only:
  environment: test
---
PhpTek\Sentry\Adaptor\SentryAdaptor:
  opts:
    # Example DSN only. Obviously you'll need to setup your own Sentry "Project"
    dsn: http://deacdf9dfedb24ccdce1b90017b39dca:deacdf9dfedb24ccdce1b90017b39dca@sentry.mydomain.nz/44
---
Except:
  environment: test
---
PhpTek\Sentry\Adaptor\SentryAdaptor:
  opts:
    # Example DSN only. Obviously you'll need to setup your own Sentry "Project"
    dsn: http://deacdf9dfedb24ccdce1b90017b39dca:deacdf9dfedb24ccdce1b90017b39dca@sentry.mydomain.nz/44
---
Only:
  environment: dev
---
PhpTek\Sentry\Adaptor\SentryAdaptor:
  opts:
    dsn: null
---

```

Please review the [usage docs](docs/en/usage.md) for further configuration and customisation options.

Notes:

- Silence `Injector` errors where `test` and `live` envs have `http_proxy` set but `dev` environments don't: Provide a value of `null`, which applies to all YML config where one env has a setting and another doesn't. For example:

```
...
    ---
    Only:
      environment: dev
    ---
    PhpTek\Sentry\Adaptor\SentryAdaptor:
      opts:
        dsn: null
        http_proxy: null
    ---
...

```

- As per the examples above, ensure your project's config is set to come *after* the module's own config, thus:

    After: - 'sentry-config'

### SilverStripe Framework v3

[](#silverstripe-framework-v3)

YML Config:

```
phptek\Sentry\Adaptor\SentryClientAdaptor:
  opts:
    # Example DSN only. Obviously you'll need to setup your own Sentry "Project"
    dsn: http://deacdf9dfedb24ccdce1b90017b39dca:deacdf9dfedb24ccdce1b90017b39dca@sentry.mydomain.nz/44

```

mysite/\_config.php:

```
SS_Log::add_writer(\phptek\Sentry\SentryLogWriter::factory(), SS_Log::ERR, '
