From 0e63a76ecaeda32ee0bdc98d236a1361a16ff57f Mon Sep 17 00:00:00 2001
From: robocoder <anthon.pang@gmail.com>
Date: Tue, 24 Jul 2012 01:06:15 +0000
Subject: [PATCH] fixes #1320 - output tracking pixel at start of request to
 increase perceived tracker responsiveness

the tradeoff is the loss of some user-readable text in non-debug mode for empty requests and exceptions

(arguably, we probably shouldn't have been outputing e->getMessage() in non-debug mode)



git-svn-id: http://dev.piwik.org/svn/trunk@6539 59fd770c-687e-43c8-a1e3-f5a4ff64c105
---
 core/Tracker.php | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/core/Tracker.php b/core/Tracker.php
index 6fc6ca4c98..334b90b6fb 100644
--- a/core/Tracker.php
+++ b/core/Tracker.php
@@ -149,6 +149,8 @@ class Piwik_Tracker
 	 */
 	public function main()
 	{
+		$this->outputTransparentGif();
+
 		if (!empty($this->requests))
 		{
 			// handle all visits
@@ -232,19 +234,16 @@ class Piwik_Tracker
 		{
 			case self::STATE_LOGGING_DISABLE:
 				printDebug("Logging disabled, display transparent logo");
-				$this->outputTransparentGif();
 			break;
 
 			case self::STATE_EMPTY_REQUEST:
 				printDebug("Empty request => Piwik page");
-				echo "<a href='/'>Piwik</a> is a free open source <a href='http://piwik.org'>web analytics</a> alternative to Google analytics.";
 			break;
 
 			case self::STATE_NOSCRIPT_REQUEST:
 			case self::STATE_NOTHING_TO_NOTICE:
 			default:
 				printDebug("Nothing to notice => default behaviour");
-				$this->outputTransparentGif();
 			break;
 		}
 		printDebug("End of the page.");
@@ -620,21 +619,16 @@ if(!function_exists('printDebug'))
 function Piwik_Tracker_ExitWithException($e)
 {
 	Piwik_Common::sendHeader('Content-Type: text/html; charset=utf-8');
+
 	if(isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG'])
 	{
 		$trailer = '<font color="#888888">Backtrace:<br /><pre>'.$e->getTraceAsString().'</pre></font>';
-	}
-	else
-	{
-		$trailer = '<p>Edit the following line in piwik.php to enable tracker debugging and display a backtrace:</p>
-					<blockquote><pre>$GLOBALS[\'PIWIK_TRACKER_DEBUG\'] = true;</pre></blockquote>';
-	}
-
-	$headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/themes/default/simple_structure_header.tpl');
-	$footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/themes/default/simple_structure_footer.tpl');
-	$headerPage = str_replace('{$HTML_TITLE}', 'Piwik &rsaquo; Error', $headerPage);
+		$headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/themes/default/simple_structure_header.tpl');
+		$footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/themes/default/simple_structure_footer.tpl');
+		$headerPage = str_replace('{$HTML_TITLE}', 'Piwik &rsaquo; Error', $headerPage);
 
-	echo $headerPage . '<p>' . $e->getMessage() . '</p>' . $trailer . $footerPage;
+		echo $headerPage . '<p>' . $e->getMessage() . '</p>' . $trailer . $footerPage;
+	}
 
 	exit;
 }
-- 
GitLab