MixpanelBase.php
31 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | class Base_MixpanelBase { |
| 4 | private $_defaults = array( |
| 5 | "max_batch_size" => 50, // the max batch size Mixpanel will accept is 50, |
| 6 | "max_queue_size" => 1000, // the max num of items to hold in memory before flushing |
| 7 | "debug" => false, // enable/disable debug mode |
| 8 | "consumer" => "curl", // which consumer to use |
| 9 | "host" => "api.mixpanel.com", // the host name for api calls |
| 10 | "events_endpoint" => "/track", // host relative endpoint for events |
| 11 | "people_endpoint" => "/engage", // host relative endpoint for people updates |
| 12 | "groups_endpoint" => "/groups", // host relative endpoint for groups updates |
| 13 | "use_ssl" => true, // use ssl when available |
| 14 | "error_callback" => null // callback to use on consumption failures |
| 15 | ); |
| 16 | protected $_options = array(); |
| 17 | public function __construct($options = array()) { |
| 18 | $options = array_merge($this->_defaults, $options); |
| 19 | $this->_options = $options; |
| 20 | } |
| 21 | protected function _log($msg) { |
| 22 | $arr = debug_backtrace(); |
| 23 | $class = $arr[0]['class']; |
| 24 | $line = $arr[0]['line']; |
| 25 | error_log ( "[ $class - line $line ] : " . $msg ); |
| 26 | } |
| 27 | protected function _debug() { |
| 28 | return isset($this->_options["debug"]) && $this->_options["debug"] == true; |
| 29 | } |
| 30 | } |
| 31 |