Fix analytics to only happen in production mode
Fix analytics to only happen in production mode
Add analytic event for geocoding

--- a/common.inc.php
+++ b/common.inc.php
@@ -4,6 +4,7 @@
 $cloudmadeAPIkey="daa03470bb8740298d4b10e3f03d63e6";
 $googleMapsAPIkey="ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q";
 $otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/';
+$owaSiteID = 'fe5b819fa8c424a99ff0764d955d23f3';
 if (isDebug()) error_reporting(E_ALL ^ E_NOTICE);
 
 // SELECT array_to_string(array(SELECT REPLACE(name_2006, ',', '\,') as name FROM suburbs order by name), ',')
@@ -18,20 +19,38 @@
    $_SESSION['time'] = filter_var($_REQUEST['time'],FILTER_SANITIZE_STRING);
  }
  if (isset($_REQUEST['geolocate'])) {
+   $geocoded = false;
    if (isset($_REQUEST['lat']) && isset($_REQUEST['lon'])) {
       $_SESSION['lat'] = $_REQUEST['lat'];
         $_SESSION['lon'] = $_REQUEST['lon'];
    } else {
     $contents = geocode(filter_var($_REQUEST['geolocate'],FILTER_SANITIZE_URL),true);
     if (isset($contents[0]->centroid)) {
+      $geocoded = true;
         $_SESSION['lat'] = $contents[0]->centroid->coordinates[0];
         $_SESSION['lon'] = $contents[0]->centroid->coordinates[1];
-    }
-    else {
+      }
+      else {
         $_SESSION['lat'] = "";
         $_SESSION['lon'] = "";
     }
    }
+   if ($_SESSION['lat'] != "" && isMetricsOn()) {
+// Create a new Instance of the tracker
+$owa = new owa_php($config);
+// Set the ID of the site being tracked
+$owa->setSiteId($owaSiteID);
+// Create a new event object
+$event = $owa->makeEvent();
+// Set the Event Type, in this case a "video_play"
+$event->setEventType('geolocate');
+// Set a property
+$event->set('lat',$_SESSION['lat']);
+$event->set('lon',$_SESSION['lon']);
+$event->set('geocoded',$geocoded);
+// Track the event
+$owa->trackEvent($event);
+    }
  }
 debug(print_r($_SESSION,true));
 function isDebug()
@@ -41,11 +60,11 @@
 
 function isMetricsOn()
 {
-    return false;
+    return !isDebug();
 }
 
 function debug($msg) {
-    if (isDebug()) echo "\n<!-- $msg -->\n";
+    if (isDebug()) echo "\n<!-- ".date(DATE_RFC822)."\n $msg -->\n";
 }
 function isFastDevice() {
    $ua = $_SERVER['HTTP_USER_AGENT']; 
@@ -128,7 +147,8 @@
     require_once('owa/owa_env.php');
     require_once(OWA_DIR.'owa_php.php');
     $owa = new owa_php();
-    $owa->setSiteId('bus.lambdacomplex.org');
+    global $owaSiteID;
+    $owa->setSiteId($owaSiteID);
     $owa->setPageTitle($pageTitle);
     $owa->setPageType($pageType);
     $owa->trackPageView();
@@ -460,7 +480,7 @@
 	        </div>
     		<div data-role="fieldcontain">
 		        <label for="time"> Time: </label>
-		    	<input type="time" name="time" id="time" value="'. (isset($_SESSION['time']) ? $_SESSION['time'] : date("H:m")).'"/> <a href="#" name="currentTime" id="currentTime"/>Current Time?</a>
+		    	<input type="time" name="time" id="time" value="'. (isset($_SESSION['time']) ? $_SESSION['time'] : date("H:i")).'"/> <a href="#" name="currentTime" id="currentTime"/>Current Time?</a>
 	        </div>
 		<div data-role="fieldcontain">
 		    <label for="service_period"> Service Period:  </label>

file:a/stop.php -> file:b/stop.php
--- a/stop.php
+++ b/stop.php
@@ -6,9 +6,9 @@
 include_header($stop[1],"stop");
 if (isMetricsOn()) {
 // Create a new Instance of the tracker
-$owa = new owa_php($config);
+$owa = new owa_php();
 // Set the ID of the site being tracked
-$owa->setSiteId('bus.lambdacomplex.org');
+$owa->setSiteId($owaSiteID);
 // Create a new event object
 $event = $owa->makeEvent();
 // Set the Event Type, in this case a "video_play"

--- a/stopList.php
+++ b/stopList.php
@@ -42,7 +42,7 @@
 // Create a new Instance of the tracker
 $owa = new owa_php($config);
 // Set the ID of the site being tracked
-$owa->setSiteId('bus.lambdacomplex.org');
+$owa->setSiteId($owaSiteID);
 // Create a new event object
 $event = $owa->makeEvent();
 // Set the Event Type, in this case a "video_play"

file:a/trip.php -> file:b/trip.php
--- a/trip.php
+++ b/trip.php
@@ -21,9 +21,9 @@
 include_header("Stops on ". $trips[1]->route_short_name . ' '. $trips[1]->route_long_name,"trip");
 if (isMetricsOn()) {
 // Create a new Instance of the tracker
-$owa = new owa_php($config);
+$owa = new owa_php();
 // Set the ID of the site being tracked
-$owa->setSiteId('bus.lambdacomplex.org');
+$owa->setSiteId($owaSiteID);
 // Create a new event object
 $event = $owa->makeEvent();
 // Set the Event Type, in this case a "video_play"

--- a/tripPlanner.php
+++ b/tripPlanner.php
@@ -4,7 +4,7 @@
   $from = (isset($_REQUEST['from']) ? filter_var($_REQUEST['from'],FILTER_SANITIZE_STRING) : "Brigalow");
       $to = (isset($_REQUEST['to']) ? filter_var($_REQUEST['to'],FILTER_SANITIZE_STRING) : "Barry");
       $date = (isset($_REQUEST['date']) ? filter_var($_REQUEST['date'],FILTER_SANITIZE_STRING) : date("m/d/Y"));
-      $time = (isset($_REQUEST['time']) ? filter_var($_REQUEST['time'],FILTER_SANITIZE_STRING) : date("H:m"));
+      $time = (isset($_REQUEST['time']) ? filter_var($_REQUEST['time'],FILTER_SANITIZE_STRING) : date("H:i"));
       # todo: convert date from form to h:ia?
 
   function tripPlanForm($errorMessage = "")
@@ -100,9 +100,9 @@
       } else {
         if (isMetricsOn()) {
 // Create a new Instance of the tracker
-$owa = new owa_php($config);
+$owa = new owa_php();
 // Set the ID of the site being tracked
-$owa->setSiteId('bus.lambdacomplex.org');
+$owa->setSiteId($owaSiteID);
 // Create a new event object
 $event = $owa->makeEvent();
 // Set the Event Type, in this case a "video_play"