PHPackages                             branchonline/yii2-eventtracker - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. branchonline/yii2-eventtracker

ActiveYii2-extension[Logging &amp; Monitoring](/categories/logging)

branchonline/yii2-eventtracker
==============================

Extends Yii2 framework with some event and state tracking classes.

2.2(7y ago)13.1k2[1 PRs](https://github.com/BranchOnline/yii2-eventtracker/pulls)BSD-3-ClausePHPPHP &gt;=7.0

Since May 3Pushed 5y ago5 watchersCompare

[ Source](https://github.com/BranchOnline/yii2-eventtracker)[ Packagist](https://packagist.org/packages/branchonline/yii2-eventtracker)[ RSS](/packages/branchonline-yii2-eventtracker/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (2)Versions (9)Used By (0)

Yii2 Eventtracker
=================

[](#yii2-eventtracker)

[![Latest Stable Version](https://camo.githubusercontent.com/39b871b1ddc10920a3024d77582ba8180e130ec08eeb9ef4fcd85343fdfec60e/68747470733a2f2f706f7365722e707567782e6f72672f6272616e63686f6e6c696e652f796969322d6576656e74747261636b65722f762f737461626c65)](https://packagist.org/packages/branchonline/yii2-eventtracker)[![Total Downloads](https://camo.githubusercontent.com/9e96809f6d586a3e8371dfd07e759b25b23487b69d0212dda0455edea0f9d1c3/68747470733a2f2f706f7365722e707567782e6f72672f6272616e63686f6e6c696e652f796969322d6576656e74747261636b65722f646f776e6c6f616473)](https://packagist.org/packages/branchonline/yii2-eventtracker)[![Latest Unstable Version](https://camo.githubusercontent.com/7636765331f1bdae27365066c9acf5ac7c07a746d83e8a0e7a56f946797c69af/68747470733a2f2f706f7365722e707567782e6f72672f6272616e63686f6e6c696e652f796969322d6576656e74747261636b65722f762f756e737461626c65)](https://packagist.org/packages/branchonline/yii2-eventtracker)[![License](https://camo.githubusercontent.com/ccf000f5b484efe25a2640366a97fc8bf0f34bbb577aa27b1fed1a894d335446/68747470733a2f2f706f7365722e707567782e6f72672f6272616e63686f6e6c696e652f796969322d6576656e74747261636b65722f6c6963656e7365)](https://packagist.org/packages/branchonline/yii2-eventtracker)

For now, this package requires you to use yii2 with a **Postgres** database!

The eventtracker package can be used when wanting to keep track of events (happening at a point in time) and state (persisting for some period) information without remodelling your database.

Keep track of events and state information via an application component.

The eventtracker allows extension of tracker functionality by hooking your own additional classes into the core functionality.

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

[](#installation)

Add

```
"branchonline/yii2-eventtracker": "2.0"
```

to your composer.json

Usage
-----

[](#usage)

Adjust the provided migration and make sure to insert the event types and state keys that you want to keep track of. Run the migration.

Create a class that extends `branchonline\eventtracker\EventTypes` and specify the event types as class consts.

Create a class that extends `branchonline\eventtracker\StateKeys` and specify the state keys as class consts.

Add

```
'eventtracker' => [
    'class'        => 'branchonline\eventtracker\EventTracker',
    'types_config' => '', // Class extending EventTypes
    'keys_config'  => '', // Class extending StateKeys
]
```

To your application config.

If you want to add additional processing of events after they are handled, create a class that implements `PostEventInterface` and hook it into the configuration like so

```
'eventtracker' => [
    'class'              => 'branchonline\eventtracker\EventTracker',
    'types_config'       => '', // Class extending EventTypes
    'keys_config'        => '', // Class extending StateKeys
    'post_event_handler' => '' // Your handler class, implementing the PostEventInterface
]
```

Now You can log your events and state by using the application component and do optional post-processing!

Examples
--------

[](#examples)

###### Log an event or a state change

[](#log-an-event-or-a-state-change)

```
// Log that MY_EVENT happened for the current user with the optional data.
Yii::$app->eventtracker->logEvent(EventTypes::MY_EVENT, ['optional' => "data"]);

// Log that the state of MY_KEY changed to ['x' => 100].
Yii::$app->eventtracker->logState(StateKeys::MY_KEY, ['x' => 100]);
```

###### Retrieve events or state

[](#retrieve-events-or-state)

```
// Get the events between 1 jan 2016 and 1 feb 2016 for user 1 and 2 of type MY_EVENT_1 or MY_EVENT_2.
Yii::$app->eventtracker->eventsBetween(
    TrackerTime::fromUnixTimestamp(1451606400),
    TrackerTime::fromUnixTimestamp(1454284800),
    [1, 2],
    [EventTypes::MY_EVENT_1, EventTypes::MY_EVENT_2]
);

// Get the state of MY_KEY_1 and MY_KEY_2 at 1 jan 2016.
Yii::$app->eventtracker->stateAt(
    TrackerTime::fromUnixTimestamp(1451606400),
    [StateKeys::MY_KEY_1, StateKeys::MY_KEY_2]
);
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~201 days

Total

6

Last Release

2703d ago

Major Versions

1.2 → 2.02017-03-23

PHP version history (2 changes)v1.0PHP &gt;=5.4

v1.1PHP &gt;=7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8556324?v=4)[Jap](/maintainers/JapMul)[@JapMul](https://github.com/JapMul)

---

Top Contributors

[![RoelofRuis](https://avatars.githubusercontent.com/u/8556376?v=4)](https://github.com/RoelofRuis "RoelofRuis (1 commits)")[![zelardiel](https://avatars.githubusercontent.com/u/3799399?v=4)](https://github.com/zelardiel "zelardiel (1 commits)")

---

Tags

loggingeventstrackingstateyii2

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/branchonline-yii2-eventtracker/health.svg)

```
[![Health](https://phpackages.com/badges/branchonline-yii2-eventtracker/health.svg)](https://phpackages.com/packages/branchonline-yii2-eventtracker)
```

###  Alternatives

[bedezign/yii2-audit

Yii2 Audit records and displays web/cli requests, database changes, php/js errors and associated data.

200688.7k4](/packages/bedezign-yii2-audit)[mero/yii2-monolog

The Monolog integration for the Yii framework.

41190.0k](/packages/mero-yii2-monolog)

PHPackages © 2026

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