Laravel In development

The nabd/laravel package: adds the browser script and, optionally, server error types.

Not available yet. These examples show the planned API; package and function names may change before the first release.

Install

bash
composer require nabd/laravel
php artisan vendor:publish --tag=nabd-config

Once published. Publishing the config file is optional.

Setup

.env
NABD_PUBLIC_KEY=nb_pub_…
NABD_APP_NAME="My Portal"
NABD_CONSENT_REQUIRED=true

The public key only. The package does not need the secret key, and if it is put in place of the public one it is not printed in the page.

Browser

resources/views/layouts/app.blade.php
    @nabdScripts
</body>
resources/js/consent.js
window.Nabd.setConsent(true);

Livewire and Inertia navigation is picked up from History API changes. With Vite::useCspNonce() both tags get the nonce.

Screen names

NABD_SCREEN_NAMESNameWhen
url (default)From the page URL with identifiers turned into :idLivewire and Inertia
routeThe route pattern /customers/:nameEvery navigation is a full page load

If your URLs contain names (/customers/ahmed-ali) and the app does not reload the page on every navigation, name the screens yourself.

Support chat: NABD_MESSAGES=true (details).

Server errors (optional)

.env
NABD_SERVER_ERRORS=true

When a fetch or XMLHttpRequest request returns a 5xx from an exception, the response carries an X-Nabd-Error header with the exception type name and a fingerprint of its location, and the browser records them on the same session and screen instead of the generic error (one event). No message, stack or file paths.