diff --git a/src/LaunchDarkly/LDClient.php b/src/LaunchDarkly/LDClient.php index d079f8130..bbb7ab388 100644 --- a/src/LaunchDarkly/LDClient.php +++ b/src/LaunchDarkly/LDClient.php @@ -78,14 +78,19 @@ public function getFlag($key, $user, $default = false) { } } catch (Exception $e) { error_log("LaunchDarkly caught $e"); - $this->_sendFlagRequestEvent($key, $user, $default); + try { + $this->_sendFlagRequestEvent($key, $user, $default); + } + catch (Exception $e) { + error_log("LaunchDarkly caught $e"); + } return $default; } } /** * Puts the LaunchDarkly client in offline mode. - * In offline mode, all calls to `getFlag` will return the default value, and `sendEvent` will be a no-op. + * In offline mode, all calls to `getFlag` will return the default value, and `track` will be a no-op. * */ public function setOffline() { @@ -115,7 +120,7 @@ public function isOffline() { * @param LDUser $user The user that performed the event * */ - public function sendEvent($eventName, $user, $data) { + public function track($eventName, $user, $data) { if ($this->isOffline()) { return; } @@ -131,6 +136,19 @@ public function sendEvent($eventName, $user, $data) { $this->_eventProcessor->enqueue($event); } + public function identify($user) { + if ($this->isOffline()) { + return; + } + + $event = array(); + $event['user'] = $user->toJSON(); + $event['kind'] = "identify"; + $event['creationDate'] = round(microtime(1) * 1000); + $event['key'] = $user->getKey(); + $this->_eventProcessor->enqueue($event); + } + protected function _sendFlagRequestEvent($key, $user, $value) { if ($this->isOffline()) { return;