Piwik\Tracker\Request::getIpString PHP Method

getIpString() public method

public getIpString ( ) : mixed | string
return mixed | string
    public function getIpString()
    {
        $cip = $this->getParam('cip');
        if (empty($cip)) {
            return IP::getIpFromHeader();
        }
        if (!$this->isAuthenticated()) {
            Common::printDebug("WARN: Tracker API 'cip' was used with invalid token_auth");
            return IP::getIpFromHeader();
        }
        return $cip;
    }

Usage Example

Example #1
0
 public function processRequestParams(VisitProperties $visitProperties, Request $request)
 {
     // the IP is needed by isExcluded() and GoalManager->recordGoals()
     $visitProperties->setProperty('location_ip', $request->getIp());
     $excluded = new VisitExcluded($request);
     if ($excluded->isExcluded()) {
         return true;
     }
     $privacyConfig = new PrivacyManagerConfig();
     $ip = $request->getIpString();
     if ($privacyConfig->useAnonymizedIpForVisitEnrichment) {
         $ip = $visitProperties->getProperty('location_ip');
     }
     // visitor recognition
     $visitorId = $this->userSettings->getConfigId($request, $ip);
     $request->setMetadata('CoreHome', 'visitorId', $visitorId);
     $isKnown = $this->visitorRecognizer->findKnownVisitor($visitorId, $visitProperties, $request);
     $request->setMetadata('CoreHome', 'isVisitorKnown', $isKnown);
     $isNewVisit = $this->isVisitNew($visitProperties, $request);
     $request->setMetadata('CoreHome', 'isNewVisit', $isNewVisit);
     return false;
 }
All Usage Examples Of Piwik\Tracker\Request::getIpString