From e938e8436b03890272c6e526266a207417af1a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Wed, 31 May 2023 10:01:17 +0300 Subject: [PATCH] sentry integration for n+1 --- app/Providers/App.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Providers/App.php b/app/Providers/App.php index 8a40fbc7f36..4627ef62c36 100644 --- a/app/Providers/App.php +++ b/app/Providers/App.php @@ -43,9 +43,13 @@ public function boot() Model::preventLazyLoading(config('app.eager_load')); Model::handleLazyLoadingViolationUsing(function ($model, $relation) { - $class = get_class($model); - - report("Attempted to lazy load [{$relation}] on model [{$class}]."); + if (config('logging.default') == 'sentry') { + \Sentry\Laravel\Integration::lazyLoadingViolationReporter(); + } else { + $class = get_class($model); + + report("Attempted to lazy load [{$relation}] on model [{$class}]."); + } }); } }