anonymizeUserId) { $userId = $request->getParam('uid'); if ($this->isValueSet($userId)) { $userIdAnonymized = self::anonymizeUserId($userId); $request->setParam('uid', $userIdAnonymized); } } if ($privacyConfig->anonymizeOrderId) { $orderId = $request->getParam('ec_id'); if ($this->isValueSet($orderId)) { $orderIdAnonymized = sha1(Common::getRandomInt() . $orderId . time() . SettingsPiwik::getSalt()); $request->setParam('ec_id', $orderIdAnonymized); } } } /** * pseudo anonymization as we need to make sure to always generate the same UserId for the same original UserID * * @param $userId * @return string */ public static function anonymizeUserId($userId) { $trackerCache = Tracker\Cache::getCacheGeneral(); $salt = ''; if (!empty($trackerCache[PrivacyManager::OPTION_USERID_SALT])) { $salt = $trackerCache[PrivacyManager::OPTION_USERID_SALT]; } if(empty($salt)) { return $userId; } return sha1($userId . $salt); } private function isValueSet($value) { return $value !== '' && $value !== false && $value !== null; } }