devdavido/laravel-reporto

使用W3C Reporting API将浏览器错误记录到服务器

1.8 2024-05-10 13:30 UTC

This package is auto-updated.

Last update: 2024-09-10 14:26:06 UTC


README

Latest Version Build Status Code Coverage Total Downloads

此包利用了W3C Reporting API,并为您的现有项目提供了一个易于安装的包。它将自动添加必要的Report HTTP头,并将所有配置的浏览器错误记录到您的Laravel后端。

文档

使用此包遇到困难?发现了一个bug?或者您对此包有一般性的问题或改进建议?请随时在GitHub上创建问题,我们会尽快处理。

如果您发现了关于安全的bug,请通过邮件github{at}diskoboss{døt}de联系,而不是使用问题跟踪器。

最低要求

  • PHP 8.0+
  • Laravel 9+

为了支持较老的PHP / Laravel版本,请查看此包的先前版本。

安装

您可以使用以下命令通过composer安装此包

composer require devdavido/laravel-reporto

此包将自动注册自身并添加一个Report-To头到您的web路由中。每个错误或违规都会记录到后端。

您可以使用以下命令发布配置文件

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

这是发布配置文件的内容

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'
];

支持我

如果您安装了此包并且它对您或您的业务有用,请不要犹豫,进行捐赠(因为我是一名学生)。谢谢!

Buy me a coffee

测试

您可以使用以下命令运行测试

vendor/bin/phpunit

想法 / 待办事项

  • 通过电子邮件发送每日/每周报告
  • 多个端点
  • 更多单元测试

变更日志

请参阅变更日志以了解最近发生了什么变化。

安全性

如果您发现了任何与安全相关的问题,请通过电子邮件github{at}diskoboss{døt}de联系,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。