コード例 #1
0
ファイル: EventTest.php プロジェクト: zumba/amplitude-php
 public function testSetUserProperties()
 {
     $userProps = ['dob' => 'tomorrow', 'gender' => 'f'];
     $event = new Event();
     $event->setUserProperties($userProps);
     $this->assertSame(['user_properties' => $userProps], $event->toArray(), 'Should set user properties in user_properties');
     $userProps2 = ['dob' => 'yesterday', 'name' => 'Baby'];
     $expected = ['dob' => 'yesterday', 'gender' => 'f', 'name' => 'Baby'];
     $event->setUserProperties($userProps2);
     $this->assertSame(['user_properties' => $expected], $event->toArray(), 'Second call to setUserProperties should update properties, not remove existing');
 }
コード例 #2
0
ファイル: Amplitude.php プロジェクト: zumba/amplitude-php
 /**
  * Gets the event that will be used for the next event logged by call to logEvent() or queueEvent()
  *
  * You can also pass in an event or array of event properties.  If you pass in an event, it will be set as the
  * event to be used for the next call to queueEvent() or logEvent()
  *
  * @param null|array|\Zumba\Amplitude\Event Can pass in an event to set as the next event to run, or array to set
  *   properties on that event
  * @return \Zumba\Amplitude\Event
  */
 public function event($event = null)
 {
     if (!empty($event) && $event instanceof \Zumba\Amplitude\Event) {
         $this->event = $event;
     } elseif (empty($this->event)) {
         // Set the values that persist between tracking events
         $this->event = new Event();
     }
     if (!empty($event) && is_array($event)) {
         // Set properties on the event
         $this->event->set($event);
     }
     return $this->event;
 }