File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/Sentry/Laravel/Console Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Fix incorrect ` release ` and ` environment ` values when using the ` sentry:test ` command
6+
57## 2.12.0
68
79- Add support for normalized route names when using [ Laravel Lumen] ( https://lumen.laravel.com/docs/9.x ) (#449 )
Original file line number Diff line number Diff line change 1111use Sentry \State \HubInterface ;
1212use Sentry \Tracing \SpanContext ;
1313use Sentry \Tracing \TransactionContext ;
14+ use Throwable ;
1415
1516class TestCommand extends Command
1617{
@@ -54,9 +55,20 @@ public function handle(): int
5455
5556 $ dsn = $ this ->option ('dsn ' );
5657
58+ $ laravelClient = null ;
59+
60+ try {
61+ $ laravelClient = app (HubInterface::class)->getClient ();
62+ } catch (Throwable $ e ) {
63+ // Ignore any errors related to getting the client from the Laravel container
64+ // These errors will surface later in the process but we should not crash here
65+ }
66+
5767 // If the DSN was not passed as option to the command we use the registered client to get the DSN from the Laravel config
5868 if ($ dsn === null ) {
59- $ dsnObject = app (HubInterface::class)->getClient ()->getOptions ()->getDsn ();
69+ $ dsnObject = $ laravelClient === null
70+ ? null
71+ : $ laravelClient ->getOptions ()->getDsn ();
6072
6173 if ($ dsnObject !== null ) {
6274 $ dsn = (string )$ dsnObject ;
@@ -77,6 +89,8 @@ public function handle(): int
7789 try {
7890 $ clientBuilder = ClientBuilder::create ([
7991 'dsn ' => $ dsn ,
92+ 'release ' => $ laravelClient === null ? null : $ laravelClient ->getOptions ()->getRelease (),
93+ 'environment ' => $ laravelClient === null ? null : $ laravelClient ->getOptions ()->getEnvironment (),
8094 'traces_sample_rate ' => 1.0 ,
8195 ]);
8296 } catch (Exception $ e ) {
You can’t perform that action at this time.
0 commit comments