本文整理匯總了PHP中Piwik\Tracker\Request::getMetadata方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getMetadata方法的具體用法?PHP Request::getMetadata怎麽用?PHP Request::getMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik\Tracker\Request
的用法示例。
在下文中一共展示了Request::getMetadata方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: recordLogs
public function recordLogs(VisitProperties $visitProperties, Request $request)
{
/** @var Action $action */
$action = $request->getMetadata('Actions', 'action');
if ($action !== null && !$request->getMetadata('CoreHome', 'visitorNotFoundInDb')) {
$idReferrerActionUrl = 0;
$idReferrerActionName = 0;
if (!$request->getMetadata('CoreHome', 'isNewVisit')) {
$idReferrerActionUrl = $request->getMetadata('Actions', 'idReferrerActionUrl');
$idReferrerActionName = $request->getMetadata('Actions', 'idReferrerActionName');
}
$visitor = Visitor::makeFromVisitProperties($visitProperties, $request);
$action->record($visitor, $idReferrerActionUrl, $idReferrerActionName);
}
}
示例2: onExistingVisit
public function onExistingVisit(&$valuesToUpdate, VisitProperties $visitProperties, Request $request)
{
$visitCustomVariables = $request->getMetadata('CustomVariables', 'visitCustomVariables');
if (!empty($visitCustomVariables)) {
$valuesToUpdate = array_merge($valuesToUpdate, $visitCustomVariables);
}
}
示例3: afterRequestProcessed
public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
{
$goalsConverted = $request->getMetadata('Goals', 'goalsConverted');
if (!empty($goalsConverted)) {
$isThereExistingCartInVisit = $this->goalManager->detectIsThereExistingCartInVisit($visitProperties->getProperties());
$request->setMetadata('Goals', 'isThereExistingCartInVisit', $isThereExistingCartInVisit);
}
}
示例4: afterRequestProcessed
public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
{
$action = $request->getMetadata('Actions', 'action');
if (empty($action) || !$action instanceof Action) {
return;
}
$dimensionsToSet = $this->getCustomDimensionsInScope(CustomDimensions::SCOPE_ACTION, $request);
foreach ($dimensionsToSet as $field => $value) {
$action->setCustomField($field, $value);
}
}
示例5: triggerPredicateHookOnDimensions
private function triggerPredicateHookOnDimensions($dimensions, $hook)
{
$visitor = $this->makeVisitorFacade();
/** @var Action $action */
$action = $this->request->getMetadata('Actions', 'action');
foreach ($dimensions as $dimension) {
if ($dimension->{$hook}($this->request, $visitor, $action)) {
return true;
}
}
return false;
}
示例6: afterRequestProcessed
public function afterRequestProcessed(VisitProperties $visitProperties, Request $request)
{
$action = $request->getMetadata('Actions', 'action');
if (empty($action) || !$action instanceof Action) {
return;
}
$customVariables = $action->getCustomVariables();
if (!empty($customVariables)) {
Common::printDebug("Page level Custom Variables: ");
Common::printDebug($customVariables);
foreach ($customVariables as $field => $value) {
$action->setCustomField($field, $value);
}
}
}
示例7: getBuyerType
private function getBuyerType(Request $request, $existingType = self::TYPE_BUYER_NONE)
{
$isRequestEcommerce = $request->getMetadata('Ecommerce', 'isRequestEcommerce');
if (!$isRequestEcommerce) {
return $existingType;
}
$isGoalAnOrder = $request->getMetadata('Ecommerce', 'isGoalAnOrder');
if ($isGoalAnOrder) {
return self::TYPE_BUYER_ORDERED;
}
// request is Add to Cart
if ($existingType == self::TYPE_BUYER_ORDERED || $existingType == self::TYPE_BUYER_ORDERED_AND_OPEN_CART) {
return self::TYPE_BUYER_ORDERED_AND_OPEN_CART;
}
return self::TYPE_BUYER_OPEN_CART;
}
示例8: getValueForDimension
private function getValueForDimension(Request $request)
{
/** @var Action $action */
$action = $request->getMetadata('Actions', 'action');
if (in_array($this->dimension, array('url', 'urlparam'))) {
if (!empty($action)) {
$dimension = $action->getActionUrlRaw();
} else {
$dimension = $request->getParam('url');
}
} elseif ($this->dimension === 'action_name' && !empty($action)) {
$dimension = $action->getActionName();
} else {
$dimension = $request->getParam($this->dimension);
}
if (!empty($dimension)) {
$dimension = Common::unsanitizeInputValue($dimension);
}
return $dimension;
}
示例9: recordLogs
public function recordLogs(VisitProperties $visitProperties, Request $request)
{
// record the goals if there were conversions in this request (even if the visit itself was not converted)
$goalsConverted = $request->getMetadata('Goals', 'goalsConverted');
if (!empty($goalsConverted)) {
$this->goalManager->recordGoals($visitProperties, $request);
}
}
示例10: recordEcommerceGoal
/**
* Records an Ecommerce conversion in the DB. Deals with Items found in the request.
* Will deal with 2 types of conversions: Ecommerce Order and Ecommerce Cart update (Add to cart, Update Cart etc).
*
* @param array $conversion
* @param Visitor $visitor
* @param Action $action
* @param array $visitInformation
*/
protected function recordEcommerceGoal(VisitProperties $visitProperties, Request $request, $conversion, $action)
{
$isThereExistingCartInVisit = $request->getMetadata('Goals', 'isThereExistingCartInVisit');
if ($isThereExistingCartInVisit) {
Common::printDebug("There is an existing cart for this visit");
}
$visitor = Visitor::makeFromVisitProperties($visitProperties, $request);
$isGoalAnOrder = $request->getMetadata('Ecommerce', 'isGoalAnOrder');
if ($isGoalAnOrder) {
$debugMessage = 'The conversion is an Ecommerce order';
$orderId = $request->getParam('ec_id');
$conversion['idorder'] = $orderId;
$conversion['idgoal'] = self::IDGOAL_ORDER;
$conversion['buster'] = Common::hashStringToInt($orderId);
$conversionDimensions = ConversionDimension::getAllDimensions();
$conversion = $this->triggerHookOnDimensions($request, $conversionDimensions, 'onEcommerceOrderConversion', $visitor, $action, $conversion);
} else {
$debugMessage = 'The conversion is an Ecommerce Cart Update';
$conversion['buster'] = 0;
$conversion['idgoal'] = self::IDGOAL_CART;
$conversionDimensions = ConversionDimension::getAllDimensions();
$conversion = $this->triggerHookOnDimensions($request, $conversionDimensions, 'onEcommerceCartUpdateConversion', $visitor, $action, $conversion);
}
Common::printDebug($debugMessage . ':' . var_export($conversion, true));
// INSERT or Sync items in the Cart / Order for this visit & order
$items = $this->getEcommerceItemsFromRequest($request);
if (false === $items) {
return;
}
$itemsCount = 0;
foreach ($items as $item) {
$itemsCount += $item[GoalManager::INTERNAL_ITEM_QUANTITY];
}
$conversion['items'] = $itemsCount;
if ($isThereExistingCartInVisit) {
$recorded = $this->getModel()->updateConversion($visitProperties->getProperty('idvisit'), self::IDGOAL_CART, $conversion);
} else {
$recorded = $this->insertNewConversion($conversion, $visitProperties->getProperties(), $request);
}
if ($recorded) {
$this->recordEcommerceItems($conversion, $items);
}
/**
* Triggered after successfully persisting an ecommerce conversion.
*
* _Note: Subscribers should be wary of doing any expensive computation here as it may slow
* the tracker down._
*
* This event is deprecated, use [Dimensions](http://developer.piwik.org/guides/dimensions) instead.
*
* @param array $conversion The conversion entity that was just persisted. See what information
* it contains [here](/guides/persistence-and-the-mysql-backend#conversions).
* @param array $visitInformation The visit entity that we are tracking a conversion for. See what
* information it contains [here](/guides/persistence-and-the-mysql-backend#visits).
* @deprecated
*/
Piwik::postEvent('Tracker.recordEcommerceGoal', array($conversion, $visitProperties->getProperties()));
}
示例11: makeFromVisitProperties
public static function makeFromVisitProperties(VisitProperties $visitProperties, Request $request)
{
$isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown');
return new Visitor($visitProperties, $isKnown);
}
示例12: recordEcommerceGoal
/**
* Records an Ecommerce conversion in the DB. Deals with Items found in the request.
* Will deal with 2 types of conversions: Ecommerce Order and Ecommerce Cart update (Add to cart, Update Cart etc).
*
* @param array $conversion
* @param Visitor $visitor
* @param Action $action
* @param array $visitInformation
*/
protected function recordEcommerceGoal(VisitProperties $visitProperties, Request $request, $conversion, $action)
{
$isThereExistingCartInVisit = $request->getMetadata('Goals', 'isThereExistingCartInVisit');
if ($isThereExistingCartInVisit) {
Common::printDebug("There is an existing cart for this visit");
}
$visitor = Visitor::makeFromVisitProperties($visitProperties, $request);
$isGoalAnOrder = $request->getMetadata('Ecommerce', 'isGoalAnOrder');
if ($isGoalAnOrder) {
$debugMessage = 'The conversion is an Ecommerce order';
$orderId = $request->getParam('ec_id');
$conversion['idorder'] = $orderId;
$conversion['idgoal'] = self::IDGOAL_ORDER;
$conversion['buster'] = Common::hashStringToInt($orderId);
$conversionDimensions = ConversionDimension::getAllDimensions();
$conversion = $this->triggerHookOnDimensions($request, $conversionDimensions, 'onEcommerceOrderConversion', $visitor, $action, $conversion);
} else {
$debugMessage = 'The conversion is an Ecommerce Cart Update';
$conversion['buster'] = 0;
$conversion['idgoal'] = self::IDGOAL_CART;
$conversionDimensions = ConversionDimension::getAllDimensions();
$conversion = $this->triggerHookOnDimensions($request, $conversionDimensions, 'onEcommerceCartUpdateConversion', $visitor, $action, $conversion);
}
Common::printDebug($debugMessage . ':' . var_export($conversion, true));
// INSERT or Sync items in the Cart / Order for this visit & order
$items = $this->getEcommerceItemsFromRequest($request);
if (false === $items) {
return;
}
$itemsCount = 0;
foreach ($items as $item) {
$itemsCount += $item[GoalManager::INTERNAL_ITEM_QUANTITY];
}
$conversion['items'] = $itemsCount;
if ($isThereExistingCartInVisit) {
$recorded = $this->getModel()->updateConversion($visitProperties->getProperty('idvisit'), self::IDGOAL_CART, $conversion);
} else {
$recorded = $this->insertNewConversion($conversion, $visitProperties->getProperties(), $request);
}
if ($recorded) {
$this->recordEcommerceItems($conversion, $items);
}
}
示例13: isVisitNew
/**
* Determines if the tracker if the current action should be treated as the start of a new visit or
* an action in an existing visit.
*
* Note: public only for tests.
*
* @param VisitProperties $visitProperties The current visit/visitor information.
* @param Request $request
* @return bool
*/
public function isVisitNew(VisitProperties $visitProperties, Request $request)
{
$isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown');
if (!$isKnown) {
return true;
}
$isLastActionInTheSameVisit = $this->isLastActionInTheSameVisit($visitProperties, $request);
if (!$isLastActionInTheSameVisit) {
Common::printDebug("Visitor detected, but last action was more than 30 minutes ago...");
return true;
}
$wasLastActionYesterday = $this->wasLastActionNotToday($visitProperties, $request);
if ($wasLastActionYesterday) {
Common::printDebug("Visitor detected, but last action was yesterday...");
return true;
}
return false;
}
示例14: isVisitNew
/**
* Determines if the tracker if the current action should be treated as the start of a new visit or
* an action in an existing visit.
*
* Note: public only for tests.
*
* @param VisitProperties $visitProperties The current visit/visitor information.
* @param Request $request
* @return bool
*/
public function isVisitNew(VisitProperties $visitProperties, Request $request)
{
$isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown');
if (!$isKnown) {
return true;
}
$isLastActionInTheSameVisit = $this->isLastActionInTheSameVisit($visitProperties, $request);
if (!$isLastActionInTheSameVisit) {
Common::printDebug("Visitor detected, but last action was more than 30 minutes ago...");
return true;
}
$wasLastActionYesterday = $this->wasLastActionNotToday($visitProperties, $request);
$forceNewVisitAtMidnight = (bool) Config::getInstance()->Tracker['create_new_visit_after_midnight'];
if ($wasLastActionYesterday && $forceNewVisitAtMidnight) {
Common::printDebug("Visitor detected, but last action was yesterday...");
return true;
}
return false;
}
示例15: getCurrentInteractionPosition
/**
* @param Request $request
* @return int
*/
public static function getCurrentInteractionPosition($request)
{
$position = $request->getMetadata('Actions', 'visit_total_interactions');
return $position + 1;
}