Skip to content

Commit 7de2e0a

Browse files
committed
config: add project purpose and browser logs watcher options to boost.php and organnise config in laravel style
1 parent 0070417 commit 7de2e0a

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

config/boost.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
declare(strict_types=1);
44

55
return [
6+
7+
/*
8+
|--------------------------------------------------------------------------
9+
| Boost Project Purpose
10+
|--------------------------------------------------------------------------
11+
|
12+
| This is the purpose of the Boost project helping AI understand context
13+
| the project and its purpose and be guidelines more specific
14+
| project. This should be set to a very specific.
15+
|
16+
*/
17+
618
'project_purpose' => null,
7-
'browser_logs' => true,
19+
20+
/*
21+
|--------------------------------------------------------------------------
22+
| Boost Browser Logs Watcher Switch
23+
|--------------------------------------------------------------------------
24+
|
25+
| The following option may be used to enable or disable browser logs watcher
26+
| functionality which simply provides a single and convenient way to
27+
| enable or disable browser logs functionality in Boost.
28+
*/
29+
'boost_browser_logs_watcher' => env('BOOST_BROWSER_LOGS_WATCHER', true),
830
];

src/BoostServiceProvider.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private function registerRoutes(): void
124124
level: $this->mapJsTypeToPsr3Level($log['type']),
125125
message: $this->buildLogMessageFromData($log['data']),
126126
context: [
127-
'url' => $log['url'],
127+
'url' => $log['url'],
128128
'user_agent' => $log['userAgent'] ?: null,
129129
'timestamp' => $log['timestamp'] ?: now()->toIso8601String(),
130130
]
@@ -133,16 +133,16 @@ private function registerRoutes(): void
133133

134134
return response()->json(['status' => 'logged']);
135135
})
136-
->name('boost.browser-logs')
137-
->withoutMiddleware(VerifyCsrfToken::class);
136+
->name('boost.browser-logs')
137+
->withoutMiddleware(VerifyCsrfToken::class);
138138
}
139139

140140
/**
141141
* Build a string message for the log based on various input types. Single dimensional, and multi:
142142
* "data":[
143143
* {"message":"Unhandled Promise Rejection","reason":{"name":"TypeError","message":"NetworkError when attempting to fetch resource.","stack":""}}]
144144
*
145-
* @param array<mixed> $data
145+
* @param array<mixed> $data
146146
*/
147147
protected function buildLogMessageFromData(array $data): string
148148
{
@@ -174,13 +174,13 @@ protected function registerBrowserLogger(): void
174174
}
175175

176176
/**
177-
* Register a Blade directive for the browser logger script
177+
* Register a Blade directive for the browser logger script.
178178
*
179-
* @param BladeCompiler $bladeCompiler
179+
* @param BladeCompiler $bladeCompiler
180180
*/
181181
protected function registerBladeDirectives(BladeCompiler $bladeCompiler): void
182182
{
183-
$bladeCompiler->directive('boostJs', fn() => '<?php echo \\Laravel\\Boost\\Services\\BrowserLogger::getScript(); ?>');
183+
$bladeCompiler->directive('boostJs', fn () => '<?php echo \\Laravel\\Boost\\Services\\BrowserLogger::getScript(); ?>');
184184
}
185185

186186
private function mapJsTypeToPsr3Level(string $type): string
@@ -198,7 +198,7 @@ private function mapJsTypeToPsr3Level(string $type): string
198198

199199
private function hookIntoResponses(Router $router): void
200200
{
201-
if (config('boost.browser_logs', true) === false) {
201+
if (! config('boost.boost_browser_logs_watcher', true)) {
202202
return;
203203
}
204204

0 commit comments

Comments
 (0)