Skip to content
Open
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
29 changes: 16 additions & 13 deletions src/log/SentryTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ protected function getOptions(): array
{
$options = [
'dsn' => $this->dsn ?: null,
'release' => $this->release ?: null,
'environment' => $this->environment ?: (App::env('CRAFT_ENVIRONMENT') ?: null),
'release' => $this->release ?? App::env('CRAFT_CLOUD_BUILD_ID'),
'environment' => $this->environment ?? App::env('CRAFT_ENVIRONMENT'),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App::env returns null if it can't find anything, so it seemed more straightforward to use null coalescing here.

'context_lines' => 10,
'send_default_pii' => !$this->anonymous,
'default_integrations' => true,
Expand Down Expand Up @@ -257,16 +257,19 @@ protected function getExtras($request): array
/** @var \craft\console\Request|\craft\web\Request $request */

$extras = [
'App Name' => Craft::$app->getSystemName(),
'Craft Edition' => Craft::$app->edition->name,
'Craft Schema' => Craft::$app->schemaVersion,
'Craft Version' => Craft::$app->getVersion(),
'Dev Mode' => Craft::$app->getConfig()->getGeneral()->devMode ? 'Yes' : 'No',
'Environment' => App::env('CRAFT_ENVIRONMENT') ?: null,
'PHP Version' => App::phpVersion(),
'Request Type' => $request->getIsConsoleRequest() ? 'Console' : ($request->getIsAjax() ? 'Ajax' : 'Web'),
'Twig Version' => TwigEnvironment::VERSION,
'Yii Version' => Yii::getVersion(),
'App Name' => Craft::$app->getSystemName(),
'Craft Edition' => Craft::$app->edition->name,
'Craft Schema' => Craft::$app->schemaVersion,
'Craft Version' => Craft::$app->getVersion(),
'Dev Mode' => Craft::$app->getConfig()->getGeneral()->devMode ? 'Yes' : 'No',
'Environment' => App::env('CRAFT_ENVIRONMENT'),
'PHP Version' => App::phpVersion(),
'Request Type' => $request->getIsConsoleRequest() ? 'Console' : ($request->getIsAjax() ? 'Ajax' : 'Web'),
'Twig Version' => TwigEnvironment::VERSION,
'Yii Version' => Yii::getVersion(),
'Craft Cloud Project ID' => App::env('CRAFT_CLOUD_PROJECT_ID'),
'Craft Cloud Environment ID' => App::env('CRAFT_CLOUD_ENVIRONMENT_ID'),
'Craft Cloud Build ID' => App::env('CRAFT_CLOUD_BUILD_ID'),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will get filtered if empty (see below)

];

if ($request->getIsConsoleRequest()) {
Expand Down Expand Up @@ -299,7 +302,7 @@ protected function getExtras($request): array
}
} catch (\Throwable $e) {}

return $extras;
return array_filter($extras);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filter any items with falsey values.

}

/**
Expand Down