/** * Logging Component * * This section uses system & user-assigned variables to * create a meaningful entry in the uuid webserver access * log. */ /** * LogEntry class encapsulates user and system-defined parameters */ function LogEntry() { // public fields with default values // // these fields can be modified by the client // using accessor methods defined below this.dob = ''; this.zip = ''; this.userId = ''; this.searchRadius = ''; this.searchCategory = ''; this.searchFilterCategory = ''; this.searchFilterKeyword = ''; this.eventDetailName = ''; this.searchGenre = ''; this.outpostVendorName = ''; this.outpostChannel = ''; this.outpostDesign = ''; this.outpostCopy = ''; this.depth = ''; // public accessors to override default values // this.setDob = new Function("dob", "this.dob = dob;"); this.setZip = new Function("zip", "this.zip = zip;"); this.setUserId = new Function("userId", "this.userId = userId;"); this.setSearchRadius = new Function("searchRadius", "this.searchRadius = searchRadius;"); this.setSearchCategory = new Function("searchCategory", "this.searchCategory = searchCategory;"); this.setSearchFilterCategory = new Function("searchFilterCategory", "this.searchFilterCategory = searchFilterCategory;"); this.setSearchFilterKeyword = new Function("searchFilterKeyword", "this.searchFilterKeyword = searchFilterKeyword;"); this.setEventDetailName = new Function("eventDetailName", "this.eventDetailName = eventDetailName;"); this.setSearchGenre = new Function("searchGenre", "this.searchGenre = searchGenre;"); this.setOutpostVendorName = new Function("outpostVendorName", "this.outpostVendorName = outpostVendorName;"); this.setOutpostChannel = new Function("outpostChannel", "this.outpostChannel = outpostChannel;"); this.setOutpostDesign = new Function("outpostDesign", "this.outpostDesign = outpostDesign;"); this.setOutpostCopy = new Function("outpostCopy", "this.outpostCopy = outpostCopy;"); this.setDepth = new Function("depth", "this.depth = depth;"); // private fields // // these fields are set from the DOM this.clientHost = document.location.host; var stringArray = new String(document.location.pathname).split("/"); if (stringArray.length > 1) { this.clientContextPath = stringArray[1]; } else { this.clientContextPath = ""; } this.clientReferer = document.referrer; this.clientTitle = document.title; this.clientURL = document.URL; this.browserLanguage = getBrowserLanguage(); // private methods used by Logger // this.getSystemParams = LogEntryGetSystemParams; this.getUserParams = LogEntryGetUserParams; this.getLUID = LogEntryGetLUID; } /** * member function to concatenate system params that can be extracted from context */ function LogEntryGetSystemParams() { var queryStr = "&_host=" + escape(this.clientHost) + "&_referrer=" + escape(this.clientReferer) + "&_title=" + escape(this.clientTitle) + "&_lang=" + escape(this.browserLanguage) + "&_url=" + escape(this.clientURL) ; return queryStr; } /** * member function to concatenate params that are provided by application developers */ function LogEntryGetUserParams() { var queryStr = "&_dob=" + escape(this.dob) + "&_zip=" + escape(this.zip) + "&_luid=" + escape(this.getLUID()) + "&_srchradius=" + escape(this.searchRadius) + "&_srchcat=" + escape(this.searchCategory) + "&_srchfltrcat=" + escape(this.searchFilterCategory) + "&_srchfltrkywd=" + escape(this.searchFilterKeyword) + "&_evtdtlnm=" + escape(this.eventDetailName) + "&_srchgenre=" + escape(this.searchGenre) + "&_outpostvndrnm=" + escape(this.outpostVendorName) + "&_outpostchnl=" + escape(this.outpostChannel) + "&_outpostdsgn=" + escape(this.outpostDesign) + "&_outpostcpy=" + escape(this.outpostCopy) + "&_depth=" + escape(this.depth) ; return queryStr; } /** * Member function to create the LUID from the shorthand appname and userId */ function LogEntryGetLUID() { if (this.userId.length > 0) return this.userId; else return ''; } /** * Public function to initiate logging */ function log(logEntry) { // construct logging url loggingURL = getTrackingURL(); queryStr = '?a=a'; // add automatic parameters to query string queryStr += logEntry.getSystemParams(); // add developer-provided params to query str queryStr += logEntry.getUserParams(); // add the cache-busting parameter; queryStr += getRandomParam() // execute log request loggingImg = new Image(); loggingImg.src = (loggingURL + queryStr); } /** * Private function to build the URL to */ function getServerURL() { // scheme for protocol var loggingScheme = "http://"; // host name for logging server var loggingHost = "beer.millerbrewing.com"; // context path for logging server // -- "/" if talking to ROOT webapp var loggingContextPath = "/tracking"; var loggingURL = loggingScheme + loggingHost + loggingContextPath ; return loggingURL; } /** * Private function to build a logged request to the pagedot */ function getTrackingURL() { // the tracking server returns 1x1 invisible gif for all gif requests. var loggingGif = "/1pixel.gif"; var loggingURL = getServerURL() + loggingGif; return loggingURL; } /** * Private function to return a random name/value pairs * r1 = unix time in millis * r2 = random num between 0 and 1 */ function getRandomParam() { var r1 = new Date().valueOf(); var r2 = Math.random(); return ("&_r1=" + r1 + "&_r2=" + r2); } /** * Private function to determine browser language * */ function getBrowserLanguage() { var lang = ""; if ( navigator.userAgent.indexOf("MSIE") > -1 ) lang = navigator.browserLanguage; else lang = navigator.language; return lang.toLowerCase(); }