Permalink
Browse files

further refactoring of tracker to support overloading of default even…

…t properties. fix for #329 #318
  • Loading branch information...
Peter Adams
Peter Adams committed Aug 26, 2018
1 parent ceb9096 commit 61f5572a1ac2f496acc179450d34f86ac21658fa
Showing with 26 additions and 25 deletions.
  1. +9 −8 modules/base/js/owa.tracker-combined-min.js
  2. +17 −17 modules/base/js/owa.tracker.js

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

Oops, something went wrong.
@@ -632,23 +632,23 @@ OWA.tracker.prototype = {
*/
setPageTitle: function(title) {
this.setGlobalEventProperty("page_title", title);
this.setGlobalEventProperty("page_title", OWA.util.trim( title ) );
},
/**
* Convienence method for setting page type
*/
setPageType : function(type) {
this.setGlobalEventProperty("page_type", type);
this.setGlobalEventProperty("page_type", OWA.util.trim( type ) );
},
/**
* Convienence method for setting user name
*/
setUserName : function( value ) {
this.setGlobalEventProperty( 'user_name', value );
this.setGlobalEventProperty( 'user_name', OWA.util.trim( value ) );
},
/**
@@ -763,9 +763,6 @@ OWA.tracker.prototype = {
if (this.active) {
// append site_id to properties
properties.site_id = this.getSiteId();
var url = this._assembleRequestUrl(properties);
var limit = this.getOption('getRequestCharacterLimit');
if ( url.length > limit ) {
@@ -2097,20 +2094,30 @@ OWA.tracker.prototype = {
*/
addDefaultsToEvent : function ( event, callback ) {
event.set( 'site_id', this.getSiteId() );
if ( ! event.get( 'page_url') ) {
if ( ! event.get( 'page_url') && ! this.getGlobalEventProperty('page_url') ) {
event.set('page_url', this.getCurrentUrl() );
}
if ( ! event.get( 'HTTP_REFERER') ) {
if ( ! event.get( 'HTTP_REFERER') && ! this.getGlobalEventProperty('HTTP_REFERER')) {
event.set('HTTP_REFERER', document.referrer );
}
if ( ! event.get( 'page_title') ) {
if ( ! event.get( 'page_title') && ! this.getGlobalEventProperty('page_title') ) {
event.set('page_title', OWA.util.trim( document.title ) );
}
if ( ! event.get( 'timestamp') ) {
event.set('timestamp', this.getTimestamp() );
}
if (callback && ( typeof( callback ) == 'function' ) ) {
callback( event );
}
@@ -2244,8 +2251,7 @@ OWA.tracker.prototype = {
if (url) {
event.set('page_url', url);
}
//is this even needed?
event.set( 'timestamp', this.getTimestamp() );
event.setEventType( "base.page_request" );
return this.trackEvent( event );
@@ -2256,8 +2262,6 @@ OWA.tracker.prototype = {
var event = new OWA.event;
event.setEventType('track.action');
event.set('site_id', this.getSiteId());
event.set('page_url', this.getCurrentUrl() );
event.set('action_group', action_group);
event.set('action_name', action_name);
event.set('action_label', action_label);
@@ -2286,10 +2290,6 @@ OWA.tracker.prototype = {
}
domstream.setEventType( 'dom.stream' );
domstream.set( 'domstream_guid', this.domstream_guid );
domstream.set( 'site_id', this.getSiteId());
domstream.set( 'page_url', this.getCurrentUrl() );
//domstream.set( 'timestamp', this.startTime);
domstream.set( 'timestamp', OWA.util.getCurrentUnixTimestamp() );
domstream.set( 'duration', this.getElapsedTime());
domstream.set( 'stream_events', JSON.stringify(this.event_queue));
domstream.set( 'stream_length', this.event_queue.length );

0 comments on commit 61f5572

Please sign in to comment.