Skip to content

Commit

Permalink
sentry integration for n+1
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed May 31, 2023
1 parent 15ebe1f commit e938e84
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/Providers/App.php
Expand Up @@ -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}].");
}
});
}
}

0 comments on commit e938e84

Please sign in to comment.