ads / statistics
跟踪基本用户信息,以生成页面使用情况的统计数据。同时也提供额外的信息来调试500错误
3.0.15
2024-03-26 18:29 UTC
Requires
- php: ^7.3|^8.0|^8.1|^8.2|^8.3
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
This package is auto-updated.
Last update: 2024-09-26 19:43:09 UTC
README
Laravel的审计/错误日志模块
该模块将跟踪相关网站的 所有用户的页面浏览历史。模块将记录500错误统计信息以帮助调试代码。此外,表单提交的发布数据将被保存在数据库中。设置文件中有一个数组选项,允许您从跟踪表中删除要保存的敏感文件。
一旦配置完成,此插件将自动将页面浏览历史保存到数据库中。
(如果更新,请确保运行 "php artisan migrate")
步骤 1
设置composer,将包添加到您的require标签中
composer require ads/statistics
步骤 2
发布并运行迁移
php artisan vendor:publish --provider=Ads\\Statistics\\StatisticsServiceProvider
php artisan migrate
步骤 3
在 app\Http\Kernel.php
中将统计日志添加到 'web' 中间件
protected $middlewareGroups = [
'web' => [
...
\Ads\Statistics\Statistic::class,
],
步骤 4
为了记录500错误,您需要向 app/Exceptions/Handler.php 中添加一些代码。在 register 函数中添加此拦截器。在返回之前将 report 函数添加到或创建它
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
$this->reportable(function (\Exception $e) {
\Statistic::error($e);
});
}
* 步骤 5 仅在您有用户身份验证时必要
步骤 5
编辑 config/statistics.php 文件。
请输入您用户数据库表中的列名。
例如
'user_id' => 'email',
'first_name' => 'first_name',
'last_name' => 'last_name',
'protected_fields' => ['password'],