1. Go to this page and download the library: Download sitruc/keenio library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sitruc / keenio example snippets
use KeenIO;
KeenIO::addEvent('New Event', ['key' => 'value']);
use KeenIO;
use Sitruc\KeenIO\KeenEvent
$event = new KeenEvent('New Event', ['key' => 'value']);
KeenIO::addEvent($event);
use Sitruc\KeenIO\KeenEvent;
$event = new KeenEvent('New Event', ['key' => 'value']);
$event->send();
use Sitruc\KeenIO\KeenEvent;
$event = new KeenEvent('New Queued Event', ['key' => 'value']);
$event->queued()->send();
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();
use Sitruc\KeenIO\KeenEvent;
$event = new KeenEvent('Keen Event', ['key' => 'value']);
$event->enrichDatetime()
->enrichDatetime('some.other.timestamp.source', 'new.enriched.location')
->send();
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)
namespace App\Http\Controllers;
use App\KeenEvents\NewRegistration;
class UserController
{
public function registerUser()
{
//Register the user.
NewRegistration::from($user)->send();
}
}
namespace App\KeenEvents;
use Sitruc\KeenIO\KeenEvent;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class NewRegistration extends KeenEvent implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
protected $keenTitle = 'New Registration';
protected $user;
public function __construct($user)
{
$this->user = $user;
$this->onQueue('keenio')
->enrichDatetime()
->enrichDatetime('upgrade_date', 'enriched_upgrade_date');
}
public static function from($user)
{
return new static($user);
}
public function keenData()
{
return [
'account_type' => $this->user->accountType,
'upgrade_date' => $this->user->upgradeDate->toAtomString(),
];
}
}