Permalink
Browse files

refactored php tracker to set page_url as a global property.

refactored both php and js trackers to only set global properties if they have not already ben set on the event.
moved the setting of page_url from processEvent controller into the php tracking client where it belongs. This helps fix an exception that was being thrown if you just called log.php directly with no params.
  • Loading branch information...
padams
padams committed Mar 31, 2012
1 parent a4d9290 commit 24d43620fbd7445c45feea9132d90e868d99d60e
View
@@ -17,7 +17,7 @@
//
require_once('owa_env.php');
-require_once(OWA_DIR.'owa_php.php');
+require_once(OWA_DIR.'owa_caller.php');
require_once(OWA_BASE_CLASS_DIR.'cliController.php');
/**
@@ -57,7 +57,7 @@
}
// Initialize owa
-$owa = new owa_php;
+$owa = new owa_caller;
if ( $owa->isEndpointEnabled( basename( __FILE__ ) ) ) {
@@ -53,6 +53,8 @@ public function __construct($config = null) {
$this->pageview_event = $this->makeEvent();
$this->pageview_event->setEventType('base.page_request');
+ // Set the page url from environmental vars
+ $this->setGlobalEventProperty( 'page_url', owa_lib::get_current_url() );
owa_coreAPI::registerStateStore('v', time()+3600*24*365*10, '', 'assoc', 'cookie', true);
owa_coreAPI::registerStateStore('s', time()+3600*24*365*10, '', 'assoc', 'cookie', true);
owa_coreAPI::registerStateStore('b', null, '', 'json', 'cookie', true);
@@ -405,9 +407,7 @@ public function setAllGlobalEventProperties( $event ) {
}
// merge global event properties
- foreach ($this->global_event_properties as $k => $v) {
- $event->set($k, $v);
- }
+ $event->setNewProperties( $this->global_event_properties );
return $event;
@@ -469,9 +469,9 @@ public function addTransaction(
$this->commerce_event->set( 'ct_gateway', $gateway );
$this->commerce_event->set( 'page_url', $page_url );
$this->commerce_event->set( 'ct_line_items', array() );
- $this->commerce_event->set( 'country', $page_url );
- $this->commerce_event->set( 'state', $page_url );
- $this->commerce_event->set( 'city', $page_url );
+ $this->commerce_event->set( 'country', $country );
+ $this->commerce_event->set( 'state', $state );
+ $this->commerce_event->set( 'city', $city );
if ( $session_id ) {
$this->commerce_event->set( 'original_session_id', $session_id );
// tells the client to NOT manage state properties as we are
@@ -123,7 +123,7 @@ function get_location($location_map) {
$country = $country_parts[0];
// if there is a second element then it's a country code.
if ( isset($country_parts[1] ) ) {
- $country_code = substr($country_code,0,-1);
+ $country_code = substr($country_parts[1],0,-1);
}
// debug
owa_coreAPI::debug('Parse of Hostip country string: '.$result['Country'].' c: '. $country.' cc: '.$country_code);
@@ -1,4 +1,4 @@
-/* OWA owa.reporting-css package file created Fri, 30 Mar 12 16:44:44 -0400 */
+/* OWA owa.reporting-css package file created Sat, 31 Mar 12 14:33:58 -0400 */
/* Start of jqueryui */

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -71,6 +71,14 @@ OWA.event.prototype = {
this.set(param, properties[param]);
}
}
+ },
+
+ isSet : function( name ) {
+
+ if ( this.properties.hasOwnProperty( name ) ) {
+
+ return true;
+ }
}
}
@@ -926,7 +934,13 @@ OWA.tracker.prototype = {
OWA.debug( 'Adding global properties to event: %s', JSON.stringify(this.globalEventProperties) );
for ( prop in this.globalEventProperties ) {
- event.set( prop, this.globalEventProperties[prop] );
+
+ // only set global properties is they are not already set on the event
+ if ( this.globalEventProperties.hasOwnProperty( prop )
+ && ! event.isSet( prop ) )
+ {
+ event.set( prop, this.globalEventProperties[prop] );
+ }
}
},
@@ -119,9 +119,9 @@ function pre() {
$this->event->set( 'page_type', $this->eq->filter( 'page_type', $this->event->get( 'page_type' ) ) );
// Set the page url or else construct it from environmental vars
- if (!$this->event->get('page_url')) {
- $this->event->set('page_url', owa_lib::get_current_url());
- }
+ //if (!$this->event->get('page_url')) {
+ // $this->event->set('page_url', owa_lib::get_current_url());
+ //}
// filter page_url
$this->event->set( 'page_url', $this->eq->filter( 'page_url', $this->event->get( 'page_url' ), $this->event->get( 'site_id' ) ) );
// set document/page id

0 comments on commit 24d4362

Please sign in to comment.