Skip to content

TelescopeServiceProvider ​

Class: Unusualify\Modularous\Providers\TelescopeServiceProvider
Source: src/Providers/TelescopeServiceProvider.php
Extends: Laravel\Telescope\TelescopeApplicationServiceProvider

Configures Laravel Telescope access control and entry filtering. Registered automatically by BaseServiceProvider — not listed in ModularousProvider's provider array.

boot() ​

  1. Calls $this->gate() to define the viewTelescope gate
  2. Sets the Telescope auth callback:
php
Telescope::auth(function ($request) {
    return app()->environment('local') ||
        Gate::check('viewTelescope', [$request->user()]);
});

Telescope is accessible to everyone in local environments. In other environments, only users who pass the viewTelescope gate can access it.

register() ​

Entry filtering ​

php
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
    return $isLocal ||
           $entry->isReportableException() ||
           $entry->isFailedRequest() ||
           $entry->isFailedJob() ||
           $entry->isScheduledTask() ||
           $entry->isSlowQuery() ||
           $entry->hasMonitoredTag();
});

In local, every entry is recorded. In production/staging, only the following entry types are stored:

Entry typeMethod
Reportable exceptionsisReportableException()
Failed HTTP requestsisFailedRequest()
Failed queued jobsisFailedJob()
Scheduled task runsisScheduledTask()
Slow database queriesisSlowQuery()
Entries with a monitored taghasMonitoredTag()

Sensitive data filtering (non-local) ​

Removes the following from recorded entries:

TypeFiltered values
Request parameters_token
Request headerscookie, x-csrf-token, x-xsrf-token

gate() ​

Defines the viewTelescope gate. By default the allowed-emails list is empty — add emails to grant non-local access:

php
Gate::define('viewTelescope', function ($user) {
    return in_array($user->email, [
        '[email protected]',
    ]);
});