Skip to content

Commit

Permalink
Merge pull request #112 from pantheon-systems/tracking
Browse files Browse the repository at this point in the history
Add tracking codes for kibana
  • Loading branch information
mikevanwinkle committed Feb 12, 2015
2 parents 3927c50 + 28b6fa9 commit 30d1592
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions php/Terminus/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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;
Expand Down Expand Up @@ -59,6 +60,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") ) {
Expand All @@ -74,6 +77,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);
Expand Down
7 changes: 6 additions & 1 deletion php/terminus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 30d1592

Please sign in to comment.