| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | public const SDK_IDENTIFIER = 'sentry.php'; |
| 28 | 28 | /** |
| 29 | 29 | * The version of the SDK. |
| 30 | 30 | */ |
| 31 | - public const SDK_VERSION = '4.31.0'; | |
| 31 | + public const SDK_VERSION = '4.32.0'; | |
| 32 | 32 | /** |
| 33 | 33 | * Regex pattern to detect if a string is a regex pattern (starts and ends with / optionally followed by flags). |
| 34 | 34 | * Supported flags: i (case-insensitive), m (multiline), s (dotall), u (unicode). |
| 35 | 35 | */ |
| @@ -360,13 +360,28 @@ | ||
| 360 | 360 | private function applyBeforeSendCallback(Event $event, ?EventHint $hint) : ?Event |
| 361 | 361 | { |
| 362 | 362 | switch ($event->getType()) { |
| 363 | 363 | case EventType::event(): |
| 364 | - return $this->options->getBeforeSendCallback()($event, $hint); | |
| 364 | + try { | |
| 365 | + return $this->options->getBeforeSendCallback()($event, $hint); | |
| 366 | + } catch (\Throwable $exception) { | |
| 367 | + $this->logger->error(\sprintf('The "before_send" callback failed with exception: "%s".', $exception->getMessage())); | |
| 368 | + return null; | |
| 369 | + } | |
| 365 | 370 | case EventType::transaction(): |
| 366 | - return $this->options->getBeforeSendTransactionCallback()($event, $hint); | |
| 371 | + try { | |
| 372 | + return $this->options->getBeforeSendTransactionCallback()($event, $hint); | |
| 373 | + } catch (\Throwable $exception) { | |
| 374 | + $this->logger->error(\sprintf('The "before_send_transaction" callback failed with exception: "%s".', $exception->getMessage())); | |
| 375 | + return null; | |
| 376 | + } | |
| 367 | 377 | case EventType::checkIn(): |
| 368 | - return $this->options->getBeforeSendCheckInCallback()($event, $hint); | |
| 378 | + try { | |
| 379 | + return $this->options->getBeforeSendCheckInCallback()($event, $hint); | |
| 380 | + } catch (\Throwable $exception) { | |
| 381 | + $this->logger->error(\sprintf('The "before_send_check_in" callback failed with exception: "%s".', $exception->getMessage())); | |
| 382 | + return null; | |
| 383 | + } | |
| 369 | 384 | default: |
| 370 | 385 | return $event; |
| 371 | 386 | } |
| 372 | 387 | } |