File tree 4 files changed +27
-5
lines changed
4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 10
10
// @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/
11
11
'dsn ' => env ('SENTRY_LARAVEL_DSN ' , env ('SENTRY_DSN ' )),
12
12
13
+ // @see https://spotlightjs.com/
14
+ // 'spotlight' => env('SENTRY_SPOTLIGHT', false),
15
+
13
16
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#logger
14
17
// 'logger' => Sentry\Logger\DebugFileLogger::class, // By default this will log to `storage_path('logs/sentry.log')`
15
18
Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ protected function hasDsnSet(): bool
25
25
return !empty ($ config ['dsn ' ]);
26
26
}
27
27
28
+ /**
29
+ * Check if Spotlight was enabled in the config.
30
+ *
31
+ * @return bool
32
+ */
33
+ protected function hasSpotlightEnabled (): bool
34
+ {
35
+ $ config = $ this ->getUserConfig ();
36
+
37
+ return ($ config ['spotlight ' ] ?? false ) === true ;
38
+ }
39
+
28
40
/**
29
41
* Retrieve the user configuration.
30
42
*
@@ -42,12 +54,14 @@ protected function getUserConfig(): array
42
54
*
43
55
* Because of `traces_sampler` being dynamic we can never be 100% confident but that is also not important.
44
56
*
57
+ * @deprecated since version 4.6. To be removed in version 5.0.
58
+ *
45
59
* @return bool
46
60
*/
47
61
protected function couldHavePerformanceTracingEnabled (): bool
48
62
{
49
63
$ config = $ this ->getUserConfig ();
50
64
51
- return !empty ($ config ['traces_sample_rate ' ]) || !empty ($ config ['traces_sampler ' ]);
65
+ return !empty ($ config ['traces_sample_rate ' ]) || !empty ($ config ['traces_sampler ' ]) || ( $ config [ ' spotlight ' ] ?? false ) === true ;
52
66
}
53
67
}
Original file line number Diff line number Diff line change @@ -83,7 +83,9 @@ public function boot(): void
83
83
84
84
$ this ->bootFeatures ();
85
85
86
- if ($ this ->hasDsnSet ()) {
86
+ // Only register if a DSN is set or Spotlight is enabled
87
+ // No events can be sent without a DSN set or Spotlight enabled
88
+ if ($ this ->hasDsnSet () || $ this ->hasSpotlightEnabled ()) {
87
89
$ this ->bindEvents ();
88
90
89
91
if ($ this ->app instanceof Lumen) {
@@ -188,7 +190,9 @@ protected function registerFeatures(): void
188
190
*/
189
191
protected function bootFeatures (): void
190
192
{
191
- $ bootActive = $ this ->hasDsnSet ();
193
+ // Only register if a DSN is set or Spotlight is enabled
194
+ // No events can be sent without a DSN set or Spotlight enabled
195
+ $ bootActive = $ this ->hasDsnSet () || $ this ->hasSpotlightEnabled ();
192
196
193
197
foreach (self ::FEATURES as $ feature ) {
194
198
try {
Original file line number Diff line number Diff line change @@ -26,8 +26,9 @@ class ServiceProvider extends BaseServiceProvider
26
26
27
27
public function boot (): void
28
28
{
29
- // If there is no DSN set we register nothing since it's impossible for us to send traces without a DSN set
30
- if (!$ this ->hasDsnSet ()) {
29
+ // Only register if a DSN is set or Spotlight is enabled
30
+ // No events can be sent without a DSN set or Spotlight enabled
31
+ if (!$ this ->hasDsnSet () && !$ this ->hasSpotlightEnabled ()) {
31
32
return ;
32
33
}
33
34
You can’t perform that action at this time.
0 commit comments