track() public method

Tracks a user action
public track ( array $message ) : [boolean]
$message array
return [boolean]
Esempio n. 1
0
 function testProductionProblems()
 {
     # Open to a place where we should not have write access.
     $client = new Segment_Client("oq0vdlg7yi", array("consumer" => "file", "filename" => "/dev/xxxxxxx"));
     $tracked = $client->track(array("userId" => "some-user", "event" => "my event"));
     $this->assertFalse($tracked);
 }
 /**
  * @expectedException \RuntimeException
  */
 function testConnectionError()
 {
     $client = new Segment_Client("x", array("consumer" => "socket", "host" => "api.segment.ioooooo", "error_handler" => function ($errno, $errmsg) {
         throw new \RuntimeException($errmsg, $errno);
     }));
     $client->track(array("user_id" => "some-user", "event" => "Event"));
     $client->__destruct();
 }
 function testLargeMessage()
 {
     $options = array("debug" => true, "consumer" => "socket");
     $client = new Segment_Client("testsecret", $options);
     $big_property = "";
     for ($i = 0; $i < 10000; $i++) {
         $big_property .= "a";
     }
     $this->assertTrue($client->track(array("userId" => "some-user", "event" => "Super Large PHP Event", "properties" => array("big_property" => $big_property))));
     $client->__destruct();
 }
 function testNotPersistentTocken()
 {
     date_default_timezone_set("UTC");
     $client = new Segment_Client("oq0vdlg7yi", array("consumer" => "socket", "persistent_socket" => false));
     $this->assertTrue($client->track(array("userId" => "some-user", "event" => "Socket PHP Event")));
 }