From 13caee0489dd641c300d6a854519fa4f91a193fb Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Fri, 24 Jan 2025 12:35:24 +0100 Subject: [PATCH] Fix unable to parse string notifiable --- .../Features/NotificationsIntegration.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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'; } }