From 5d02eace09d239931508d9031dbd868d5b09748d Mon Sep 17 00:00:00 2001 From: Sebastiaan Kloos Date: Wed, 15 Nov 2023 15:41:30 +0100 Subject: [PATCH] added a custom tag for the livewire original url --- .../Laravel/Features/LivewirePackageIntegration.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Sentry/Laravel/Features/LivewirePackageIntegration.php b/src/Sentry/Laravel/Features/LivewirePackageIntegration.php index c7c6d157..71d7d1aa 100644 --- a/src/Sentry/Laravel/Features/LivewirePackageIntegration.php +++ b/src/Sentry/Laravel/Features/LivewirePackageIntegration.php @@ -9,6 +9,7 @@ use Sentry\Breadcrumb; use Sentry\Laravel\Integration; use Sentry\SentrySdk; +use Sentry\State\Scope; use Sentry\Tracing\Span; use Sentry\Tracing\SpanContext; use Sentry\Tracing\TransactionSource; @@ -187,7 +188,9 @@ public function handleComponentDehydrate(Component $component): void private function updateTransactionName(string $componentName): void { - $transaction = SentrySdk::getCurrentHub()->getTransaction(); + $hub = SentrySdk::getCurrentHub(); + + $transaction = $hub->getTransaction(); if ($transaction === null) { return; @@ -199,6 +202,12 @@ private function updateTransactionName(string $componentName): void $transaction->getMetadata()->setSource(TransactionSource::custom()); Integration::setTransaction($transactionName); + + $hub->configureScope(function (Scope $scope) { + $livewireManager = $this->container()->make(LivewireManager::class); + + $scope->setTag('livewire.original_url', $livewireManager->originalUrl()); + }); } private function isLivewireRequest(): bool