Differentiate between localhost and live

Really? Why? There is no reason you should have path problems if you code properly and set up a proper local dev. If the local scripts are different then they should be the updated versions of the ones online. If you did proper local testing there should be no problems overwriting the ones online. That is just the basics of updating an application. The code looks rather hackish IMO.

The error display setting should be set in the Php ini, not the code. Pretty redundant to put it in every application when you can just set it once in the ini. The only place I have found it useful to dynamically determine localhost is in the DB connection. Doing it for analytics is just a hack since you can set the analytics filter to not track localhost or you can add a bit of JS to the analytics code to not track localhost or you can enclose the code in a JS Check for localhost.

If you are having havoc updating an application I have to question your methods.

Example

<script>
    var host = window.location.hostname;
    if(host != "localhost") {
	// your google analytics code goes here
    }
</script>