Skip to content

Commit 6e2bcd6

Browse files
authored
Merge pull request grokability#17680 from grokability/added-telescope
Added laravel telescope for dev environment
2 parents 9c0202e + 35b358d commit 6e2bcd6

File tree

7 files changed

+427
-2
lines changed

7 files changed

+427
-2
lines changed

app/Providers/AppServiceProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public function boot(UrlGenerator $url)
8585
*/
8686
public function register()
8787
{
88+
89+
if ($this->app->environment('local')) {
90+
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
91+
$this->app->register(TelescopeServiceProvider::class);
92+
}
93+
8894
// Only load rollbar if there is a rollbar key and the app is in production
8995
if (($this->app->environment('production')) && (config('logging.channels.rollbar.access_token'))) {
9096
$this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\Facades\Gate;
6+
use Laravel\Telescope\IncomingEntry;
7+
use Laravel\Telescope\Telescope;
8+
use Laravel\Telescope\TelescopeApplicationServiceProvider;
9+
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
57+
{
58+
Gate::define('viewTelescope', function ($user) {
59+
if ($user->isSuperUser()) {
60+
return true;
61+
}
62+
63+
return false;
64+
});
65+
}
66+
}

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
},
8585
"require-dev": {
8686
"larastan/larastan": "^2.9",
87+
"laravel/telescope": "^5.11",
8788
"mockery/mockery": "^1.4",
8889
"nunomaduro/phpinsights": "^2.11",
8990
"php-mock/php-mock-phpunit": "^2.10",
@@ -95,7 +96,8 @@
9596
"extra": {
9697
"laravel": {
9798
"dont-discover": [
98-
"rollbar/rollbar-laravel"
99+
"rollbar/rollbar-laravel",
100+
"laravel/telescope"
99101
]
100102
}
101103
},

composer.lock

Lines changed: 70 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/telescope.php

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
<?php
2+
3+
use Laravel\Telescope\Http\Middleware\Authorize;
4+
use Laravel\Telescope\Watchers;
5+
6+
return [
7+
8+
/*
9+
|--------------------------------------------------------------------------
10+
| Telescope Master Switch
11+
|--------------------------------------------------------------------------
12+
|
13+
| This option may be used to disable all Telescope watchers regardless
14+
| of their individual configuration, which simply provides a single
15+
| and convenient way to enable or disable Telescope data storage.
16+
|
17+
*/
18+
19+
'enabled' => env('TELESCOPE_ENABLED', false),
20+
21+
/*
22+
|--------------------------------------------------------------------------
23+
| Telescope Domain
24+
|--------------------------------------------------------------------------
25+
|
26+
| This is the subdomain where Telescope will be accessible from. If the
27+
| setting is null, Telescope will reside under the same domain as the
28+
| application. Otherwise, this value will be used as the subdomain.
29+
|
30+
*/
31+
32+
'domain' => env('TELESCOPE_DOMAIN'),
33+
34+
/*
35+
|--------------------------------------------------------------------------
36+
| Telescope Path
37+
|--------------------------------------------------------------------------
38+
|
39+
| This is the URI path where Telescope will be accessible from. Feel free
40+
| to change this path to anything you like. Note that the URI will not
41+
| affect the paths of its internal API that aren't exposed to users.
42+
|
43+
*/
44+
45+
'path' => env('TELESCOPE_PATH', 'telescope'),
46+
47+
/*
48+
|--------------------------------------------------------------------------
49+
| Telescope Storage Driver
50+
|--------------------------------------------------------------------------
51+
|
52+
| This configuration options determines the storage driver that will
53+
| be used to store Telescope's data. In addition, you may set any
54+
| custom options as needed by the particular driver you choose.
55+
|
56+
*/
57+
58+
'driver' => env('TELESCOPE_DRIVER', 'database'),
59+
60+
'storage' => [
61+
'database' => [
62+
'connection' => env('DB_CONNECTION', 'mysql'),
63+
'chunk' => 1000,
64+
],
65+
],
66+
67+
/*
68+
|--------------------------------------------------------------------------
69+
| Telescope Queue
70+
|--------------------------------------------------------------------------
71+
|
72+
| This configuration options determines the queue connection and queue
73+
| which will be used to process ProcessPendingUpdate jobs. This can
74+
| be changed if you would prefer to use a non-default connection.
75+
|
76+
*/
77+
78+
'queue' => [
79+
'connection' => env('TELESCOPE_QUEUE_CONNECTION'),
80+
'queue' => env('TELESCOPE_QUEUE'),
81+
'delay' => env('TELESCOPE_QUEUE_DELAY', 10),
82+
],
83+
84+
/*
85+
|--------------------------------------------------------------------------
86+
| Telescope Route Middleware
87+
|--------------------------------------------------------------------------
88+
|
89+
| These middleware will be assigned to every Telescope route, giving you
90+
| the chance to add your own middleware to this list or change any of
91+
| the existing middleware. Or, you can simply stick with this list.
92+
|
93+
*/
94+
95+
'middleware' => [
96+
'web',
97+
Authorize::class,
98+
],
99+
100+
/*
101+
|--------------------------------------------------------------------------
102+
| Allowed / Ignored Paths & Commands
103+
|--------------------------------------------------------------------------
104+
|
105+
| The following array lists the URI paths and Artisan commands that will
106+
| not be watched by Telescope. In addition to this list, some Laravel
107+
| commands, like migrations and queue commands, are always ignored.
108+
|
109+
*/
110+
111+
'only_paths' => [
112+
// 'api/*'
113+
],
114+
115+
'ignore_paths' => [
116+
'livewire*',
117+
],
118+
119+
'ignore_commands' => [
120+
//
121+
],
122+
123+
/*
124+
|--------------------------------------------------------------------------
125+
| Telescope Watchers
126+
|--------------------------------------------------------------------------
127+
|
128+
| The following array lists the "watchers" that will be registered with
129+
| Telescope. The watchers gather the application's profile data when
130+
| a request or task is executed. Feel free to customize this list.
131+
|
132+
*/
133+
134+
'watchers' => [
135+
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
136+
137+
Watchers\CacheWatcher::class => [
138+
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
139+
'hidden' => [],
140+
'ignore' => [],
141+
],
142+
143+
Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
144+
145+
Watchers\CommandWatcher::class => [
146+
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
147+
'ignore' => [],
148+
],
149+
150+
Watchers\DumpWatcher::class => [
151+
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
152+
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
153+
],
154+
155+
Watchers\EventWatcher::class => [
156+
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
157+
'ignore' => [],
158+
],
159+
160+
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
161+
162+
Watchers\GateWatcher::class => [
163+
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
164+
'ignore_abilities' => [],
165+
'ignore_packages' => true,
166+
'ignore_paths' => [],
167+
],
168+
169+
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
170+
171+
Watchers\LogWatcher::class => [
172+
'enabled' => env('TELESCOPE_LOG_WATCHER', true),
173+
'level' => 'error',
174+
],
175+
176+
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
177+
178+
Watchers\ModelWatcher::class => [
179+
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
180+
'events' => ['eloquent.*'],
181+
'hydrations' => true,
182+
],
183+
184+
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
185+
186+
Watchers\QueryWatcher::class => [
187+
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
188+
'ignore_packages' => true,
189+
'ignore_paths' => [],
190+
'slow' => 100,
191+
],
192+
193+
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
194+
195+
Watchers\RequestWatcher::class => [
196+
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
197+
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
198+
'ignore_http_methods' => [],
199+
'ignore_status_codes' => [],
200+
],
201+
202+
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
203+
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
204+
],
205+
];

0 commit comments

Comments
 (0)