diff --git a/src/Producers/People.php b/src/Producers/People.php index 32cc296..d2e85e0 100644 --- a/src/Producers/People.php +++ b/src/Producers/People.php @@ -48,16 +48,17 @@ public function identify($identifier) { return $this->_people_id; } - if(empty($this->_visitor_id)) { - throw new Exception('Empty visitor_id.'); - } - $this->_transport->setEndpoint('people/identify'); - $response = $this->_transport->execute([ - 'visitor_id' => $this->_visitor_id, + $data = [ 'identifier' => $identifier - ]); + ]; + + if(!empty($this->_visitor_id)) { + $data['visitor_id'] = $this->_visitor_id; + } + + $response = $this->_transport->execute($data); $this->_people = $response['people']; @@ -79,6 +80,12 @@ public function set(array $args) { } } + if(empty($this->get()['id'])) { + if(!empty($this->_identifier)) { + $this->identify($this->_identifier); + } + } + $this->_transport->setEndpoint('people/'.$this->get()['id']); $this->_transport->execute($data);