PHPackages                             kakaprodo/system-analytic - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kakaprodo/system-analytic

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kakaprodo/system-analytic
=========================

A laravel package that simplifies the collection and visualization of your system analytics.

v1.3.6(11mo ago)13.0kMITPHPPHP &gt;=8.0

Since Apr 24Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/kakaprodo/system-analytic)[ Packagist](https://packagist.org/packages/kakaprodo/system-analytic)[ RSS](/packages/kakaprodo-system-analytic/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (32)Used By (0)

system-analytic
===============

[](#system-analytic)

A laravel package that simplifies the collection and visualization of your system analytics

[OFFICIAL DOCUMENTATION](https://yupidoc.com/projects/system-analytic/preview)
==============================================================================

[](#official-documentation)

Find more details about this package visit the page: [System-Analytic](https://yupidoc.com/projects/system-analytic/preview)

```
use Kakaprodo\SystemAnalytic\AnalyticGate;

AnalyticGate::process([
    'analytic_type' => 'new-user-bar-chart',
    'scope_type' => 'this_week',// last_week, last_year,last_month,range_date, range_year ...
]);
```

1. Prerequisites
----------------

[](#1-prerequisites)

- php &gt;= 7
- kakaprodo/custom-data package

2. Installation
---------------

[](#2-installation)

```
 composer require kakaprodo/system-analytic
```

3. Publishing Skeleton
----------------------

[](#3-publishing-skeleton)

- ### Config file

    [](#config-file)

    ```
    php artisan system-analytic:config
    ```

    The above command will create the configuration file with name `system-analytic.php` in the config folder.
- ### Skeleton files

    [](#skeleton-files)

    At this point you can open the `system-analytic.php` file in the config folder. From there you can review all the settings, and customize them according to your desire. Then run the bellow command to create the analytic `Hub`:

    ```
    php artisan system-analytic:install
    ```

After running the above command, a new folder will be created in your app/Http folder(by default) and in the app/Http/Requests folder. in the next section you are going to discover the magic that will be happening in these files. Put your shoes on 🤪

4. Your First Analytic class(handler)
-------------------------------------

[](#4-your-first-analytic-classhandler)

### 1. Create a handler

[](#1-create-a-handler)

To generate the analytic class, you will need to run the bellow command:

```
php artisan system-analytic:handler NewUserBarChart --bar-chart
```

A bellow handler will be created, now let's explain this:

```
class NewUserBarChart extends BlockChart
{
    protected function boot()
    {
    }

    protected function query()
    {
        return DB::table('example')
    }

    protected function result(LazyCollection $groupedResult): AnalyticResponse
    {
        return $this->response($groupedResult->all());
    }
}
```

As you can see,we have three magic methods and very important to understand:

- `boot`: the method that you can use as the construct of your handler
- `query`: the core of your class, this method will return the value that the package will use to filter data based on the request scope.
- `result`: Will return data on which all filters have been applied, and it is formatted based on the handler type(BarChart).

### 2. Define Basic query In the Handler

[](#2-define-basic-query-in-the-handler)

Now we have our handler, let's give it a sens, so that it can return the block chart data of new users of the system

```
class NewUserBarChart extends BlockChart
{
    protected $scopeColumn = "users.created_at";

    protected $groupBy = "created_at";

    protected function boot()
    {
    }

    protected function query()
    {
        return DB::table('users')->orderBy('id');
    }

    protected function result(LazyCollection $groupedUsersByCreatedAt): AnalyticResponse
    {
        $result = $groupedUsersByCreatedAt->map(function ($users) {
            return $users->count();
        });

        return $this->response($result->all());
    }
}
```

Now we have our handler that returns number of the new users at each date. Note that you can make any logic of your choice to your query and that will work.

### 3. Register the handler class

[](#3-register-the-handler-class)

Now you have your handler ready to be used. To register your handler you need to open the `AnalyticHandlerRegister` class and register it under the `handlers` method. you will see this class in the analytic skeleton folder that we have created early in this doc.

```
class AnalyticHandlerRegister extends AnalyticHandlerRegisterBase
{
    /**
     * register a key value array of your handlers,
     * where the key is the analytic_type and the value
     * is the actual handler
     */
    public static function handlers(): array
    {
        return [
            NewUserBarChart::type() => NewUserBarChart::class,
        ];
    }
}
```

You can see, we have used `NewUserBarChart::type()` , the `type` method will automatically return the kebak case of the name of your handler class. so if you think you will have multiple handlers with the same names, then you can specify your own names at the place of `NewUserBarChart::type()`.

### 3. Using the handler class

[](#3-using-the-handler-class)

Now to call the handler , we will be using the class `AnalyticGate` and the registered name of your handler. Note that, the `AnalyticGate` is the gate to all registered handlers.

```
use Kakaprodo\SystemAnalytic\AnalyticGate;

AnalyticGate::process([
    'analytic_type' => 'new-user-bar-chart',// NewUserBarChart::type()
    'scope_type' => 'this_week',// last_week, last_year,last_month ...
]);
```

VERY SIMPLE RIGHT ???🤪🤪🤪🤪🤪🤪🤪!!!

Now from the above code, we have used only two options among the list of options supported by the `AnalyticGate` class. here other options you can use

```
 $options = [
    'scope_value' => date based on the scope_type,
    'scope_from_date' => date or dateTime based on your need,
    'scope_to_date' => date or dateTime based on your need,
    'search_value' => string or Array,
    'should_export' => Bool,
    'file_type' => string between [csv,xlsx],
    'selected_option' => string,
    'should_clear_cache' => Bool
 ];
```

Now i know, you are asking yourself why this dude didn't finish the documentation. 😜Man, i can not put everything here but trust me, i'm working on the full documentation and you will be the first to know about it once i finish. now high five 🖐✋🏾.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance52

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~37 days

Total

30

Last Release

332d ago

PHP version history (2 changes)v1.1.1PHP &gt;=7.0

v1.2.2PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/988cbdacb19b632229a0cf2746b84b6cdbd4a81624b86a5ad4b1e27db48778a3?d=identicon)[kakaprodo](/maintainers/kakaprodo)

---

Top Contributors

[![kakaprodo](https://avatars.githubusercontent.com/u/30261670?v=4)](https://github.com/kakaprodo "kakaprodo (115 commits)")

---

Tags

phppackageanalyticphp-metricslaravel-metricskakaprodosystem analyticlaravel analyticpromesse kayengaphp analytic

### Embed Badge

![Health badge](/badges/kakaprodo-system-analytic/health.svg)

```
[![Health](https://phpackages.com/badges/kakaprodo-system-analytic/health.svg)](https://phpackages.com/packages/kakaprodo-system-analytic)
```

###  Alternatives

[nunomaduro/essentials

Just better defaults for your Laravel projects.

1.2k317.5k51](/packages/nunomaduro-essentials)[wujunze/money-wrapper

MoneyPHP Wrapper

113.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
