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/clone/wp-conte.../plugins/wp-smush.../vendor/mixpanel/mixpanel.../lib
File: Mixpanel.php
<?php
[0] Fix | Delete
[1] Fix | Delete
require_once(dirname(__FILE__) . "/Base/MixpanelBase.php");
[2] Fix | Delete
require_once(dirname(__FILE__) . "/Producers/MixpanelPeople.php");
[3] Fix | Delete
require_once(dirname(__FILE__) . "/Producers/MixpanelEvents.php");
[4] Fix | Delete
require_once(dirname(__FILE__) . "/Producers/MixpanelGroups.php");
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* This is the main class for the Mixpanel PHP Library which provides all of the methods you need to track events,
[8] Fix | Delete
* create/update profiles and group profiles.
[9] Fix | Delete
*
[10] Fix | Delete
* Architecture
[11] Fix | Delete
* -------------
[12] Fix | Delete
*
[13] Fix | Delete
* This library is built such that all messages are buffered in an in-memory "queue"
[14] Fix | Delete
* The queue will be automatically flushed at the end of every request. Alternatively, you can call "flush()" manually
[15] Fix | Delete
* at any time. Flushed messages will be passed to a Consumer's "persist" method. The library comes with a handful of
[16] Fix | Delete
* Consumers. The "CurlConsumer" is used by default which will send the messages to Mixpanel using forked cURL processes.
[17] Fix | Delete
* You can implement your own custom Consumer to customize how a message is sent to Mixpanel. This can be useful when
[18] Fix | Delete
* you want to put messages onto a distributed queue (such as ActiveMQ or Kestrel) instead of writing to Mixpanel in
[19] Fix | Delete
* the user thread.
[20] Fix | Delete
*
[21] Fix | Delete
* Options
[22] Fix | Delete
* -------------
[23] Fix | Delete
*
[24] Fix | Delete
* <table width="100%" cellpadding="5">
[25] Fix | Delete
* <tr>
[26] Fix | Delete
* <th>Option</th>
[27] Fix | Delete
* <th>Description</th>
[28] Fix | Delete
* <th>Default</th>
[29] Fix | Delete
* </tr>
[30] Fix | Delete
* <tr>
[31] Fix | Delete
* <td>max_queue_size</td>
[32] Fix | Delete
* <td>The maximum number of items to buffer in memory before flushing</td>
[33] Fix | Delete
* <td>1000</td>
[34] Fix | Delete
* </tr>
[35] Fix | Delete
* <tr>
[36] Fix | Delete
* <td>debug</td>
[37] Fix | Delete
* <td>Enable/disable debug mode</td>
[38] Fix | Delete
* <td>false</td>
[39] Fix | Delete
* </tr>
[40] Fix | Delete
* <tr>
[41] Fix | Delete
* <td>consumer</td>
[42] Fix | Delete
* <td>The consumer to use for writing messages</td>
[43] Fix | Delete
* <td>curl</td>
[44] Fix | Delete
* </tr>
[45] Fix | Delete
* <tr>
[46] Fix | Delete
* <td>consumers</td>
[47] Fix | Delete
* <td>An array of custom consumers in the format array(consumer_key => class_name)</td>
[48] Fix | Delete
* <td>null</td>
[49] Fix | Delete
* </tr>
[50] Fix | Delete
* <tr>
[51] Fix | Delete
* <td>host</td>
[52] Fix | Delete
* <td>The host name for api calls (used by some consumers)</td>
[53] Fix | Delete
* <td>api.mixpanel.com</td>
[54] Fix | Delete
* </tr>
[55] Fix | Delete
* <tr>
[56] Fix | Delete
* <td>events_endpoint</td>
[57] Fix | Delete
* <td>The endpoint for tracking events (relative to the host)</td>
[58] Fix | Delete
* <td>/events</td>
[59] Fix | Delete
* </tr>
[60] Fix | Delete
* <tr>
[61] Fix | Delete
* <td>people_endpoint</td>
[62] Fix | Delete
* <td>The endpoint for making people updates (relative to the host)</td>
[63] Fix | Delete
* <td>/engage</td>
[64] Fix | Delete
* </tr>
[65] Fix | Delete
* <tr>
[66] Fix | Delete
* <td>use_ssl</td>
[67] Fix | Delete
* <td>Tell the consumer whether or not to use ssl (when available)</td>
[68] Fix | Delete
* <td>true</td>
[69] Fix | Delete
* </tr>
[70] Fix | Delete
* <tr>
[71] Fix | Delete
* <td>error_callback</td>
[72] Fix | Delete
* <td>The name of a function to be called on consumption failures</td>
[73] Fix | Delete
* <td>null</td>
[74] Fix | Delete
* </tr>
[75] Fix | Delete
* <tr>
[76] Fix | Delete
* <td>connect_timeout</td>
[77] Fix | Delete
* <td>In both the SocketConsumer and CurlConsumer, this is used for the connection timeout (i.e. How long it has take to actually make a connection).
[78] Fix | Delete
* <td>5</td>
[79] Fix | Delete
* </tr>
[80] Fix | Delete
* <tr>
[81] Fix | Delete
* <td>timeout</td>
[82] Fix | Delete
* <td>In the CurlConsumer (non-forked), it is used to determine how long the cURL call has to execute.
[83] Fix | Delete
* <td>30</td>
[84] Fix | Delete
* </tr>
[85] Fix | Delete
* </table>
[86] Fix | Delete
*
[87] Fix | Delete
* Example: Tracking an Event
[88] Fix | Delete
* -------------
[89] Fix | Delete
*
[90] Fix | Delete
* $mp = Mixpanel::getInstance("MY_TOKEN");
[91] Fix | Delete
*
[92] Fix | Delete
* $mp->track("My Event");
[93] Fix | Delete
*
[94] Fix | Delete
* Example: Setting Profile Properties
[95] Fix | Delete
* -------------
[96] Fix | Delete
*
[97] Fix | Delete
* $mp = Mixpanel::getInstance("MY_TOKEN", array("use_ssl" => false));
[98] Fix | Delete
*
[99] Fix | Delete
* $mp->people->set(12345, array(
[100] Fix | Delete
* '$first_name' => "John",
[101] Fix | Delete
* '$last_name' => "Doe",
[102] Fix | Delete
* '$email' => "john.doe@example.com",
[103] Fix | Delete
* '$phone' => "5555555555",
[104] Fix | Delete
* 'Favorite Color' => "red"
[105] Fix | Delete
* ));
[106] Fix | Delete
*
[107] Fix | Delete
*/
[108] Fix | Delete
class Mixpanel extends Base_MixpanelBase {
[109] Fix | Delete
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* An instance of the MixpanelPeople class (used to create/update profiles)
[113] Fix | Delete
* @var Producers_MixpanelPeople
[114] Fix | Delete
*/
[115] Fix | Delete
public $people;
[116] Fix | Delete
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* An instance of the MixpanelEvents class
[120] Fix | Delete
* @var Producers_MixpanelEvents
[121] Fix | Delete
*/
[122] Fix | Delete
private $_events;
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* An instance of the MixpanelGroups class (used to create/update group profiles)
[126] Fix | Delete
* @var Producers_MixpanelPeople
[127] Fix | Delete
*/
[128] Fix | Delete
public $group;
[129] Fix | Delete
[130] Fix | Delete
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Instances' list of the Mixpanel class (for singleton use, splitted by token)
[134] Fix | Delete
* @var Mixpanel[]
[135] Fix | Delete
*/
[136] Fix | Delete
private static $_instances = array();
[137] Fix | Delete
[138] Fix | Delete
[139] Fix | Delete
/**
[140] Fix | Delete
* Instantiates a new Mixpanel instance.
[141] Fix | Delete
* @param $token
[142] Fix | Delete
* @param array $options
[143] Fix | Delete
*/
[144] Fix | Delete
public function __construct($token, $options = array()) {
[145] Fix | Delete
parent::__construct($options);
[146] Fix | Delete
$this->people = new Producers_MixpanelPeople($token, $options);
[147] Fix | Delete
$this->_events = new Producers_MixpanelEvents($token, $options);
[148] Fix | Delete
$this->group = new Producers_MixpanelGroups($token, $options);
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Returns a singleton instance of Mixpanel
[154] Fix | Delete
* @param $token
[155] Fix | Delete
* @param array $options
[156] Fix | Delete
* @return Mixpanel
[157] Fix | Delete
*/
[158] Fix | Delete
public static function getInstance($token, $options = array()) {
[159] Fix | Delete
if(!isset(self::$_instances[$token])) {
[160] Fix | Delete
self::$_instances[$token] = new Mixpanel($token, $options);
[161] Fix | Delete
}
[162] Fix | Delete
return self::$_instances[$token];
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
[166] Fix | Delete
/**
[167] Fix | Delete
* Add an array representing a message to be sent to Mixpanel to the in-memory queue.
[168] Fix | Delete
* @param array $message
[169] Fix | Delete
*/
[170] Fix | Delete
public function enqueue($message = array()) {
[171] Fix | Delete
$this->_events->enqueue($message);
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* Add an array representing a list of messages to be sent to Mixpanel to a queue.
[177] Fix | Delete
* @param array $messages
[178] Fix | Delete
*/
[179] Fix | Delete
public function enqueueAll($messages = array()) {
[180] Fix | Delete
$this->_events->enqueueAll($messages);
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
[184] Fix | Delete
/**
[185] Fix | Delete
* Flush the events queue
[186] Fix | Delete
* @param int $desired_batch_size
[187] Fix | Delete
*/
[188] Fix | Delete
public function flush($desired_batch_size = 50) {
[189] Fix | Delete
$this->_events->flush($desired_batch_size);
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
[193] Fix | Delete
/**
[194] Fix | Delete
* Empty the events queue
[195] Fix | Delete
*/
[196] Fix | Delete
public function reset() {
[197] Fix | Delete
$this->_events->reset();
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Identify the user you want to associate to tracked events. The $anon_id must be UUID v4 format and not already merged to an $identified_id.
[203] Fix | Delete
* All identify calls with a new and valid $anon_id will trigger a track $identify event, and merge to the $identified_id.
[204] Fix | Delete
* @param string|int $user_id
[205] Fix | Delete
* @param string|int $anon_id [optional]
[206] Fix | Delete
*/
[207] Fix | Delete
public function identify($user_id, $anon_id = null) {
[208] Fix | Delete
$this->_events->identify($user_id, $anon_id);
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Track an event defined by $event associated with metadata defined by $properties
[213] Fix | Delete
* @param string $event
[214] Fix | Delete
* @param array $properties
[215] Fix | Delete
*/
[216] Fix | Delete
public function track($event, $properties = array()) {
[217] Fix | Delete
$this->_events->track($event, $properties);
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
[221] Fix | Delete
/**
[222] Fix | Delete
* Register a property to be sent with every event.
[223] Fix | Delete
*
[224] Fix | Delete
* If the property has already been registered, it will be
[225] Fix | Delete
* overwritten. NOTE: Registered properties are only persisted for the life of the Mixpanel class instance.
[226] Fix | Delete
* @param string $property
[227] Fix | Delete
* @param mixed $value
[228] Fix | Delete
*/
[229] Fix | Delete
public function register($property, $value) {
[230] Fix | Delete
$this->_events->register($property, $value);
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
[234] Fix | Delete
/**
[235] Fix | Delete
* Register multiple properties to be sent with every event.
[236] Fix | Delete
*
[237] Fix | Delete
* If any of the properties have already been registered,
[238] Fix | Delete
* they will be overwritten. NOTE: Registered properties are only persisted for the life of the Mixpanel class
[239] Fix | Delete
* instance.
[240] Fix | Delete
* @param array $props_and_vals
[241] Fix | Delete
*/
[242] Fix | Delete
public function registerAll($props_and_vals = array()) {
[243] Fix | Delete
$this->_events->registerAll($props_and_vals);
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
[247] Fix | Delete
/**
[248] Fix | Delete
* Register a property to be sent with every event.
[249] Fix | Delete
*
[250] Fix | Delete
* If the property has already been registered, it will NOT be
[251] Fix | Delete
* overwritten. NOTE: Registered properties are only persisted for the life of the Mixpanel class instance.
[252] Fix | Delete
* @param $property
[253] Fix | Delete
* @param $value
[254] Fix | Delete
*/
[255] Fix | Delete
public function registerOnce($property, $value) {
[256] Fix | Delete
$this->_events->registerOnce($property, $value);
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
[260] Fix | Delete
/**
[261] Fix | Delete
* Register multiple properties to be sent with every event.
[262] Fix | Delete
*
[263] Fix | Delete
* If any of the properties have already been registered,
[264] Fix | Delete
* they will NOT be overwritten. NOTE: Registered properties are only persisted for the life of the Mixpanel class
[265] Fix | Delete
* instance.
[266] Fix | Delete
* @param array $props_and_vals
[267] Fix | Delete
*/
[268] Fix | Delete
public function registerAllOnce($props_and_vals = array()) {
[269] Fix | Delete
$this->_events->registerAllOnce($props_and_vals);
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
[273] Fix | Delete
/**
[274] Fix | Delete
* Un-register an property to be sent with every event.
[275] Fix | Delete
* @param string $property
[276] Fix | Delete
*/
[277] Fix | Delete
public function unregister($property) {
[278] Fix | Delete
$this->_events->unregister($property);
[279] Fix | Delete
}
[280] Fix | Delete
[281] Fix | Delete
[282] Fix | Delete
/**
[283] Fix | Delete
* Un-register a list of properties to be sent with every event.
[284] Fix | Delete
* @param array $properties
[285] Fix | Delete
*/
[286] Fix | Delete
public function unregisterAll($properties) {
[287] Fix | Delete
$this->_events->unregisterAll($properties);
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
[291] Fix | Delete
/**
[292] Fix | Delete
* Get a property that is set to be sent with every event
[293] Fix | Delete
* @param string $property
[294] Fix | Delete
* @return mixed
[295] Fix | Delete
*/
[296] Fix | Delete
public function getProperty($property)
[297] Fix | Delete
{
[298] Fix | Delete
return $this->_events->getProperty($property);
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
[302] Fix | Delete
/**
[303] Fix | Delete
* An alias to be merged with the distinct_id. Each alias can only map to one distinct_id.
[304] Fix | Delete
* This is helpful when you want to associate a generated id (such as a session id) to a user id or username.
[305] Fix | Delete
* @param string|int $distinct_id
[306] Fix | Delete
* @param string|int $alias
[307] Fix | Delete
*/
[308] Fix | Delete
public function createAlias($distinct_id, $alias) {
[309] Fix | Delete
$this->_events->createAlias($distinct_id, $alias);
[310] Fix | Delete
}
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function