| 1 |
<?php |
| 2 |
|
| 3 |
namespace ElementorDeps; |
| 4 |
|
| 5 |
/** |
| 6 |
* This a Base class which all Mixpanel classes extend from to provide some very basic |
| 7 |
* debugging and logging functionality. It also serves to persist $_options across the library. |
| 8 |
* |
| 9 |
*/ |
| 10 |
class Base_MixpanelBase |
| 11 |
{ |
| 12 |
/** |
| 13 |
* Default options that can be overridden via the $options constructor arg |
| 14 |
* @var array |
| 15 |
*/ |
| 16 |
private $_defaults = array( |
| 17 |
"max_batch_size" => 50, |
| 18 |
// the max batch size Mixpanel will accept is 50, |
| 19 |
"max_queue_size" => 1000, |
| 20 |
// the max num of items to hold in memory before flushing |
| 21 |
"debug" => \false, |
| 22 |
// enable/disable debug mode |
| 23 |
"consumer" => "curl", |
| 24 |
// which consumer to use |
| 25 |
"host" => "api.mixpanel.com", |
| 26 |
// the host name for api calls |
| 27 |
"events_endpoint" => "/track", |
| 28 |
// host relative endpoint for events |
| 29 |
"people_endpoint" => "/engage", |
| 30 |
// host relative endpoint for people updates |
| 31 |
"groups_endpoint" => "/groups", |
| 32 |
// host relative endpoint for groups updates |
| 33 |
"use_ssl" => \true, |
| 34 |
// use ssl when available |
| 35 |
"error_callback" => null, |
| 36 |
); |
| 37 |
/** |
| 38 |
* An array of options to be used by the Mixpanel library. |
| 39 |
* @var array |
| 40 |
*/ |
| 41 |
protected $_options = array(); |
| 42 |
/** |
| 43 |
* Construct a new MixpanelBase object and merge custom options with defaults |
| 44 |
* @param array $options |
| 45 |
*/ |
| 46 |
public function __construct($options = array()) |
| 47 |
{ |
| 48 |
$options = \array_merge($this->_defaults, $options); |
| 49 |
$this->_options = $options; |
| 50 |
} |
| 51 |
/** |
| 52 |
* Log a message to PHP's error log |
| 53 |
* @param $msg |
| 54 |
*/ |
| 55 |
protected function _log($msg) |
| 56 |
{ |
| 57 |
$arr = \debug_backtrace(); |
| 58 |
$class = $arr[0]['class']; |
| 59 |
$line = $arr[0]['line']; |
| 60 |
\error_log("[ {$class} - line {$line} ] : " . $msg); |
| 61 |
} |
| 62 |
/** |
| 63 |
* Returns true if in debug mode, false if in production mode |
| 64 |
* @return bool |
| 65 |
*/ |
| 66 |
protected function _debug() |
| 67 |
{ |
| 68 |
return isset($this->_options["debug"]) && $this->_options["debug"] == \true; |
| 69 |
} |
| 70 |
} |
| 71 |
|