From 28b6fa904a162b131a4674b76487ceed309b6844 Mon Sep 17 00:00:00 2001 From: Mike Van Winkle Date: Thu, 5 Feb 2015 23:54:25 +0000 Subject: [PATCH] Add tracking codes for kibana --- php/Terminus/Request.php | 8 ++++++++ php/terminus.php | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/php/Terminus/Request.php b/php/Terminus/Request.php index cf950a51f..1188b619c 100755 --- a/php/Terminus/Request.php +++ b/php/Terminus/Request.php @@ -26,6 +26,7 @@ public static function send($url, $method, $data = array()) { } // create a new Guzzle\Http\Client $browser = new Browser; + $browser->setUserAgent(self::userAgent()); $options = array(); $options['allow_redirects'] = @$data['allow_redirects'] ?: false; $options['json'] = @$data['json'] ?: false; @@ -58,6 +59,8 @@ public static function send($url, $method, $data = array()) { $debug = "#### REQUEST ####".PHP_EOL; $debug .= $request->getRawHeaders(); \Terminus\Loggers\Regular::debug($debug); + if (isset($data['body'])) + \Terminus\Loggers\Regular::debug($data['body']); } if ( getenv("BUILD_FIXTURES") ) { @@ -73,6 +76,11 @@ public static function send($url, $method, $data = array()) { return $response; } + static function userAgent() { + $agent = sprintf("Terminus/%s (php_version=%s&script=%s)", constant('TERMINUS_VERSION'), phpversion(), constant('TERMINUS_SCRIPT')); + return $agent; + } + public static function download($url,$target) { // @todo use Guzzle in the future, but for now this will do $ch = curl_init($url); diff --git a/php/terminus.php b/php/terminus.php index 3ec202c38..fe45481f9 100755 --- a/php/terminus.php +++ b/php/terminus.php @@ -2,8 +2,13 @@ // Can be used by plugins/themes to check if Terminus is running or not define( 'Terminus', true ); define( 'TERMINUS_VERSION', '0.4-beta'); +$source = 'unknown'; +if ('cli' === PHP_SAPI && isset($argv)) { + $source = explode('/',$argv[0]); + $source = end($source); +} +define('TERMINUS_SCRIPT',$source); date_default_timezone_set('UTC'); - include TERMINUS_ROOT . '/php/utils.php'; include TERMINUS_ROOT . '/php/login.php'; include TERMINUS_ROOT . '/php/FileCache.php';