refactor: SentryEventScrubber static + config array notation
The scrubber is fully stateless. Container-resolution per event was overhead without value, the closure indirection polluted the config layer with executable logic, and stack traces showed an anonymous closure frame instead of the class name. - SentryEventScrubber::scrub() and its private helpers all become static methods. No instance fields, so the change is mechanical. - config/sentry.php before_send switches from a closure that calls app() to PHP array-callable notation [Class, method]. Symfony OptionsResolver accepts array-callables for static methods. - PiiScrubbingTest swaps (new SentryEventScrubber)->scrub(...) for SentryEventScrubber::scrub(...). Semantics unchanged. Tests 1537 unchanged. Larastan and Pint clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,8 +25,12 @@ return [
|
||||
// When left empty or `null` the Laravel environment will be used (usually discovered from `APP_ENV` in your `.env`)
|
||||
'environment' => env('SENTRY_ENVIRONMENT', env('APP_ENV')),
|
||||
|
||||
// Crewli observability scrubber (RFC-WS-7 §3.7).
|
||||
'before_send' => static fn (\Sentry\Event $event, ?\Sentry\EventHint $hint = null): ?\Sentry\Event => app(\App\Services\Observability\SentryEventScrubber::class)->scrub($event, $hint),
|
||||
// RFC-WS-7 §3.7 — stateless static method + array notation.
|
||||
// Configuration is declarative (a reference, not executable logic);
|
||||
// container-resolution per event would be overhead without value for
|
||||
// stateless scrubbing, and stack traces show the class name instead of
|
||||
// an anonymous closure frame.
|
||||
'before_send' => [\App\Services\Observability\SentryEventScrubber::class, 'scrub'],
|
||||
|
||||
// Errors-only — RFC §2 amendment B explicitly excludes performance tracing.
|
||||
// Force traces/profiles off regardless of env.
|
||||
|
||||
Reference in New Issue
Block a user