PHPackages                             sitruc/keenio - 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. [API Development](/categories/api)
4. /
5. sitruc/keenio

ActiveLibrary[API Development](/categories/api)

sitruc/keenio
=============

A convenient wrapper around the Keen.io API for Laravel

1.0.11(6y ago)12.8kMITPHPPHP ^7.0CI failing

Since Apr 24Pushed 6y ago2 watchersCompare

[ Source](https://github.com/cthorne91/KeenIO)[ Packagist](https://packagist.org/packages/sitruc/keenio)[ RSS](/packages/sitruc-keenio/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (15)Used By (0)

[![Latest Version](https://camo.githubusercontent.com/8e79aa641db12fa2b195bec20914fd5a0dadeb3f2e4164fdcd1288d77515e8f6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6374686f726e6539312f4b65656e494f2e7376673f7374796c653d666c61742d737175617265)](https://github.com/cthorne91/KeenIO/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/0fad1a7d08477bd8ce4a09813d7f1e82fc0981fe9df656a6fc72a32948afff02/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369747275632f6b65656e696f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sitruc/keenio)

A convenient wrapper around the Keen.io PHP SDK for Laravel
===========================================================

[](#a-convenient-wrapper-around-the-keenio-php-sdk-for-laravel)

Using this package you can send events to keen.io in laravel elegance. Here are a few examples from basic to elegant.

The most basic example, using the facade which accepts both a KeenEvent or the name and data directly.

```
use KeenIO;

KeenIO::addEvent('New Event', ['key' => 'value']);
```

Or pass a KeenEvent

```
use KeenIO;
use Sitruc\KeenIO\KeenEvent

$event = new KeenEvent('New Event', ['key' => 'value']);

KeenIO::addEvent($event);
```

If you prefer, you can send the event directly.

```
use Sitruc\KeenIO\KeenEvent;

$event = new KeenEvent('New Event', ['key' => 'value']);

$event->send();
```

Queuing events.

```
use Sitruc\KeenIO\KeenEvent;

$event = new KeenEvent('New Queued Event', ['key' => 'value']);

$event->queued()->send();
```

Use keen.io's data enrichment.

```
use Sitruc\KeenIO\KeenEvent;

$event = new KeenEvent('New Event', ['key' => 'value']);

//Enriches keen's default keen.timestamp value into enriched_timestamp
$event->enrichDatetime();

$event->enrichDatetime('some.other.timestamp.source', 'new.enriched.location');

$event->send();
```

Methods are fluent so the above example can become.

```
use Sitruc\KeenIO\KeenEvent;

$event = new KeenEvent('Keen Event', ['key' => 'value']);

$event->enrichDatetime()
      ->enrichDatetime('some.other.timestamp.source', 'new.enriched.location')
      ->send();
```

The following enrichment values are accepted. You can read more about data enrichment, also known as 'Add Ons' [in the keen.io documentation](https://keen.io/docs/api/#ip-to-geo-parser)

```
public function enrichDatetime($source = 'keen.timestamp', $destination = 'enriched_timestamp')

public function enrichIPAddress($source, $destination = 'ip_geo_info')

public function enrichUserAgent($source, $destination = 'parsed_user_agent')

public function enrichURL($source, $destination)

public function enrichReferrer($referrer_url_input, $page_url_input, $destination)
```

Subclassing KeenEvent can be even more powerful.

Behind the scenes this packages uses laravel's dispatch handler. This means you can implement the `ShouldQueue` interface and dispatch onto specific queues just like you would any other job.

Here is an example of reporting a registration event on a keenio queue with enriched created\_at and upgrade\_date. Simple and elegant!

```
