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