Add URI Tag to Telescope Requests cover image

Add URI Tag to Telescope Requests

Sam Ciaramilaro • March 20, 2024

Snippets

This adds the ability to add a URI tag to requests in order to filter requests in Telescope by the URI.

// TelescopeServiceProvider.php

use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;

/**
 * Register any application services.
 */
public function register(): void
{
    Telescope::tag(function (IncomingEntry $entry) {
        $uri = $entry->content['uri'] ?? null;

        return $entry->isRequest() && $uri
            ? ['URI:'.$uri]
            : [];
    });

    // ...
 }

The URI tag will now be added to the request in Telescope. Telescope URI Ta

And the requests can now be filtered by the URI. Telescope URI Ta