public static function trackActor($email, $action, $properties = array()) { if (class_exists('\\Activity\\Models\\Actions')) { \Activity\Models\Actions::trackActor($email, $action, $properties); } if (class_exists('\\Admin\\Models\\Settings') && class_exists('\\KM')) { $settings = \Admin\Models\Settings::fetch(); if ($settings->enabledIntegration('kissmetrics') && $settings->{'integration.kissmetrics.key'}) { \KM::init($settings->{'integration.kissmetrics.key'}); \KM::identify($email); \KM::record($action, $properties); } } return null; }
$host_port = explode(':', self::$host); $get = 'GET ' . $query . " HTTP/1.1\r\n"; $fp = fsockopen($host_port[0], $host_port[1], $errno, $errstr, 30); if (!$fp) { self::log_error("Failed to create socket " . self::$host . " : {$errstr} ({$errno})\n"); self::log_query($query); } else { stream_set_blocking($fp, 0); // If mode is 0, the given stream will be switched to non-blocking mode, and if 1, it will be switched to blocking mode. $out = $get; $out .= "Host:" . self::$host . "\r\n"; $out .= "Connection: Close\r\n\r\n"; $write_success = fwrite($fp, $out); if (!$write_success) { self::log_error("Failed to send query: {$query}"); self::log_query($query); } fclose($fp); } } catch (Exception $e) { throw new Exception($e->getMessage() . "for host " . self::$host); } } } if (basename(KM::array_get($_SERVER, 'SCRIPT_NAME')) == basename(__FILE__)) { if (!KM::array_get($argv, 1)) { error_log("At least one argument required. km.php <km_key> [<log_dir>]"); } KM::init(KM::array_get($argv, 1), array('log_dir' => KM::array_get($argv, 2, KM::$log_dir, true), 'host' => KM::array_get($argv, 3, KM::$host, true))); KM::send_logged_queries(); }
<?php use lithium\core\Libraries; $_config = Libraries::get('li3_kissmetrics'); if (isset($_config['key']) && !empty($_config['key'])) { if (!isset($_config['options'])) { $_config['options'] = array(); } if (!isset($_config['options']['log_dir']) || empty($_config['options']['log_dir'])) { $_config['options']['log_dir'] = Libraries::get(true, 'resources') . '/tmp/logs'; } \KM::init($_config['key'], $_config['options']); } unset($_config);