schmeits/sentry-noise-filter
Composer 安装命令:
composer require schmeits/sentry-noise-filter
包简介
Drop-in Sentry/GlitchTip noise filter for Laravel. Install, set DSN, done.
README 文档
README
A drop-in package that sets up Sentry / GlitchTip error tracking and filters common noise. Install it, set your DSN, done.
The Problem
Laravel apps using Livewire and Filament get bombarded with errors that aren't real bugs:
- Bot spam — Bots hitting
/livewire/updatewith invalid payloads, causingCannotUpdateLockedPropertyException, Filament notification TypeErrors, andRootTagMissingFromViewException - Transient infra errors —
Connection refused,MySQL server has gone away,Redis server went awayduring server updates and restarts - Dev leaks —
Vite manifest not foundand dev-only command errors accidentally sent from local environments
This package silently suppresses these before they reach your error tracker, so you only see real application errors.
Installation
composer require schmeits/sentry-noise-filter
Add your DSN to .env:
SENTRY_LARAVEL_DSN=https://your-key@your-glitchtip-or-sentry-instance/project-id
That's it. The package:
- Pulls in
sentry/sentry-laravelautomatically - Auto-registers the exception handler (no
bootstrap/app.phpchanges needed) - Applies the noise filter to all outgoing error events
Migrating from manual Sentry setup
If you previously had Integration::handles($exceptions) in bootstrap/app.php, you can remove it — the package handles this automatically:
// bootstrap/app.php — REMOVE this block: ->withExceptions(function (Exceptions $exceptions) { Integration::handles($exceptions); // No longer needed })
Recommended .env settings
SENTRY_LARAVEL_DSN=https://your-key@your-instance/project-id SENTRY_SEND_DEFAULT_PII=false SENTRY_TRACES_SAMPLE_RATE=0
SENTRY_SEND_DEFAULT_PII=false— Don't send personal data (IP, cookies, user info). Set totrueonly if you need it for debugging.SENTRY_TRACES_SAMPLE_RATE=0— Disables performance monitoring. Set to0.1(10% of requests) if you want performance data.
Configuration
The default configuration works out of the box. To customize the filter patterns, publish the config:
php artisan vendor:publish --tag=sentry-filter-config
This creates config/sentry-filter.php:
return [ // Disable the filter entirely 'enabled' => env('SENTRY_FILTER_ENABLED', true), // Livewire/Filament bot patterns (suppress by default) 'bot_patterns' => [ 'CannotUpdateLockedPropertyException', 'RootTagMissingFromViewException', // ... ], // Transient infrastructure errors (suppress by default) 'infra_patterns' => [ 'Connection refused', 'MySQL server has gone away', 'Redis server went away', ], // Local development errors (suppress by default) 'dev_patterns' => [ 'Vite manifest not found', 'Command "boost" is not defined', ], // Add your own project-specific patterns 'extra_patterns' => [ // 'Some noisy error you want to suppress', ], // Stack-aware patterns (since v1.4) // Each entry is a pair: ['value' => ..., 'frame' => ...]. The event is only // suppressed when BOTH match. Use this when the message alone is too generic // to filter on, but the combination with a specific vendor frame is unique. 'stack_patterns' => [ // Livewire 3 ErrorException from bots posting malformed snapshots. // Fixed in Livewire 4 with strict snapshot validation. [ 'value' => 'Trying to access array offset on null', 'frame' => 'Mechanisms/HandleComponents/HandleComponents.php', ], ], ];
Simple vs. stack-aware patterns
| Pattern type | Matches against | Use when |
|---|---|---|
bot_patterns / infra_patterns / dev_patterns / extra_patterns |
exception type + message | the message itself is unique enough to identify noise |
stack_patterns |
exception type + message AND a stacktrace frame | the message is generic (e.g. Trying to access array offset on null), but the combination with a specific vendor frame is uniquely bot-spam |
Both pattern types use case-sensitive substring matching.
How It Works
The package does two things automatically on boot:
- Registers exception handling — Equivalent to
Integration::handles()inbootstrap/app.php, but done automatically via the ServiceProvider - Applies noise filtering — Hooks into Sentry's
before_sendcallback. When an error is about to be sent, it checks the exception type and message against all configured patterns. Matches are suppressed, everything else passes through.
The noise filter chains with existing filters — if your project already has a custom before_send in config/sentry.php, it will still run after the noise filter.
Disabling
Disable filtering without removing the package:
SENTRY_FILTER_ENABLED=false
Compatibility
- PHP 8.2+
- Laravel 10, 11, 12, 13
- sentry/sentry-laravel 4.x
- Works with both Sentry and GlitchTip (Sentry-compatible API)
License
MIT
schmeits/sentry-noise-filter 适用场景与选型建议
schmeits/sentry-noise-filter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 396 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 schmeits/sentry-noise-filter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 schmeits/sentry-noise-filter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 396
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-13