Skip to content

Commit accc94f

Browse files
authored
Only capture attributes when fetching user data (#244)
When a user is connected to many other models, calling toArray can be intensive, and the data gathered may not be much more useful from a debugging perspective. This change reduces the overhead of fetching the user.
1 parent 8063d80 commit accc94f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/BugsnagServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ protected function setupCallbacks(Client $client, Container $app, array $config)
269269
if (!isset($config['user']) || $config['user']) {
270270
$client->registerCallback(new CustomUser(function () use ($app) {
271271
if ($user = $app->auth->user()) {
272-
if (is_callable([$user, 'toArray'])) {
273-
return $user->toArray();
272+
if (method_exists($user, 'attributesToArray') && is_callable([$user, 'attributesToArray'])) {
273+
return $user->attributesToArray();
274274
}
275275

276276
if ($user instanceof GenericUser) {

0 commit comments

Comments
 (0)