PHP Class Piwik\Tracker\Request

Show file Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$isAuthenticated
$params array
$rawParams
$tokenAuth

Public Methods

Method Description
__construct ( $params, boolean | string $tokenAuth = false )
authenticateSuperUserOrAdmin ( $tokenAuth, $idSite )
getBrowserLanguage ( ) : string Returns the language the visitor is viewing.
getCurrentTimestamp ( )
getCustomVariables ( $scope )
getCustomVariablesInPageScope ( )
getCustomVariablesInVisitScope ( )
getDaysSinceFirstVisit ( ) : float | integer
getDaysSinceLastOrder ( ) : boolean | float | integer
getDaysSinceLastVisit ( ) : float | integer
getForcedUserId ( )
getForcedVisitorId ( )
getGoalRevenue ( $defaultGoalRevenue )
getIdSite ( )
getIp ( )
getIpString ( ) : mixed | string
getLocalTime ( ) : string
getMetadata ( string $pluginName, string $key ) : mixed Get a request metadata value. Returns null if none exists.
getPageGenerationTime ( ) 1 hour
getParam ( $name )
getParams ( )
getPlugins ( )
getRawParams ( ) : array Get the params that were originally passed to the instance. These params do not contain any params that were added within this object.
getTokenAuth ( )
getUserAgent ( )
getUserIdHashed ( $userId ) : string Matches implementation of PiwikTracker::getUserIdHashed
getVisitCount ( ) : integer | mixed
getVisitorId ( ) Returns the ID from the request in this order: return from a given User ID, or from a Tracking API forced Visitor ID, or from a Visitor ID from 3rd party (optional) cookies, or from a given Visitor Id from 1st party?
isAuthenticated ( ) : boolean
isEmptyRequest ( )
setCurrentTimestamp ( $timestamp )
setMetadata ( string $pluginName, string $key, mixed $value ) Set a request metadata value.
setParam ( $name, $value )
setThirdPartyCookie ( $idVisitor ) Update the cookie information.
truncateCustomVariable ( $input )

Protected Methods

Method Description
authenticateTrackingApi ( $tokenAuth ) This method allows to set custom IP + server time + visitor ID, when using Tracking API.
getCookieExpire ( )
getCookieName ( )
getCookiePath ( )
getCurrentDate ( string $format = "Y-m-d" ) : string Returns the current date in the "Y-m-d" PHP format
getCustomTimestamp ( )
isTimestampValid ( $time, $now = null ) : boolean Returns true if the timestamp is valid ie. timestamp is sometime in the last 10 years and is not in the future.
makeThirdPartyCookieUID ( )
shouldUseThirdPartyCookie ( )

Private Methods

Method Description
hasParam ( $name )
truncateIdAsVisitorId ( $idVisitor ) : string

Method Details

__construct() public method

public __construct ( $params, boolean | string $tokenAuth = false )
$params
$tokenAuth boolean | string

authenticateSuperUserOrAdmin() public static method

public static authenticateSuperUserOrAdmin ( $tokenAuth, $idSite )

authenticateTrackingApi() protected method

These two attributes can be only set by the Super User (passing token_auth).
protected authenticateTrackingApi ( $tokenAuth )

getBrowserLanguage() public method

Returns the language the visitor is viewing.
public getBrowserLanguage ( ) : string
return string browser language code, eg. "en-gb,en;q=0.5"

getCookieExpire() protected method

protected getCookieExpire ( )

getCookieName() protected method

protected getCookieName ( )

getCookiePath() protected method

protected getCookiePath ( )

getCurrentDate() protected method

Returns the current date in the "Y-m-d" PHP format
protected getCurrentDate ( string $format = "Y-m-d" ) : string
$format string
return string

getCurrentTimestamp() public method

public getCurrentTimestamp ( )

getCustomTimestamp() protected method

protected getCustomTimestamp ( )

getCustomVariables() public method

Deprecation: since Piwik 2.10.0. Use Request::getCustomVariablesInPageScope() or Request::getCustomVariablesInVisitScope() instead. When we "remove" this method we will only set visibility to "private" and pass $parameter = _cvar|cvar as an argument instead of $scope
public getCustomVariables ( $scope )

getCustomVariablesInPageScope() public method

getCustomVariablesInVisitScope() public method

getDaysSinceFirstVisit() public method

getDaysSinceLastOrder() public method

getDaysSinceLastVisit() public method

public getDaysSinceLastVisit ( ) : float | integer
return float | integer

getForcedUserId() public method

public getForcedUserId ( )

getForcedVisitorId() public method

public getForcedVisitorId ( )

getGoalRevenue() public method

public getGoalRevenue ( $defaultGoalRevenue )

getIdSite() public method

public getIdSite ( )

getIp() public method

public getIp ( )

getIpString() public method

public getIpString ( ) : mixed | string
return mixed | string

getLocalTime() public method

public getLocalTime ( ) : string
return string

getMetadata() public method

Get a request metadata value. Returns null if none exists.
public getMetadata ( string $pluginName, string $key ) : mixed
$pluginName string eg, `'Actions'`, `'Goals'`, `'YourPlugin'`
$key string
return mixed

getPageGenerationTime() public method

1 hour

getParam() public method

public getParam ( $name )

getParams() public method

public getParams ( )

getPlugins() public method

public getPlugins ( )

getRawParams() public method

Get the params that were originally passed to the instance. These params do not contain any params that were added within this object.
public getRawParams ( ) : array
return array

getTokenAuth() public method

public getTokenAuth ( )

getUserAgent() public method

public getUserAgent ( )

getUserIdHashed() public method

Matches implementation of PiwikTracker::getUserIdHashed
public getUserIdHashed ( $userId ) : string
$userId
return string

getVisitCount() public method

public getVisitCount ( ) : integer | mixed
return integer | mixed

getVisitorId() public method

Returns the ID from the request in this order: return from a given User ID, or from a Tracking API forced Visitor ID, or from a Visitor ID from 3rd party (optional) cookies, or from a given Visitor Id from 1st party?
public getVisitorId ( )

isAuthenticated() public method

public isAuthenticated ( ) : boolean
return boolean

isEmptyRequest() public method

public isEmptyRequest ( )

isTimestampValid() protected method

Returns true if the timestamp is valid ie. timestamp is sometime in the last 10 years and is not in the future.
protected isTimestampValid ( $time, $now = null ) : boolean
$time int Timestamp to test
$now int Current timestamp
return boolean

makeThirdPartyCookieUID() protected method

protected makeThirdPartyCookieUID ( )

setCurrentTimestamp() public method

public setCurrentTimestamp ( $timestamp )

setMetadata() public method

Set a request metadata value.
public setMetadata ( string $pluginName, string $key, mixed $value )
$pluginName string eg, `'Actions'`, `'Goals'`, `'YourPlugin'`
$key string
$value mixed

setParam() public method

public setParam ( $name, $value )

setThirdPartyCookie() public method

Update the cookie information.
public setThirdPartyCookie ( $idVisitor )

shouldUseThirdPartyCookie() protected method

truncateCustomVariable() public static method

public static truncateCustomVariable ( $input )

Property Details

$isAuthenticated protected property

protected $isAuthenticated

$params protected property

protected array $params
return array

$rawParams protected property

protected $rawParams

$tokenAuth protected property

protected $tokenAuth