zinxan / native-web
Error tracking for Laravel websites and web apps, reported to NativeWatch.
Requires
- php: ^8.4
- zinxan/native-core: ^0.2.3
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pint: ^1.27
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.8|^4.0|^5.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0|^5.0
- pestphp/pest-plugin-type-coverage: ^3.0|^4.0|^5.0
Suggests
None
Provides
None
Conflicts
Replaces
None
README
Error tracking for Laravel websites and web apps. Errors go to NativeWatch.
composer require zinxan/native-web
Add the Server client key of your NativeWatch project to .env (never embed a Server key in public HTML):
NATIVEWATCH_KEY=nw_... NATIVEWATCH_URL=https://native.watch
Send a test error:
php artisan nativewatch:test
Browser errors and consent on multi-user websites
To capture browser JavaScript errors and unhandled promise rejections from your Laravel pages, add @nativewatchScripts to your root Blade layout's <head> before your frontend scripts. On web projects, /_nativewatch/browser-errors requires positive same-origin Origin/Referer headers by default, strips query strings and fragments from page and frame URLs, and reports errors with the browser and browser.unhandledrejection mechanisms. You can add 'web' middleware (session/CSRF) to nativewatch.browser.middleware in config/nativewatch.php if desired.
Because websites serve multiple visitors from one server, zinxan/native-web deliberately disables native-core's single-device on-disk FileConsent store so one visitor cannot change consent or clear the outbox for others. Gate per-visitor consent with NativeWatch::beforeSend() or conditionally render @nativewatchScripts from your app's own cookie/session consent state.
Request scope, deduplication cache, and per-request beforeSend callbacks reset automatically between requests (including Laravel Octane workers), while boot-time beforeSend hooks registered in service providers are preserved.
For static or non-Laravel websites, use NativeWatch's hosted browser script (https://native.watch/sdk/browser.js) with a dedicated Browser client key and your site's allowed origins configured in NativeWatch.