devdavido/laravel-reporto

Log browser errors to the server using W3C Reporting API

1.8 2024-05-10 13:30 UTC

This package is auto-updated.

Last update: 2024-12-10 15:06:19 UTC


README

Latest Version Build Status Code Coverage Total Downloads

This package makes use of the W3C Reporting API and provides an easy plug-and-play package for your existing project. It will automatically add the necessary Report HTTP headers and log all configured browser errors to your Laravel backend.

Documentation

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving this package? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a bug regarding security please mail github{at}diskoboss{døt}de instead of using the issue tracker.

Minimum requirements

  • PHP 8.0+
  • Laravel 9+

For support of older PHP / Laravel versions, check out previous releases of this package.

Installation

You can install this package via composer using this command:

composer require devdavido/laravel-reporto

The package will automatically register itself and add a Report-To header to your web routes. Each error or violation will be logged to the backend.

You can publish the config-file with:

php artisan vendor:publish --provider="DevDavido\Reporto\ReportoServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    /*
     * Use this setting to enable the reporting API header
     */
    'enabled' => env('REPORTING_API_ENABLED', true),

    /*
     * Enables the reporting API for all subdomains
     */
    'include_subdomains' => env('REPORTING_API_INCLUDE_SUBDOMAINS', false),

    /*
     * Exclude certain source files from being logged
     */
    'exclude_source_files' => env('REPORTING_API_EXCLUDE_SOURCE_FILES', ['chrome-extension://*']),

    /*
     * Defines cached lifetime of all endpoint in seconds (86400s = 1 day)
     */
    'endpoint_max_age' => env('REPORTING_API_MAX_AGE', 86400),

    /*
     * Which types of browser errors to report
     * @see https://w3c.github.io/reporting/
     */
    'groups' => [
        'default',
        'csp-endpoint',
        'network-errors'
    ],

    /*
     * If you want to set the logging route prefix
     */
    'route_prefix' => 'log'
];

Support me

If you installed the package and it was useful for you or your business, please don't hesitate to make a donation (as I am a student). Thank you!

Buy me a coffee

Testing

You can run the tests with:

vendor/bin/phpunit

Ideas / ToDo

  • Daily/weekly reports via email
  • Multiple endpoints
  • More unit tests

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email github{at}diskoboss{døt}de instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.