aldeebhasan/laravel-event-tracker
Composer 安装命令:
composer require aldeebhasan/laravel-event-tracker
包简介
A privacy-first Laravel package for tracking conversions, events, and user journeys—100% locally stored. No third-party APIs, no external tracking.
README 文档
README
A simple and flexible Laravel package for tracking events in your application. The laravel-event-tracker package provides an intuitive helper function to log events with minimal setup, abstracting the complexity of event storage and retrieval. It supports multiple drivers (e.g., database, log) and includes Artisan commands to retrieve insightful statistics about your events.
Installation
You can install the package via composer:
composer require aldeebhasan/laravel-event-tracker
You need first to publish and run the migrations with:
php artisan vendor:publish --tag="event-tracker-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="event-tracker-config"
Usage
Track events
After the configuration of the target driver you want to use in the config file (log by default), you can start track your users with the following helpers
track_event(event:"event name",context: [],user: auth()->user())
if you want to use different driver at run time, you can use the tracker helper to configure it.
tracker('database')->track_event(event:"event name",context: [],user: auth()->user())
Alternately, you can use the package facade to call all the event tracker manager functions
\Aldeebhasan\LaravelEventTracker\Facades\EventTracker::driver()->track_event("event name");
View Statistics & Insights
We have four available commands that can tell you the whole story about your events:
- event-tracker:frequency : Show the event frequency bases on specific/all users.
- event-tracker:event-insights : Show the event insights for specific/all events within a specific period of time.
- event-tracker:statistics : Show general statistics about the events and users.
- event-tracker:user-insights : Show the user insights within a specific period of time.
all these commands has 4 input options
php artisan event-tracker:command --from= // Start date (YYYY-MM-DD) and by default is yesterday --to= // End date (YYYY-MM-DD) and by default is today --event= // Specific event name to filter on --user_id=// Specific user id to filter on
Advanced Setup
Custom Tracker
After publishing of the config, you have the ability to change the default trackers implementation, or add your custom tracker. to configure your custom tracker you can define it in the config file as follow:
'drivers' => [ /*'database' => [ 'table' => 'events', 'connection' => 'mysql', ],*/ 'custom' => [ 'implementation' => YourProject\Trackers\CustomTracker::class, 'api-key' => '***********', 'project' => '***********', ], ],
Then you can use the tracker as follow
tracker('custom')->track_event('action.created');
Important
The CustomTracker should implement the TrackerUI interface
Additional Resolvers
In the config file you have a resolver array that contain all the resolver applied on the incoming request to extract data from it. If you want to extract extra info from the current request you can create a new resolver class and add it to the resolver list.
As example: let create a new resolver to extract the host from the request:
class HostResolver implements ResolveUI { public static function resolve(EventTracker $tracker): string { return $tracker->preloadedResolverData['host'] ?? (request()->getHost() ?? ''); } }
Important
The new resolver should implement the ResolveUI interface
The new resolver data will be passed within the $meta param within the track function in all of the tracker implementation.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
aldeebhasan/laravel-event-tracker 适用场景与选型建议
aldeebhasan/laravel-event-tracker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 08 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Hasan Deeb」 「laravel-event-tracker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aldeebhasan/laravel-event-tracker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aldeebhasan/laravel-event-tracker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aldeebhasan/laravel-event-tracker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Modern inventory control for Laravel applications. Features include stock tracking, movement history, low stock alerts, and seamless integration with your existing models
Alfabank REST API integration
Poor man's graphql
It provides a Eloquent query builder that can be used with trait on any model for Laravel project
It provides continents, countries, cities (with div1 and div2) and districts.
It provides an imagable model that can be used with trait on any model for Laravel project
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-05