File tree 4 files changed +47
-1
lines changed
4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - Respect the ` SENTRY_ENVIRONMENT ` environment variable to override the Laravel environment (#354 )
6
+
5
7
## 1.8.0
6
8
7
9
- Add ` send_default_pii ` option by default to published config file (#340 )
Original file line number Diff line number Diff line change 7
7
// capture release as git sha
8
8
// 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),
9
9
10
+ // When left empty or `null` the Laravel environment will be used
11
+ 'environment ' => env ('SENTRY_ENVIRONMENT ' ),
12
+
10
13
'breadcrumbs ' => [
11
14
// Capture Laravel logs in breadcrumbs
12
15
'logs ' => true ,
Original file line number Diff line number Diff line change @@ -114,13 +114,17 @@ protected function configureAndRegisterClient(): void
114
114
115
115
$ options = \array_merge (
116
116
[
117
- 'environment ' => $ this ->app ->environment (),
118
117
'prefixes ' => [$ basePath ],
119
118
'in_app_exclude ' => ["{$ basePath }/vendor " ],
120
119
],
121
120
$ userConfig
122
121
);
123
122
123
+ // When we get no environment from the (user) configuration we default to the Laravel environment
124
+ if (empty ($ options ['environment ' ])) {
125
+ $ options ['environment ' ] = $ this ->app ->environment ();
126
+ }
127
+
124
128
$ clientBuilder = ClientBuilder::create ($ options );
125
129
126
130
// Set the Laravel SDK identifier and version
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Sentry ;
4
+
5
+ use Sentry \Laravel \Tests \SentryLaravelTestCase ;
6
+
7
+ class ServiceProviderWithEnvironmentFromConfigTest extends SentryLaravelTestCase
8
+ {
9
+ public function testSentryEnvironmentDefaultsToLaravelEnvironment ()
10
+ {
11
+ $ this ->assertEquals ('testing ' , app ()->environment ());
12
+ }
13
+
14
+ public function testEmptySentryEnvironmentDefaultsToLaravelEnvironment ()
15
+ {
16
+ $ this ->resetApplicationWithConfig ([
17
+ 'sentry.environment ' => '' ,
18
+ ]);
19
+
20
+ $ this ->assertEquals ('testing ' , $ this ->getHubFromContainer ()->getClient ()->getOptions ()->getEnvironment ());
21
+
22
+ $ this ->resetApplicationWithConfig ([
23
+ 'sentry.environment ' => null ,
24
+ ]);
25
+
26
+ $ this ->assertEquals ('testing ' , $ this ->getHubFromContainer ()->getClient ()->getOptions ()->getEnvironment ());
27
+ }
28
+
29
+ public function testSentryEnvironmentDefaultGetsOverriddenByConfig ()
30
+ {
31
+ $ this ->resetApplicationWithConfig ([
32
+ 'sentry.environment ' => 'not_testing ' ,
33
+ ]);
34
+
35
+ $ this ->assertEquals ('not_testing ' , $ this ->getHubFromContainer ()->getClient ()->getOptions ()->getEnvironment ());
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments