vendor/sentry/sentry/src/Integration/TransactionIntegration.php line 26

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sentry\Integration;
  4. use Sentry\Event;
  5. use Sentry\EventHint;
  6. use Sentry\SentrySdk;
  7. use Sentry\State\Scope;
  8. /**
  9. * This integration sets the `transaction` attribute of the event to the value
  10. * found in the raw event payload or to the value of the `PATH_INFO` server var
  11. * if present.
  12. *
  13. * @author Stefano Arlandini <sarlandini@alice.it>
  14. */
  15. final class TransactionIntegration implements IntegrationInterface
  16. {
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function setupOnce(): void
  21. {
  22. Scope::addGlobalEventProcessor(static function (Event $event, EventHint $hint): Event {
  23. $integration = SentrySdk::getCurrentHub()->getIntegration(self::class);
  24. // The client bound to the current hub, if any, could not have this
  25. // integration enabled. If this is the case, bail out
  26. if (null === $integration) {
  27. return $event;
  28. }
  29. if (null !== $event->getTransaction()) {
  30. return $event;
  31. }
  32. if (isset($hint->extra['transaction']) && \is_string($hint->extra['transaction'])) {
  33. $event->setTransaction($hint->extra['transaction']);
  34. } elseif (isset($_SERVER['PATH_INFO'])) {
  35. $event->setTransaction($_SERVER['PATH_INFO']);
  36. }
  37. return $event;
  38. });
  39. }
  40. }