/** * Gets a sample ApplicationInsights\Channel\Contracts\User * @return ApplicationInsights\Channel\Contracts\User */ public static function getSampleUserContext() { $context = new \ApplicationInsights\Channel\Contracts\User(); $context->setId('my_user_id'); $context->setAccountAcquisitionDate('1/1/2014'); $context->setAccountId('my_account_id'); $context->setUserAgent('my_user_agent'); return $context; }
/** * Initializes a new TelemetryContext. */ function __construct() { $this->_deviceContext = new Channel\Contracts\Device(); $this->_applicationContext = new Channel\Contracts\Application(); $this->_userContext = new Channel\Contracts\User(); $this->_locationContext = new Channel\Contracts\Location(); $this->_operationContext = new Channel\Contracts\Operation(); $this->_sessionContext = new Channel\Contracts\Session(); $this->_properties = array(); // Initialize user id $currentUser = new Current_User(); $this->_userContext->setId($currentUser->id); // Initialize session id $currentSession = new Current_Session(); $this->_sessionContext->setId($currentSession->id); // Initialize client ip if (array_key_exists('REMOTE_ADDR', $_SERVER) && sizeof(explode('.', $_SERVER['REMOTE_ADDR'])) >= 4) { $this->_locationContext->setIp($_SERVER['REMOTE_ADDR']); } }