Skip to content

feat: add browser capture presets for Inertia.js, Hotwire Turbo, htmx and Vite - #96

Merged
geodro merged 5 commits into
lerd-env:mainfrom
ExeQue:feat/browser-presets
Oct 6, 2026
Merged

geodro merged 5 commits into
lerd-env:mainfrom
ExeQue:feat/browser-presets

Conversation

@ExeQue

@ExeQue ExeQue commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

This adds the first browser capture presets, for lerd-env/lerd#2094. A preset lists the DOM events a frontend library fires when something fails, together with the composer and npm packages that show a project uses the library, and lerd offers the detected ones in a site's Browser settings with one click. The presets live in a new browser/ directory beside packages/, and index.json gains a browser_presets list naming them, so binaries that predate browser capture never look at either.

Inertia.js reports inertia:invalid and inertia:exception, Hotwire Turbo turbo:fetch-request-error and turbo:frame-missing, htmx its response, send and swap errors, and Vite vite:preloadError for a chunk that failed to load. A preset holds only event names and dot paths into the event, never code, since the capture script runs on every page of a site.

Refs lerd-env/lerd#2089

… and Vite

Browser capture presets live in a new browser directory beside packages, and index.json lists them under browser_presets, so binaries that predate browser capture never read either. Each preset names the DOM events a frontend library fires when something fails and the composer and npm packages that show a project uses it.
@ExeQue
ExeQue requested a review from a team as a code owner October 4, 2026 14:39
ExeQue added 3 commits October 5, 2026 18:32
…ship them

The presets move out of their own browser directory into packages, where lerd already detects what a project uses. A package definition can now say it is an npm package with an optional type, composer staying the default, and declare the DOM events its library fires in a browser block, which names the preset it belongs to so the Inertia, Turbo, htmx and Vite packages that share one are offered as one. npm packages are listed in the index with their type and live under an npm- prefix, so a name can never collide with a composer package.

An older lerd only looks a package up once composer has installed it, which an npm name never is, and reads a composer package's file without the keys it does not know, so none of this reaches a version that cannot use it.
A released lerd fetches every entry of packages on lerd update and refuses a name composer could not publish, so the npm entries would have counted as failed refreshes on every install. They move to npm_packages, a key no released lerd reads, and the files keep their type and their place in packages.
Every lerd since the package layer fetches each entry of packages on lerd update and refuses a name composer could not publish, so such an entry would fail a refresh on every install. The README says why at the rule for listing a package, and the schema guard now refuses one, pointing at a key of its own such as npm_packages.
@geodro

geodro commented Oct 6, 2026

Copy link
Copy Markdown
Member

@ExeQue one change here to go with the lerd side, the Inertia presets should use message: detail.response instead of detail.response.status, in both inertiajs-inertia-laravel.yaml and the npm-inertiajs files. lerd now prints an axios response as status, method and URL, so you get something like 500 GET https://site.test/some/route instead of just 500.

The Inertia presets read only detail.response.status, so an invalid response arrived as a bare 500. lerd now prints the axios response Inertia hands its events as its status, method and URL, so the presets point at detail.response and the dashboard shows which request failed, like 500 GET https://site.test/some/route.
@geodro
geodro merged commit 41dc7ec into lerd-env:main Oct 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants