bekand / telescope-request-track
Automatically attach request identifiers to Laravel JSON responses and Telescope request entries.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/bekand/telescope-request-track
Requires
- php: ^8.1
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
README
Automatically attach a Telescope-compatible request identifier to every JSON response and propagate it via headers.
Installation
composer require bekand/telescope-request-track
The package registers itself automatically thanks to Laravel's package auto-discovery.
Configuration
Publish the configuration to customise header names, JSON keys, or disable the middleware globally.
php artisan vendor:publish --tag=telescope-track-config
Available options (see config/telescope-track.php):
enabled(bool): Toggle the middleware globally (defaulttrue).show_in_json(bool): Control whether the request ID is appended to JSON payloads (defaulttrue).key(string): JSON key added to responses (defaultrequest_id).header(string): Header used for propagation (defaultX-Request-Id).routes(array): Middleware groups that should receive the request ID middleware (default['api', 'web']).except(array): URI patterns (same semantics as$request->is()) that should not receive a request ID.
Usage
The middleware is prepended globally, so every JSON response automatically gains a request identifier. Responses that already define the configured JSON key are respected.
If a response body is a JSON list, it's wrapped into a structure like:
{
"data": [1, 2, 3],
"request_id": "..."
}
Skipping specific routes
Wrap routes with the provided SkipRequestId middleware to bypass augmentation:
use BekAnd\TelescopeRequestTrack\Middleware\SkipRequestId; Route::get('/health', function () { return response()->json(['status' => 'ok']); })->middleware(SkipRequestId::class);
Telescope integration
When laravel/telescope is installed, the package tags request entries with the request identifier so you can filter them easily:
request-id: <value>
Testing
composer test
License
Released under the MIT License.