bliptrace / drupal
Drupal 10/11 module for Bliptrace — auto-captures exceptions via an event subscriber and ships them to the ingest API. Thin adapter over bliptrace/php.
Requires
- php: ^8.2
- bliptrace/php: ^2.0
Requires (Dev)
- laravel/pint: ^1.0
- pestphp/pest: ^3.0
- symfony/http-kernel: ^6.4|^7.0
Suggests
- drupal/core: ^10 || ^11
Provides
None
Conflicts
None
Replaces
None
README
A thin Drupal 10/11 module that auto-captures unhandled exceptions and ships
them to the Bliptrace ingest API. It is a light
adapter over the runtime PHP SDK, bliptrace/php — all the
envelope building, scrubbing and transport live there; this module only wires
Drupal's exception event into the SDK.
Drupal is built on Symfony, so the natural hook is a kernel exception event
subscriber. The module subscribes to KernelEvents::EXCEPTION, enriches the
exception with request context, and hands it to the SDK client.
Never breaks the site. Every step on the capture path is guarded. A misconfigured key, an unreachable ingest endpoint, or a slow network will never raise an error, stop event propagation, or alter the response — Drupal's own error handling continues exactly as before.
How capture works
- An unhandled
ThrowabletriggersKernelEvents::EXCEPTION. ExceptionSubscriberforwards it (at a low priority, so it only observes) to thebliptrace.reporterservice.- The
Reporterbuilds request context (method, URL, headers — withAuthorizationandCookiestripped), then asks thebliptrace/phpclient to build, scrub and ship the envelope. - The envelope is
POSTed toendpoint(/v1/ingestis appended to a bare base URL) with anX-Ingest-Keyheader.
The project is never sent in the payload. It is resolved server-side from the ingest key. Only the key, endpoint and shaping options are configured here.
Install
Add the module via Composer:
composer require bliptrace/drupal
Then enable it:
drush en bliptrace
# or via the UI: Admin → Extend → enable "bliptrace"
Configure
Set the ingest key (and any overrides) in your site's settings.php. Source the
key from the environment so it never lands in version control:
// settings.php $settings['bliptrace'] = [ 'enabled' => TRUE, 'key' => \Bliptrace\Php\Env::get('KEY'), // BLIPTRACE_KEY (required) 'endpoint' => 'https://ingest.bliptrace.com/v1/ingest', 'environment' => \Bliptrace\Php\Env::get('ENVIRONMENT', 'production'), 'release' => \Bliptrace\Php\Env::get('RELEASE'), 'timeout' => 3, // Optional shaping: 'max_frames' => 30, 'max_message' => 2000, 'ignore_exceptions' => [], // fully-qualified Throwable class names to skip 'scrub_keys' => ['password', 'token', 'secret'], ];
Env names:
Bliptrace\Php\Env::get('KEY')(frombliptrace/php^2.0) readsBLIPTRACE_KEY.
| Setting | Maps to Bliptrace\Php\Config |
Default |
|---|---|---|
enabled |
enabled |
true |
key |
key |
null (capture is off without it) |
endpoint |
endpoint |
https://ingest.bliptrace.com/v1/ingest |
environment |
environment |
production |
release |
release |
null |
timeout |
timeout |
3 |
max_frames |
maxFrames |
30 |
max_message |
maxMessage |
2000 |
ignore_exceptions |
ignoreExceptions |
[] |
scrub_keys |
scrubKeys |
[] |
When enabled is false or key is empty, nothing is ever sent.
Service wiring
bliptrace.services.yml registers two services:
bliptrace.reporter— built byReporterFactory::fromDrupalSettings()from thebliptracearray insettings.php.bliptrace.exception_subscriber— taggedevent_subscriber, listens forKernelEvents::EXCEPTION.
Development & tests
The test suite depends only on bliptrace/php (plus symfony/http-kernel to
load the subscriber) — it never pulls in drupal/core. The testable pieces
(Reporter, RequestContext, BliptraceSettings, ReporterFactory) are
framework-light and live under the Bliptrace\Drupal\ namespace; the Drupal
service class lives under Drupal\bliptrace\.
composer install vendor/bin/pest
Licence
MIT. See LICENSE.