<commit_before>/* jshint strict: true, browser: true, nonbsp: true, bitwise: true, immed: true, latedef: true, eqeqeq: true, undef: true, curly: true, unused: true */

/**
 * @author <NAME> - https://github.com/aaronclinger/gahelper.js
 */
(function($, window, document) {
	'use strict';
	
	function GAHelper() {
		var pub         = {};
		var firstView   = true;
		pub.forceTry    = false;
		pub.timeout     = 2000;
		pub.trackerName = null;
		
		
		pub.create = function(fieldsObject) {
			if ( ! pub.isDefined()) {
				loadGA();
			}
			
			if (typeof fieldsObject === 'string') {
				fieldsObject = {
					trackingId: fieldsObject
				};
			}
			
			if (fieldsObject.name) {
				pub.trackerName = fieldsObject.name = trim(fieldsObject.name);
			} else if (typeof pub.trackerName === 'string') {
				fieldsObject.name = trim(pub.trackerName);
			}
			
			fieldsObject.cookieDomain = fieldsObject.cookieDomain || 'auto';
			
			getGA()('create', fieldsObject);
			
			return pub;
		};
		
		pub.pageview = function(fieldsObject) {
			var callback;
			var command;
			
			fieldsObject         = fieldsObject || {};
			fieldsObject.hitType = 'pageview';
			
			command = getNamedCommand('set', fieldsObject);
			
			if ( ! fieldsObject.page && ! fieldsObject.location) {
				getGA()(command, 'location', window.location.toString());
				getGA()(command, 'page', window.location.pathname.toString());
			}
			
			if (fieldsObject.clearUTM) {
				if (firstView) {
					firstView = false;
					callback  = fieldsObject.hitCallback;
					
					fieldsObject.hitCallback = function(success) {
						pub.clearUTM();
						
						if (callback) {
							callback(success);
						}
					};
				}
				
				delete fieldsObject.clearUTM;
			}
			
			return pub.send(fieldsObject);
		};
		
		pub.event = function(fieldsObject) {
			fieldsObject.hitType = 'event';
			
			return pub.send(fieldsObject);
		};
		
		pub.send = function(fieldsObject) {
			var hasHit = false;
			var callback;
			var fallback;
			var delay;
			
			if (fieldsObject.hitCallback) {
				callback = fieldsObject.hitCallback;
				
				fallback = function(success) {
					if (hasHit) {
						return;
					}
					
					hasHit = true;
					
					clearTimeout(delay);
					
					callback(success);
				};
				
				fieldsObject.hitCallback = function() {
					fallback(true);
				};
				
				delay = setTimeout(function() {
					fallback(false);
				}, pub.timeout);
			}
			
			if (pub.forceTry || pub.isLoaded() || pub.isDefined() && fieldsObject.hitType === 'pageview') {
				getGA()(getNamedCommand('send', fieldsObject), fieldsObject);
			} else if (fieldsObject.hitCallback) {
				fieldsObject.hitCallback(false);
			}
			
			return pub;
		};
		
		pub.clearUTM = function() {
			var loc     = window.location.toString();
			var hasPush = history && 'pushState' in history;
			
			if (hasPush && loc.indexOf('?') !== -1) {
				loc = loc.replace(/utm_(?:source|medium|term|content|campaign)=[^\&#]+\&*/ig, '');
				loc = loc.replace(/(\?|\&)+(?=$|#)/g, '');
				
				history.replaceState({}, '', loc);
			}
			
			return pub;
		};
		
		pub.isDefined = function() {
			return !! getGA();
		};
		<commit_msg>Small update to 'clearUTM'<commit_after>/* jshint strict: true, browser: true, nonbsp: true, bitwise: true, immed: true, latedef: true, eqeqeq: true, undef: true, curly: true, unused: true */

/**
 * @author <NAME> - https://github.com/aaronclinger/gahelper.js
 */
(function($, window, document) {
	'use strict';
	
	function GAHelper() {
		var pub         = {};
		var firstView   = true;
		pub.forceTry    = false;
		pub.timeout     = 2000;
		pub.trackerName = null;
		
		
		pub.create = function(fieldsObject) {
			if ( ! pub.isDefined()) {
				loadGA();
			}
			
			if (typeof fieldsObject === 'string') {
				fieldsObject = {
					trackingId: fieldsObject
				};
			}
			
			if (fieldsObject.name) {
				pub.trackerName = fieldsObject.name = trim(fieldsObject.name);
			} else if (typeof pub.trackerName === 'string') {
				fieldsObject.name = trim(pub.trackerName);
			}
			
			fieldsObject.cookieDomain = fieldsObject.cookieDomain || 'auto';
			
			getGA()('create', fieldsObject);
			
			return pub;
		};
		
		pub.pageview = function(fieldsObject) {
			var callback;
			var command;
			
			fieldsObject         = fieldsObject || {};
			fieldsObject.hitType = 'pageview';
			
			command = getNamedCommand('set', fieldsObject);
			
			if ( ! fieldsObject.page && ! fieldsObject.location) {
				getGA()(command, 'location', window.location.toString());
				getGA()(command, 'page', window.location.pathname.toString());
			}
			
			if (fieldsObject.clearUTM) {
				if (firstView) {
					firstView = false;
					callback  = fieldsObject.hitCallback;
					
					fieldsObject.hitCallback = function(success) {
						pub.clearUTM();
						
						if (callback) {
							callback(success);
						}
					};
				}
				
				delete fieldsObject.clearUTM;
			}
			
			return pub.send(fieldsObject);
		};
		
		pub.event = function(fieldsObject) {
			fieldsObject.hitType = 'event';
			
			return pub.send(fieldsObject);
		};
		
		pub.send = function(fieldsObject) {
			var hasHit = false;
			var callback;
			var fallback;
			var delay;
			
			if (fieldsObject.hitCallback) {
				callback = fieldsObject.hitCallback;
				
				fallback = function(success) {
					if (hasHit) {
						return;
					}
					
					hasHit = true;
					
					clearTimeout(delay);
					
					callback(success);
				};
				
				fieldsObject.hitCallback = function() {
					fallback(true);
				};
				
				delay = setTimeout(function() {
					fallback(false);
				}, pub.timeout);
			}
			
			if (pub.forceTry || pub.isLoaded() || pub.isDefined() && fieldsObject.hitType === 'pageview') {
				getGA()(getNamedCommand('send', fieldsObject), fieldsObject);
			} else if (fieldsObject.hitCallback) {
				fieldsObject.hitCallback(false);
			}
			
			return pub;
		};
		
		pub.clearUTM = function() {
			var loc     = window.location.toString();
			var hasPush = ('history' in window) && ('pushState' in window.history);
			
			if (hasPush && loc.indexOf('?') !== -1) {
				loc = loc.replace(/utm_(?:source|medium|term|content|campaign)=[^\&#]+\&*/ig, '');
				loc = loc.replace(/(\?|\&)+(?=$|#)/g, '');
				
				window.history.replaceState({}, '', loc);
			}
			
			return pub;
		};
		
		pub.isDefined = function() {
			return !! getGA();
		};
		
{'fraction_non_alphanumeric': 0.15391864300298413, 'fraction_numerical': 0.001570598397989634, 'mean_word_length': 2.5936794582392775, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6087735', 'n_tokens_mistral': 2731, 'n_tokens_neox': 2013, 'n_words': 391}