Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-smush.../vendor/mixpanel/mixpanel.../lib/Producer...
File: MixpanelPeople.php
<?php
[0] Fix | Delete
require_once(dirname(__FILE__) . "/MixpanelBaseProducer.php");
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Provides an API to create/update profiles on Mixpanel
[4] Fix | Delete
*/
[5] Fix | Delete
class Producers_MixpanelPeople extends Producers_MixpanelBaseProducer {
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Internal method to prepare a message given the message data
[9] Fix | Delete
* @param $distinct_id
[10] Fix | Delete
* @param $operation
[11] Fix | Delete
* @param $value
[12] Fix | Delete
* @param null $ip
[13] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[14] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[15] Fix | Delete
* @return array
[16] Fix | Delete
*/
[17] Fix | Delete
private function _constructPayload($distinct_id, $operation, $value, $ip = null, $ignore_time = false, $ignore_alias = false) {
[18] Fix | Delete
$payload = array(
[19] Fix | Delete
'$token' => $this->_token,
[20] Fix | Delete
'$distinct_id' => $distinct_id,
[21] Fix | Delete
'$time' => microtime(true),
[22] Fix | Delete
$operation => $value
[23] Fix | Delete
);
[24] Fix | Delete
if ($ip !== null) $payload['$ip'] = $ip;
[25] Fix | Delete
if ($ignore_time === true) $payload['$ignore_time'] = true;
[26] Fix | Delete
if ($ignore_alias === true) $payload['$ignore_alias'] = true;
[27] Fix | Delete
return $payload;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Set properties on a user record. If the profile does not exist, it creates it with these properties.
[32] Fix | Delete
* If it does exist, it sets the properties to these values, overwriting existing values.
[33] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[34] Fix | Delete
* @param array $props associative array of properties to set on the profile
[35] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[36] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[37] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[38] Fix | Delete
*/
[39] Fix | Delete
public function set($distinct_id, $props, $ip = null, $ignore_time = false, $ignore_alias = false) {
[40] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$set', $props, $ip, $ignore_time, $ignore_alias);
[41] Fix | Delete
$this->enqueue($payload);
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Set properties on a user record. If the profile does not exist, it creates it with these properties.
[46] Fix | Delete
* If it does exist, it sets the properties to these values but WILL NOT overwrite existing values.
[47] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[48] Fix | Delete
* @param array $props associative array of properties to set on the profile
[49] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[50] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[51] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[52] Fix | Delete
*/
[53] Fix | Delete
public function setOnce($distinct_id, $props, $ip = null, $ignore_time = false, $ignore_alias = false) {
[54] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$set_once', $props, $ip, $ignore_time, $ignore_alias);
[55] Fix | Delete
$this->enqueue($payload);
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Unset properties on a user record. If the profile does not exist, it creates it with no properties.
[60] Fix | Delete
* If it does exist, it unsets these properties. NOTE: In other libraries we use 'unset' which is
[61] Fix | Delete
* a reserved word in PHP.
[62] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[63] Fix | Delete
* @param array $props associative array of properties to unset on the profile
[64] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[65] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[66] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[67] Fix | Delete
*/
[68] Fix | Delete
public function remove($distinct_id, $props, $ip = null, $ignore_time = false, $ignore_alias = false) {
[69] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$unset', $props, $ip, $ignore_time, $ignore_alias);
[70] Fix | Delete
$this->enqueue($payload);
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Increments the value of a property on a user record. If the profile does not exist, it creates it and sets the
[75] Fix | Delete
* property to the increment value.
[76] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[77] Fix | Delete
* @param $prop string the property to increment
[78] Fix | Delete
* @param int $val the amount to increment the property by
[79] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[80] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[81] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[82] Fix | Delete
*/
[83] Fix | Delete
public function increment($distinct_id, $prop, $val, $ip = null, $ignore_time = false, $ignore_alias = false) {
[84] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$add', array("$prop" => $val), $ip, $ignore_time, $ignore_alias);
[85] Fix | Delete
$this->enqueue($payload);
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Adds $val to a list located at $prop. If the property does not exist, it will be created. If $val is a string
[90] Fix | Delete
* and the list is empty or does not exist, a new list with one value will be created.
[91] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[92] Fix | Delete
* @param string $prop the property that holds the list
[93] Fix | Delete
* @param string|array $val items to add to the list
[94] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[95] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[96] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[97] Fix | Delete
*/
[98] Fix | Delete
public function append($distinct_id, $prop, $val, $ip = null, $ignore_time = false, $ignore_alias = false) {
[99] Fix | Delete
$operation = gettype($val) == "array" ? '$union' : '$append';
[100] Fix | Delete
$payload = $this->_constructPayload($distinct_id, $operation, array("$prop" => $val), $ip, $ignore_time, $ignore_alias);
[101] Fix | Delete
$this->enqueue($payload);
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Adds a transaction to the user's profile for revenue tracking
[106] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[107] Fix | Delete
* @param string $amount the transaction amount e.g. "20.50"
[108] Fix | Delete
* @param null $timestamp the timestamp of when the transaction occurred (default to current timestamp)
[109] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[110] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[111] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[112] Fix | Delete
*/
[113] Fix | Delete
public function trackCharge($distinct_id, $amount, $timestamp = null, $ip = null, $ignore_time = false, $ignore_alias = false) {
[114] Fix | Delete
$timestamp = $timestamp == null ? time() : $timestamp;
[115] Fix | Delete
$date_iso = date("c", $timestamp);
[116] Fix | Delete
$transaction = array(
[117] Fix | Delete
'$time' => $date_iso,
[118] Fix | Delete
'$amount' => $amount
[119] Fix | Delete
);
[120] Fix | Delete
$val = array('$transactions' => $transaction);
[121] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$append', $val, $ip, $ignore_time, $ignore_alias);
[122] Fix | Delete
$this->enqueue($payload);
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Clear all transactions stored on a user's profile
[127] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[128] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[129] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[130] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[131] Fix | Delete
*/
[132] Fix | Delete
public function clearCharges($distinct_id, $ip = null, $ignore_time = false, $ignore_alias = false) {
[133] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$set', array('$transactions' => array()), $ip, $ignore_time, $ignore_alias);
[134] Fix | Delete
$this->enqueue($payload);
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Delete this profile from Mixpanel
[139] Fix | Delete
* @param string|int $distinct_id the distinct_id or alias of a user
[140] Fix | Delete
* @param string|null $ip the ip address of the client (used for geo-location)
[141] Fix | Delete
* @param boolean $ignore_time If the $ignore_time property is true, Mixpanel will not automatically update the "Last Seen" property of the profile. Otherwise, Mixpanel will add a "Last Seen" property associated with the current time
[142] Fix | Delete
* @param boolean $ignore_alias If the $ignore_alias property is true, an alias look up will not be performed after ingestion. Otherwise, a lookup for the distinct ID will be performed, and replaced if a match is found
[143] Fix | Delete
*/
[144] Fix | Delete
public function deleteUser($distinct_id, $ip = null, $ignore_time = false, $ignore_alias = false) {
[145] Fix | Delete
$payload = $this->_constructPayload($distinct_id, '$delete', "", $ip, $ignore_time, $ignore_alias);
[146] Fix | Delete
$this->enqueue($payload);
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Returns the "engage" endpoint
[151] Fix | Delete
* @return string
[152] Fix | Delete
*/
[153] Fix | Delete
function _getEndpoint() {
[154] Fix | Delete
return $this->_options['people_endpoint'];
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function