7lab/laravel-kpi

This package is abandoned and no longer maintained. No replacement package was suggested.

Measure KPI statistics in a Laravel application

1.2.1 2021-02-18 09:36 UTC

This package is auto-updated.

Last update: 2023-01-09 13:37:05 UTC


README

Latest Version on Packagist Software License Total Downloads

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.

Credits