PageSourceSearch

https://climateeducation.ca/wp-content/mu-plugins/ubc-google-analytics/js/ubc-google-analytics-shim.js

js climateeducation.ca collected 2026-10-04 01:35:08 UTC 2,640 bytes, 116 lines download raw bytes

1
2
3	var newXHR,
4		getTrackerErrorDataAjax,
5		errorWatchInit,
6		vanillaJsAjax,
7		serialize,
8		reqListener;
9
10	// create event tracker object shim
11	pageTracker2 = {};
12
13	/**
14	* create method based off our pageTracker2 object for track event
15	* @return null
16	*/
17
18	pageTracker2._trackEvent = function( a, b, c, d, e ) {
19
20		ga( 'pageTracker2.send', 'event', a, b, c, d, e );
21
22	};
23
24	/**
25	 * Ajax response
26	 */
27	reqListener = function () {
28
29		if ( this.status !== 200 ) {
30
31			console.log('Response: ' + this.status);
32			console.log( 'UBC Google Analytics Shim' );
33
34		}
35	}
36
37	 /**
38	 * Serialize string object into url param
39	 * @param string obj - the object
40	 */
41
42	serialize = function (obj) {
43		var str = [];
44		for (var p in obj)
45			if (obj.hasOwnProperty(p)) {
46				str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
47			}
48		return str.join("&");
49	};
50
51	 /**
52	 * Capture errors based off our selection
53	 * @param string msg - the js error message
54	 * @param string path - the js file the error originated
55	 * @param string ajaxFile - site/admin-ajax.php
56	 * @param string windowlocation - the url the js error originated
57	 * @param string nonce
58	 */
59
60	vanillaJsAjax = function ( jsError ) {
61
62		// Setup up a XHR object
63		newXHR = new XMLHttpRequest();
64
65		// after load show response message
66		newXHR.addEventListener('load', reqListener);
67
68		// Gather what we need for our reponse
69		var msg =  jsError.message,
70			path = jsError.filename,
71			windowlocation = window.location.href,
72			nonce = js_errors.nonce,
73			currentdate = new Date(),
74			datetime = currentdate.getDate() + '/' + (currentdate.getMonth() + 1) + '/' + currentdate.getFullYear() + ' @ ' + currentdate.getHours() + ':' + currentdate.getMinutes(),
75			data = { action: 'ubc_ga_track_tracker_error', errorMsg: msg, errorUrl: path, postUrl: windowlocation, theDate: datetime, getNonce : nonce },
76			serializeToUrlParam = serialize(data); 
77
78		// Open connection with admin-ajax.php
79		newXHR.open('POST', js_errors.wpajaxurl );
80
81		// The content type of the data being sent
82		newXHR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
83
84		// Send our data
85		newXHR.send(serializeToUrlParam );
86
87	};
88
89	// // End getTrackerErrorDataAjax()
90
91	/**
92	* addEventListener for error with a casual search criteria
93	* @param string searchTerm - search word(s)
94	*/
95
96	errorWatchInit = function( searchTerm ) {
97
98		window.addEventListener( 'error', function( e )  {
99
100			// Test if the error message is the one we want
101			if ( e.message.indexOf( searchTerm ) >= 0 ) {
102
103				vanillaJsAjax( e );
104
105			}
106
107		} );
108
109	};
110	//End errorWatchInit()
111
112
113	errorWatchInit( 'pageTracker2' );
114
115
116

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.