Base
2 years ago
ConsumerStrategies
2 years ago
Producers
2 years ago
Mixpanel.php
2 years ago
index.php
2 years ago
Mixpanel.php
68 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | require_once(dirname(__FILE__) . "/Base/MixpanelBase.php"); |
| 4 | require_once(dirname(__FILE__) . "/Producers/MixpanelPeople.php"); |
| 5 | require_once(dirname(__FILE__) . "/Producers/MixpanelEvents.php"); |
| 6 | require_once(dirname(__FILE__) . "/Producers/MixpanelGroups.php"); |
| 7 | class Mixpanel extends Base_MixpanelBase { |
| 8 | public $people; |
| 9 | private $_events; |
| 10 | public $group; |
| 11 | private static $_instances = array(); |
| 12 | public function __construct($token, $options = array()) { |
| 13 | parent::__construct($options); |
| 14 | $this->people = new Producers_MixpanelPeople($token, $options); |
| 15 | $this->_events = new Producers_MixpanelEvents($token, $options); |
| 16 | $this->group = new Producers_MixpanelGroups($token, $options); |
| 17 | } |
| 18 | public static function getInstance($token, $options = array()) { |
| 19 | if(!isset(self::$_instances[$token])) { |
| 20 | self::$_instances[$token] = new Mixpanel($token, $options); |
| 21 | } |
| 22 | return self::$_instances[$token]; |
| 23 | } |
| 24 | public function enqueue($message = array()) { |
| 25 | $this->_events->enqueue($message); |
| 26 | } |
| 27 | public function enqueueAll($messages = array()) { |
| 28 | $this->_events->enqueueAll($messages); |
| 29 | } |
| 30 | public function flush($desired_batch_size = 50) { |
| 31 | $this->_events->flush($desired_batch_size); |
| 32 | } |
| 33 | public function reset() { |
| 34 | $this->_events->reset(); |
| 35 | } |
| 36 | public function identify($user_id, $anon_id = null) { |
| 37 | $this->_events->identify($user_id, $anon_id); |
| 38 | } |
| 39 | public function track($event, $properties = array()) { |
| 40 | $this->_events->track($event, $properties); |
| 41 | } |
| 42 | public function register($property, $value) { |
| 43 | $this->_events->register($property, $value); |
| 44 | } |
| 45 | public function registerAll($props_and_vals = array()) { |
| 46 | $this->_events->registerAll($props_and_vals); |
| 47 | } |
| 48 | public function registerOnce($property, $value) { |
| 49 | $this->_events->registerOnce($property, $value); |
| 50 | } |
| 51 | public function registerAllOnce($props_and_vals = array()) { |
| 52 | $this->_events->registerAllOnce($props_and_vals); |
| 53 | } |
| 54 | public function unregister($property) { |
| 55 | $this->_events->unregister($property); |
| 56 | } |
| 57 | public function unregisterAll($properties) { |
| 58 | $this->_events->unregisterAll($properties); |
| 59 | } |
| 60 | public function getProperty($property) |
| 61 | { |
| 62 | return $this->_events->getProperty($property); |
| 63 | } |
| 64 | public function createAlias($distinct_id, $alias) { |
| 65 | $this->_events->createAlias($distinct_id, $alias); |
| 66 | } |
| 67 | } |
| 68 |