diff --git a/src/Sentry/Laravel/Features/NotificationsIntegration.php b/src/Sentry/Laravel/Features/NotificationsIntegration.php index 1f236401..79b4b0cd 100644 --- a/src/Sentry/Laravel/Features/NotificationsIntegration.php +++ b/src/Sentry/Laravel/Features/NotificationsIntegration.php @@ -76,14 +76,22 @@ public function handleNotificationSent(NotificationSent $event): void } } - private function formatNotifiable(object $notifiable): string + private function formatNotifiable($notifiable): string { - $notifiable = get_class($notifiable); + if (is_string($notifiable) || is_numeric($notifiable)) { + return (string)$notifiable; + } + + if (is_object($notifiable)) { + $result = get_class($notifiable); + + if ($notifiable instanceof Model) { + $result .= "({$notifiable->getKey()})"; + } - if ($notifiable instanceof Model) { - $notifiable .= "({$notifiable->getKey()})"; + return $result; } - return $notifiable; + return 'unknown'; } }