7lab / laravel-kpi
该包已被弃用且不再维护。未建议替代包。
在 Laravel 应用中测量 KPI 统计数据
1.2.1
2021-02-18 09:36 UTC
Requires
- php: ^7.1
- guzzlehttp/guzzle: ^6.3|^7.0
- illuminate/console: ~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- illuminate/database: ~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- illuminate/support: ~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0
- laravel/framework: ~5.6.34|~5.7.0|~5.8.0|^6.0|^7.0|^8.0
Requires (Dev)
- barryvdh/laravel-ide-helper: ^2.7
- fzaninotto/faker: 1.9.1
- orchestra/testbench: ~3.6.0|~3.7.0|~3.8.0|^4.0|^5.0
- phpunit/phpunit: ^7.0|^8.0|^9.0
README
缓存响应
此 Laravel 包注册了一些命令,这些命令会将统计数据推送到指定的 URL。
安装
您可以通过 Composer 安装此包
composer require 7Lab/laravel-kpi
包将自动注册自身。
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="SevenLab\Kpi\KpiServiceProvider"
这是已发布的配置文件的内容 (config/kpi.php
)
return [ /* * Specify the Autorization Bearer token that will be used. */ 'token' => env('LAB_TOKEN'), /* * Specify the base url that will be used. */ 'url' => env('LAB_BASE_URL'), /* * Specify the endpoint that will be used for the KPI stats. */ 'endpoint' => env('KPI_ENDPOINT', ''), /** * Define the number of days we will threat as being 'active' */ 'active_period' => 7, /** * Database columns for the user counts */ 'users_table_name' => env('KPI_USERS_TABLE_NAME', 'users'), /* * Specify the last login column name. */ 'last_login_column_name' => env('KPI_LAST_LOGIN_COLUMN', 'last_login_at'), /** * Enable or disable the stats. */ 'stats_enabled' => env('KPI_ENABLE_STATS', false), ];
运行 php artisan migrate
来运行 last_login_at
的迁移,这允许统计活跃用户数。
使用方法
该包注册了一些命令,这些命令可以被定时执行,或者当然可以手动运行。每个命令都会将统计数据推送到指定的 URL。
统计用户数量
运行以下命令将推送总用户数量的统计到 kpi-endpoint。
php artisan kpi:total-user-count
运行以下命令将推送总活跃用户数量的统计到 kpi-endpoint。
php artisan kpi:active-user-count
运行以下命令将推送总已删除用户数量的统计到 kpi-endpoint。
php artisan kpi:deleted-user-count
这些命令将在每周日午夜12点运行。