1"use strict"; 2 3// Remote logging lib; required jQuery 4 5function getCookieByName(name, fallbackValueIfNotFound) { 6 var value = "; " + document.cookie; 7 var parts = value.split("; " + name + "="); 8 if (parts.length == 2) { 9 return parts.pop().split(";").shift(); 10 } else { 11 return fallbackValueIfNotFound; 12 } 13} 14 15function addPropertyToObjectIfValueNotEmpty(obj, propName, propValue) { 16 if(propValue) { 17 obj[propName] = propValue; 18 } 19} 20 21function logRemotely(category, level, message, details) { 22 try { 23 if (window._LTracker == null) { 24 window._LTracker = []; 25 26 var url = '' + window.location; 27 // remove trialing params 28 var lastPos = url.lastIndexOf('?'); 29 lastPos = lastPos >= 0 ? lastPos : url.lastIndexOf('#'); 30 var urlNoParams = lastPos >= 0 ? url.substring(0, lastPos) : url; 31 // remove protocols 32 var doubleSlashesPos = urlNoParams.indexOf("//"); 33 var urlNoProtocol = doubleSlashesPos >= 0 ? urlNoParams.substring(doubleSlashesPos + "//".length) : urlNoParams; 34 // replace 35 var urlTagName = urlNoProtocol.replace(/[^\w.]/g, '_'); 36 37 window._LTracker.push({ 38 'logglyKey': 'e44415b5-8bb0-483d-acf6-c9ac32d771fb', 39 'sendConsoleErrors': false, // don't send console errors 40 'tag': urlTagName 41 }); 42 } 43 44 var logObj = { 45 'cat': category, 46 'level': level, 47 'message': message 48 }; 49 50 if (details) { 51 logObj['details'] = details; 52 } 53 54 try { 55 addPropertyToObjectIfValueNotEmpty(logObj, 'aui', getCookieByName('AUI')); 56 addPropertyToObjectIfValueNotEmpty(logObj, 'ami', getCookieByName('AMI')); 57 } catch (err) { 58 console.error(err); 59 } 60 61 window._LTracker.push(logObj); 62 63 logglyJsLoad(2); 64 } catch (lerr) { 65 console.error("Failed to log: " + message + '; error: ' + lerr); 66 } 67} 68 69/** returns true only if loggly.tracker.js has been executed */ 70function logglyJsIsLoaded() { 71 return window._LTracker != null && ! Array.isArray(window._LTracker); 72} 73 74function logglyJsLoad(maxAttempts) { 75 if(logglyJsIsLoaded()) { 76 return; 77 } 78 79 console.log("logglyJsLoad called with maxAttempts: " + maxAttempts + " ..."); 80 maxAttempts = (typeof(maxAttempts)==='undefined') ? 3 : maxAttempts; 81 82 if(! (maxAttempts >= 1)) { // runs out of attempts 83 console.log("logglyJsLoad cancelled as maxAttempts is: " + maxAttempts); 84 return; 85 } 86 87 if(window['logglyJsDownloading']) { // downloading in 88 console.log("logglyJsLoad cancelled as downloading is in progress."); 89 return; 90 } 91 92 window['logglyJsDownloading'] = true; 93 window['logglyJsDownloadAttempts'] = window['logglyJsDownloadAttempts'] ? (window['logglyJsDownloadAttempts'] + 1) : 1; 94 $.getScript( "https://cloudfront.loggly.com/js/loggly.tracker-latest.min.js" ) // https://aspr.loggly.com/sources/setup/js-app-setup 95 .done(function( script, textStatus ) { 96 setTimeout(function () { 97 window['logglyJsDownloading'] = false; // mark the end 98 if (logglyJsIsLoaded()) { 99 console.log("loggly js loaded."); 100 } else { 101 logglyJsLoad(maxAttempts - 1); // trigger download 102 } 103 }, 1000); // assume execution of the loggly js takes max 1s 104 }) 105 .fail(function( jqXHR, textStatus, errorThrown ) { 106 setTimeout(function () { 107 window['logglyJsDownloading'] = false; // mark the end 108 if (logglyJsIsLoaded()) { 109 console.log("loggly js loaded."); 110 } else { 111 logglyJsLoad(maxAttempts - 1); // trigger download 112 } 113 }, 1000); // assume execution of the loggly js takes max 1s 114 }); 115}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.