Skip to content

Commit

Permalink
Fix Scope extra data setup by Event extra data
Browse files Browse the repository at this point in the history
Without this fix API doesn't log extra data to Sentry
  • Loading branch information
devicebusy committed Sep 6, 2024
1 parent 383514b commit 1c54ad2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/State/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public function applyToEvent(Event $event, ?EventHint $hint = null, ?Options $op
$event->setTags(array_merge($this->tags, $event->getTags()));
}

if (!empty($this->extra)) {
if (!empty($this->extra) || !empty($event->getExtra())) {
$event->setExtra(array_merge($this->extra, $event->getExtra()));
}

Expand Down
17 changes: 17 additions & 0 deletions tests/State/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@ public function testSetExtras(): void
$this->assertSame(['foo' => 'bar', 'bar' => 'baz'], $event->getExtra());
}

public function testSetExtrasOnScopeWithoutExtras(): void
{
$scope = new Scope();

$event = $scope->applyToEvent(Event::createEvent());

$this->assertNotNull($event);
$this->assertSame([], $event->getExtra());

$scope->setExtras(['bar' => 'baz']);

$event = $scope->applyToEvent(Event::createEvent());

$this->assertNotNull($event);
$this->assertSame(['bar' => 'baz'], $event->getExtra());
}

public function testSetUser(): void
{
$scope = new Scope();
Expand Down

0 comments on commit 1c54ad2

Please sign in to comment.