Appearance
Sentry
Errors and performance of the site in Sentry.
kitloom/ · admins: kitloom/, kitloom/
Video lessons
Recorded in the Filament admin; the Nova admin works the same way.
Sends the site's errors to Sentry: what broke, on which page, for which kind of visitor, and what was changed on the site just before. Works with sentry.io, a self-hosted Sentry and GlitchTip. The admin page is the Sentry section (kitloom/sentry-filament or kitloom/sentry-nova).
Connecting the site
- In Sentry, create a project (platform: Laravel) and copy its DSN — Project Settings → Client Keys (DSN). It looks like
https://.abc123@o123. ingest. sentry. io/ 456 - In the admin, open Sentry → Settings, paste the DSN and save.
- Press Send test event (in Nova: tick Send a test event on save and save). The event shows up in Sentry → Issues within a minute. If the page says Sentry did not take it, the DSN is wrong or the server cannot reach Sentry.
Sentry starts with the next request. Under Octane a new DSN works after php artisan octane:.
| Field | What it means |
|---|---|
| DSN | Where the events go. Empty — Sentry is off. |
| Environment | The name events are filed under (production, staging…). Empty — the application's environment. |
| Traced requests, % | The share of requests whose timing goes to Sentry's Performance: database queries, rendering. 0 — errors only. On a busy site 5–20 % is plenty; every traced request counts against the Sentry quota. |
| Report JavaScript errors from the site's pages | The theme's pages load Sentry's browser SDK and report errors of the page's scripts to the same project. Off by default. |
When SENTRY_ is set in the server's environment, the environment rules: the connection fields only show its values and are not saved. The browser switch still works.
Errors in visitors' browsers
Turned on, every page of the theme loads Sentry's browser SDK from Sentry's CDN (with its integrity hash) and reports JavaScript errors with the same DSN and environment, tagged with the page's template (kitloom.). Visitors with an ad blocker may block it — Sentry sees fewer browser errors than there are.
The theme must have @site in its layout (every kitloom theme has); a theme of your own adds @site, @site and @site to its root layout. Nothing about the visitor is put into the page — it is cached the same for everyone. With a Content Security Policy, allow https:// for scripts and the Sentry host for connections; a nonce set with Vite:: goes on the scripts.
When the database is down
The settings live in the database, and a DSN read from it would be missing exactly when the database fails. So each server keeps a copy of them in storage/, read before the database is asked anything: the error "database is down" still reaches Sentry. The status on the settings page says whether this server's copy is up to date. The copy is rewritten on every save and checked against the settings once a minute, which is how the other servers of a site learn of a change. A server that has never reached its database since it was deployed has no copy — give such setups SENTRY_.
What the site adds to Sentry's events
| What | Switch (kitloom-) |
|---|---|
Exceptions are reported by the module — no Integration:: in bootstrap/ (with it, turn this off, or every exception arrives twice) | report_ |
Pages named by the template hierarchy instead of one fallback route: single-, page, front-, home, category, tag, taxonomy-, author, date, archive-, search, 404 | transaction_ |
Tag kitloom. and context kitloom_: kind, post type or taxonomy, object id, page number | page_ |
The signed-in user's id, nothing else; with sentry. the SDK sends the user itself | user_ |
Content saved, published, trashed, restored or deleted before the error — book 12 saved: ids, types and statuses, no titles | content_ |
For developers
- Settings:
sentry_,dsn sentry_,environment sentry_,traces_ percent sentry_(declared bybrowser Sentry, written throughOptions Setting; a DSN the SDK cannot parse is refused).Writer Sentryputs the local copy into Sentry's config while the application boots;Config:: apply() Testsends a message with its own client and returns the transport's answer (Event:: send() success,invalid,unknownwhen Sentry could not be reached) — the SDK gives an event id even to an event Sentry refused.Browseris aScripts Pageof kitloom/site; the SDK's url and hash are inScripts Provider kitloom-, a newer SDK is a config change.sentry. browser php artisan vendor:forpublish -- tag=kitloom- sentry- config kitloom-: the copy's path (sentry. php KITLOOM_; under unit tests there is no copy unless a test names one) and check interval, the switches above, the admin sections (SENTRY_ LOCAL_ COPY filament.,register nova.). Everything else is sentry-laravel's ownregister config/.sentry. php - Tests, from the application that installs the package:
php vendor/.bin/ phpunit -- testsuite Sentry