7lab / laravel-kpi
Measure KPI statistics in a Laravel application
Installs: 1 767
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
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
Cache responses
This Laravel package registers some commands which will push a statistic to the specified URL.
Installation
You can install the package via Composer:
composer require 7Lab/laravel-kpi
The package will automatically register itself.
You can publish the config file with:
php artisan vendor:publish --provider="SevenLab\Kpi\KpiServiceProvider"
This is the contents of the published config file (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), ];
Run php artisan migrate
to run the migrations for last_login_at
which allows the count of active users.
Usage
The package registers some commands which can be scheduled or can be run manually of course. Each command will push a statistic to the specified URL.
Counting the count of users
Running the command below will push the count of total amount users to the kpi-endpoint.
php artisan kpi:total-user-count
Running the command below will push the count of total active users to the kpi-endpoint.
php artisan kpi:active-user-count
Running the command below will push the count of total deleted users to the kpi-endpoint.
php artisan kpi:deleted-user-count
These commands will run weekly on sunday 12am.