Skip to content

Instantly share code, notes, and snippets.

@yatsenkolesh
Last active June 23, 2022 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatsenkolesh/f31825a197d45aa9768655fc3f739dbc to your computer and use it in GitHub Desktop.
Save yatsenkolesh/f31825a197d45aa9768655fc3f739dbc to your computer and use it in GitHub Desktop.
<?php
use Abrouter\Client\Config\Config;
use DI\ContainerBuilder;
use Abrouter\Client\Client;
use Abrouter\Client\Builders\StatEventBuilder;
require '/app/vendor/autoload.php';
$userId = $_SESSION['user_id'] ?? uniqid();
$containerBuilder = new ContainerBuilder();
$di = $containerBuilder->build();
/**
* @var Client $client
*/
$client = $di->make(Abrouter\Client\Client::class); // using PHP-DI
$eventBuilder = $this->getContainer()->make(StatEventBuilder::class);
//sending button_click event as button_click+1
$client->statistics()->sendEvent(
$eventBuilder
->incremental()
->event('button_click')
->setUserId($userId)
->build()
);
// sending purchase event with purchase amount
$client->statistics()->sendEvent(
$eventBuilder
->summarize()
->event('purchase')
->setValue(30)
->setUserId($userId)
->build()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment