otifsolutions/laravel-tracker
Composer 安装命令:
composer require otifsolutions/laravel-tracker
包简介
The Package will track users activity and generate the complete log in database tables
README 文档
README
The Package will track users activity and generate the complete log in database tables
Requirements
php >= 7.4
laravel >= 8.0
Installation
Composer recommended to install package
composer require otifsolutions/laravel-tracker
Now put these middlewares at the end of App\Http\Kernel route middlware group web stack (order of middlewares is important)
\OTIFSolutions\LaravelTracker\Http\Middleware\TrackActivities::class
Or
If you want your certain group of routes to be tracked, apply the middleware to the route group in web.php like
use OTIFSolutions\LaravelTracker\Http\Middleware\TrackActivities; Route::middleware([TrackActivities::class])->group(static function () { // your routes to be tracked });
and then run migrations by
php artisan migrate
Defaults
The package is enabled by default, once it is installed, it will start logging/tracking your site visits into database tables. To check what default settings are, see OTIFSolutions\LaravelTracker\Traits\UtilityMethods class constructor
$this->trackerStatus = Setting::get('tracker_status') ?: true; $this->trackCookies = Setting::get('track_cookies') ?: false; $this->trackMiscData = Setting::get('track_misc_data') ?: false; $this->trackHttpRequests = Setting::get('track_http_requests') ?: true;
Remember ( If key tracker_status is false then no other key will work and won't track anything )
Package made database table hold records of certain days, and removes the rest of the data,
by default it is set to 20 days, you can either change this too by
\OTIFSolutions\Laravel\Settings\Models\Setting::set('keep_except', $numDays);
Set your own keys
You can use your keys and values using laravel tinker (php artisan tinker) by setting keyName and value,
here are the keys track_cookies, tracker_status, track_misc_data, track_http_requests, these keys hold
boolean values only, so remember to add third parameter as 'bool'
\OTIFSolutions\Laravel\Settings\Models\Setting::set('your_key', $trueFalse, 'bool');
Clearing old data
Data is generated on every page hit by user, at the end we have bulk of data,
we have command to remove that data data, which is sheduled to be executed after 30 days
at 08::00 AM and time will be started when package will be installed, though we can run
this command manually anytime to remove the data (before set days, default is 20)
php artisan clear:records
Note
In Linux environments, sometimes, when you install a package, it wants some permissions for package to work, like laravel.log and storage etc residing in laravel project. You have to grant it permissions by running this command inside your laravel proejct , for debian based linux distros like Ubuntu
for all files in project
sudo chmod -R 0777 *
for certain single file
sudo chmod -R 0777 file
where file is absolute path to the file
Relationships defined between Models
UserSession is the parent model. It has one-to-many relation with UserActivity, one-to-many relation with RequestData, one-to-many relation with MyCookie and one-to-many relation with MiscData.
Licence
The MIT License (MIT). Please see License file for more information
otifsolutions/laravel-tracker 适用场景与选型建议
otifsolutions/laravel-tracker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 otifsolutions/laravel-tracker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 otifsolutions/laravel-tracker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-07