/** * 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']); } }
/** * Gets a sample ApplicationInsights\Channel\Contracts\Session * @return ApplicationInsights\Channel\Contracts\Session */ public static function getSampleSessionContext() { $context = new \ApplicationInsights\Channel\Contracts\Session(); $context->setId('my_session_id'); $context->setIsFirst(false); $context->setIsNew(false); return $context; }