Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Deprecate the `logger` option (#1167)
- Pass the event hint from the `capture*()` methods down to the `before_send` callback (#1138)
- Deprecate the `tags` option, see the [docs](https://docs.sentry.io/platforms/php/guides/laravel/enriching-events/tags/) for other ways to set tags (#1174)
- Make sure the `environment` field is set to `production` if it has not been overridden explicitly (#1116)

## 3.1.5 (2021-02-18)

Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco
}

if (null === $event->getEnvironment()) {
$event->setEnvironment($this->options->getEnvironment());
$event->setEnvironment($this->options->getEnvironment() ?? Event::DEFAULT_ENVIRONMENT);
}

if (null === $event->getLogger()) {
Expand Down
2 changes: 2 additions & 0 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
final class Event
{
public const DEFAULT_ENVIRONMENT = 'production';

/**
* @var EventId The ID
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public function getRelease(): ?string
/**
* Sets the release tag to be passed with every event sent to Sentry.
*
* @param string $release The release
* @param string|null $release The release
*/
public function setRelease(?string $release): void
{
Expand Down
18 changes: 13 additions & 5 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Sentry\ClientBuilder;
use Sentry\Event;
use Sentry\EventHint;
use Sentry\EventId;
use Sentry\ExceptionMechanism;
use Sentry\Frame;
use Sentry\Integration\IntegrationInterface;
Expand Down Expand Up @@ -204,7 +203,9 @@ public function captureExceptionWithEventHintDataProvider(): \Generator
*/
public function testCaptureEvent(array $options, Event $event, Event $expectedEvent): void
{
$this->expectDeprecation('The option "tags" is deprecated since version 3.2 and will be removed in 4.0. Either set the tags on the scope or on the event.');
if (isset($options['tags'])) {
$this->expectDeprecation('The option "tags" is deprecated since version 3.2 and will be removed in 4.0. Either set the tags on the scope or on the event.');
}

$transport = $this->createMock(TransportInterface::class);
$transport->expects($this->once())
Expand All @@ -224,8 +225,7 @@ public function testCaptureEvent(array $options, Event $event, Event $expectedEv

public function captureEventDataProvider(): \Generator
{
$eventId = EventId::generate();
$event = Event::createEvent($eventId);
$event = Event::createEvent();

yield 'Options set && no event properties set => use options' => [
[
Expand All @@ -238,7 +238,7 @@ public function captureEventDataProvider(): \Generator
$event,
];

$event = Event::createEvent($eventId);
$event = Event::createEvent();
$event->setServerName('foo.example.com');
$event->setRelease('721e41770371db95eee98ca2707686226b993eda');
$event->setEnvironment('production');
Expand All @@ -254,6 +254,14 @@ public function captureEventDataProvider(): \Generator
$event,
$event,
];

$event = Event::createEvent();

yield 'Environment option set to null && no event property set => fallback to default value' => [
['environment' => null],
$event,
$event,
];
}

public function testCaptureEventWithEventHint(): void
Expand Down