PHPackages                             adelinferaru/nestedflowtracker - 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. adelinferaru/nestedflowtracker

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

adelinferaru/nestedflowtracker
==============================

Laravel package that helps tracking nested execution flows.

1.0(6y ago)03.1kMITPHPCI failing

Since Nov 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/adelinferaru/nestedflowtracker)[ Packagist](https://packagist.org/packages/adelinferaru/nestedflowtracker)[ Docs](https://github.com/adelinferaru/nestedflowtracker)[ RSS](/packages/adelinferaru-nestedflowtracker/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (6)Versions (4)Used By (0)

NestedFlowTracker
=================

[](#nestedflowtracker)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5ee517618f2f5ab2bbe9e250cf814d1985dd661698a912fc6beba7d7c75bec0f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6164656c696e6665726172752f6e6573746564666c6f77747261636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adelinferaru/nestedflowtracker)[![Total Downloads](https://camo.githubusercontent.com/6a65e7a560793c1dc70e568c49e82d6276d26d1470353bd93b8ad9854f2fd901/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6164656c696e6665726172752f6e6573746564666c6f77747261636b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/adelinferaru/nestedflowtracker)[![Build Status](https://camo.githubusercontent.com/4ba06c5489f84ab794c3236be4804767a17ee05dded0cb344bbbf9bb85a9da8b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6164656c696e6665726172752f6e6573746564666c6f77747261636b65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/adelinferaru/nestedflowtracker)[![StyleCI](https://camo.githubusercontent.com/cb13a877afd1dbe223c631789c3f922d3ace958fdb334a9cce9b26afefbc2ebd/68747470733a2f2f7374796c6563692e696f2f7265706f732f31323334353637382f736869656c64)](https://styleci.io/repos/12345678)

This Laravel package allows metering the time spent from a start point to an end point in the code.

Take a look at [contributing.md](contributing.md) to see a to do list.

Installation
------------

[](#installation)

Via Composer

```
$ composer require adelinferaru/nestedflowtracker
```

Configuration
-------------

[](#configuration)

**1. Publish the configuration file**

`> php artisan vendor:publish --provider="AdelinFeraru\NestedFlowTracker\NestedFlowTrackerServiceProvider" --tag="nestedflowtracker.config"`

**2. Publish migration files**

`> php artisan vendor:publish --provider="AdelinFeraru\NestedFlowTracker\NestedFlowTrackerServiceProvider" --tag="nestedflowtracker.migrations"`

**3. Setup environmental variables**

The package requires that you setup two environmental variables. Edit .env and add the following:

`FLOW_TRACKER_COMPONENT="default-component-name"`

`FLOW_TRACKER_DB_CONNECTION=default`

The **`FLOW_TRACKER_COMPONENT`** variable represents the name of the current application and when the package is used to track a user flow that spans multiple applications it is very usefull in understanding which one of the applicantions was reporting a specific tracking record.

The **`FLOW_TRACKER_DB_CONNECTION`** variable will specify the name of the database connection used to write the tracking records to. If you are not using the `default`, you must define, in `config/database.php`, a new DB connection to be used by NestedFlowTracker.

Example:

```
...
'nestedflowtracker' => [
            'driver' => 'mysql',
            'host' => env('FLOW_TRACKER_DB_HOST', '127.0.0.1'),
            'port' => env('FLOW_TRACKER_DB_PORT', '3306'),
            'database' => env('FLOW_TRACKER_DB_DATABASE', 'my_external_db'),
            'username' => env('FLOW_TRACKER_DB_USERNAME', 'root'),
            'password' => env('FLOW_TRACKER_DB_PASSWORD', 'secret'),
            'unix_socket' => env('FLOW_TRACKER_DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('FLOW_TRACKER_MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],
...

```

Now in .env file you will have:

`FLOW_TRACKER_DB_CONNECTION=nestedflowtracker`

Usage
-----

[](#usage)

Mostly you will be using 2 class static methods:

`$track_model = NestedFlowTracker::startTrack($timer_name, $message = null, array $setting = []);`

`NestedFlowTracker::endTrack($timer_name, array $setting = []);`

**$settings** array might contain the following:

- tracker\_id : the unique identifier of the whole flow (spanning multiple apps)
- user\_id: the user\_id of the user performing the flow or on whose behalf is the flow
- component: overwrite the default component/app name defined in the .env file when needed
- message: overwrite the message (usefull in ::endTask)
- context: specify a context
- result: pass in a result
- parent\_id: programatically specify a the id of a parent tracker

**Note:** The `NestedFlowTracker::startTrack` method is returning a Model that is implementing the Nested Set.

**Note:** The startTrack / endTrack mark the begining and the end of SUB-FLOW.

```
startTrack -------------------------> root:
    startTrack ---------------------> child 1
        startTrack -----------------> child 1.1
        endTrack

        startTrack -----------------> child 1.2
        endTrack
    endTrack

    startTrack ---------------------> child 2
        startTrack -----------------> child 2.1
        endTrack
    endTrack
endTrack

```

When making an API call to another app that is part of the flow and might need to track its own internal flow, you can pass the following vars:

- `"tracker_id" => NestedFlowTracker::getTrackerId(),`
- `"tracker_parent_id" => $current_tracker->id,`

```
...
public static function doSomething($data) {
    $tracker_parent_id = $data['tracker_parent_id] ?? null;
    $tracker_id = $data['tracker_id] ?? NestedFlowTracker::getTrackerId();

    $doSomething_timer = "Meter my doSomething";
    $track = NestedFlowTracker::startTrack($doSomething_timer,
                                           "Track my doSomething function",
                                            [
                                                'context' => [],
                                                'user_id' => $data['user_id'],

                                                // "tracker_id" to be used only at the begining of a flow
                                                //'tracker_id' => $tracker_id,

                                                // "parent_id"  to be used only at the begining of a flow
                                                //'parent_id' => $tracker_parent_id
                                            ]);

    $result = [
        'success' => 1,
        'message' => null
    ];
    ...
    ...
    some code that the function does
    ...
    // Supposedly we'll call another function that we want to track as a child of the already existing tracker "$track"

    $processData_timer = "Meter my processData";
    $track2 = NestedFlowTracker::starTrack($processData_timer, "Process my data");

    // Call another function to do something with data
    $new_data = $this->processData($data);

    NestedFlowTracker::endTrack($processData_timer);

    if($new_data) $result['success'] = 1;
    ...
    ...

    NestedFlowTracker::endTrack($doSomething_timer, ['result' => $result]);

    return $result;
}
...

```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Feraru Ioan Adelin](https://github.com/adelinferaru)
- [All Contributors](../../contributors)

License
-------

[](#license)

license. Please see the [license file](license.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~67 days

Total

3

Last Release

2226d ago

Major Versions

v1.x-dev → v2.x-dev2020-04-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4851269?v=4)[Feraru Ioan Adelin](/maintainers/adelinferaru)[@adelinferaru](https://github.com/adelinferaru)

---

Top Contributors

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

---

Tags

laravelNestedFlowTracker

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adelinferaru-nestedflowtracker/health.svg)

```
[![Health](https://phpackages.com/badges/adelinferaru-nestedflowtracker/health.svg)](https://phpackages.com/packages/adelinferaru-nestedflowtracker)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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