Last active
June 23, 2022 23:35
-
-
Save yatsenkolesh/f31825a197d45aa9768655fc3f739dbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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