$config = $defaultConfig; } // Create hub $trackerHub = new TrackerHub(); // Add customer.io client if ($config['customer_io']['site_id']) { $customerIOClient = new CustomerIO($config['customer_io']['site_id'], $config['customer_io']['api_key']); $trackerHub->addClient($customerIOClient); echoLog('Added customer.io client'); } // Add mixpanel client if ($config['mixpanel']['write_token']) { $mixpanelClient = new Mixpanel($config['mixpanel']['write_token']); $trackerHub->addClient($mixpanelClient); echoLog('Added mixpanel client'); } // Add indicative client if ($config['indicative']['api_key']) { $indicativeClient = new Indicative($config['indicative']['api_key']); $trackerHub->addClient($indicativeClient); echoLog('Added indicative client'); } // Identify an user $user = array('user_id' => 101, 'params' => array('first_name' => 'Quan', 'last_name' => 'MT', 'email' => '*****@*****.**')); $trackerHub->identify($user['user_id'], $user['params']); echoLog('Sent identify ' . serialize($user)); // Track an event $event = array('user_id' => 101, 'event' => 'Add Offer', 'params' => array('type' => 'Cross-sell')); $trackerHub->track($event['user_id'], $event['event'], $event['params']); echoLog('Sent track ' . serialize($event));
<?php require_once "Logger.php"; function loggStuff() { loggHeader("A header"); loggThis("write a message"); loggThis("include call trace", null, true); loggThis("include an object", new \Exception("foo exception"), false); } loggStuff(); //show log //do not dump superglobals echoLog(false); //show with superglobals echoLog();
// Do what you want with the data... // Have fun ! // For example echoLog(' - Timestamp: ' . $json['message']['timestamp']); echoLog(' - Uploader ID: ' . $json['header']['uploaderID']); echoLog(' - System Name: ' . $json['message']['systemName']); echoLog(' - Station Name: ' . $json['message']['stationName']); foreach ($json['message']['commodities'] as $commodity) { echoLog(' - Name: ' . $commodity['name']); echoLog(' - Buy Price: ' . $commodity['buyPrice']); echoLog(' - Supply: ' . $commodity['supply'] . (array_key_exists('supplyLevel', $commodity) ? ' (' . $commodity['supplyLevel'] . ')' : '')); echoLog(' - Sell Price: ' . $commodity['sellPrice']); echoLog(' - Demand: ' . $commodity['demand'] . (array_key_exists('demandLevel', $commodity) ? ' (' . $commodity['demandLevel'] . ')' : '')); } // End example } unset($authorised, $excluded); echoLog(''); echoLog(''); } unset($converted); } } catch (ZMQSocketException $e) { echoLog(''); echoLog('ZMQSocketException: ' . $e); echoLog(''); sleep(10); } } // Exit correctly exit(0);