identify() public static method

Tags traits about the user.
public static identify ( array $message ) : boolean
$message array
return boolean whether the identify call succeeded
コード例 #1
0
ファイル: SegmentIoStats.php プロジェクト: rukzuk/rukzuk
 /**
  * send summary
  */
 public function sendAll()
 {
     // send properties of a certain user
     foreach ($this->properties as $user => $prop) {
         if (\Segment::identify(array('userId' => $user, 'traits' => $prop, 'context' => array('active' => false, 'ip' => 0)))) {
             // remove submitted property
             unset($this->properties[$user]);
         }
     }
     // track events (of a user)
     foreach ($this->events as $idx => $stat) {
         // ordinary action
         if (\Segment::track(array('userId' => $stat['user'], 'event' => $stat['action'], 'properties' => $stat['additional_info'], 'timestamp' => $stat['time']))) {
             // remove submitted event
             // oh yeah this works in php with foreach (do not try at home with a real language)
             unset($this->events[$idx]);
         }
     }
     return count($this->events) + count($this->properties) === 0;
 }
コード例 #2
0
 function testEmptyArrayTraits()
 {
     $this->assertTrue(Segment::identify(array("userId" => "empty-traits", "traits" => array())));
     $this->assertTrue(Segment::group(array("userId" => "empty-traits", "groupId" => "empty-traits", "traits" => array())));
 }