2017 © Pedro Peláez
 

yii2-extension yii2-eventtracker

Extends Yii2 framework with some event and state tracking classes.

image

branchonline/yii2-eventtracker

Extends Yii2 framework with some event and state tracking classes.

  • Thursday, March 23, 2017
  • by JapMul
  • Repository
  • 3 Watchers
  • 1 Stars
  • 872 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Yii2 Eventtracker

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

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

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., (*3)

Keep track of events and state information via an application component., (*4)

The eventtracker allows extension of tracker functionality by hooking your own additional classes into the core functionality., (*5)

Installation

Add, (*6)

"branchonline/yii2-eventtracker": "2.0"

to your composer.json, (*7)

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., (*8)

Create a class that extends branchonline\eventtracker\EventTypes and specify the event types as class consts., (*9)

Create a class that extends branchonline\eventtracker\StateKeys and specify the state keys as class consts., (*10)

Add, (*11)

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

To your application config., (*12)

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, (*13)

'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!, (*14)

Examples

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
// 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]
);

The Versions

23/03 2017

dev-master

9999999-dev

Extends Yii2 framework with some event and state tracking classes.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roelof Ruis

logging yii2 events tracking state

23/03 2017

2.0

2.0.0.0

Extends Yii2 framework with some event and state tracking classes.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roelof Ruis

logging yii2 events tracking state

28/11 2016

1.2

1.2.0.0

Extends Yii2 framework with some event and state tracking classes.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roelof Ruis

logging yii2 events tracking state

25/11 2016

v1.1

1.1.0.0

Extends Yii2 framework with some event and state tracking classes.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roelof Ruis

logging yii2 events tracking state

03/05 2016

v1.0

1.0.0.0

Extends Yii2 framework with some event and state tracking classes.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Roelof Ruis

logging yii2 events tracking state