Sentry and Glitchtip 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 > report > debug > patch > 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, Rollbar, AirBrake and BugSnag before, you'll know roughly what to expect.
See composer.json
composer require phptek/sentry
SentryClientAdaptor
has been renamed to SentryAdaptor
and SentryLogWriter
was renamed to SentryLogger
, so your existing configuration(s) may need to be updated accordingly.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
---
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 for further configuration and customisation options.
Notes:
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:
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, '<=');
Sentry is normally setup once in your project's .env
, YML config or even _config.php
file. See the above examples and the usage docs for details and options.
If you like what you see, support me! I accept Bitcoin:
3KxmqFeVWoigjvXZoLGnoNzvEwnDq3dZ8Q |