| Total Complexity | 9 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class TelescopeServiceProvider extends TelescopeApplicationServiceProvider |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Register any application services. |
||
| 14 | */ |
||
| 15 | public function register(): void |
||
| 16 | { |
||
| 17 | // Telescope::night(); |
||
| 18 | |||
| 19 | $this->hideSensitiveRequestDetails(); |
||
| 20 | |||
| 21 | $isLocal = $this->app->environment('local'); |
||
| 22 | |||
| 23 | Telescope::filter(function (IncomingEntry $entry) use ($isLocal) { |
||
| 24 | return $isLocal || |
||
| 25 | $entry->isReportableException() || |
||
| 26 | $entry->isFailedRequest() || |
||
| 27 | $entry->isFailedJob() || |
||
| 28 | $entry->isScheduledTask() || |
||
| 29 | $entry->hasMonitoredTag(); |
||
| 30 | }); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Prevent sensitive request details from being logged by Telescope. |
||
| 35 | */ |
||
| 36 | protected function hideSensitiveRequestDetails(): void |
||
| 37 | { |
||
| 38 | if ($this->app->environment('local')) { |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | |||
| 42 | Telescope::hideRequestParameters(['_token']); |
||
| 43 | |||
| 44 | Telescope::hideRequestHeaders([ |
||
| 45 | 'cookie', |
||
| 46 | 'x-csrf-token', |
||
| 47 | 'x-xsrf-token', |
||
| 48 | ]); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Register the Telescope gate. |
||
| 53 | * |
||
| 54 | * This gate determines who can access Telescope in non-local environments. |
||
| 55 | */ |
||
| 56 | protected function gate(): void |
||
| 60 | // |
||
| 61 | ]); |
||
| 62 | }); |
||
| 65 |