Skip to content

Commit

Permalink
added a custom tag for the livewire original url
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastiaanKloos committed Nov 15, 2023
1 parent 342581c commit 5d02eac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Sentry/Laravel/Features/LivewirePackageIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 5d02eac

Please sign in to comment.