analytics-utils
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.1.1](https://github.com/DavidWells/analytics/compare/analytics-utils@0.1.0...analytics-utils@0.1.1) (2019-08-14) | ||
**Note:** Version bump only for package analytics-utils | ||
# [0.1.0](https://github.com/DavidWells/analytics/compare/analytics-utils@0.0.22...analytics-utils@0.1.0) (2019-07-13) | ||
@@ -8,0 +16,0 @@ |
@@ -73,34 +73,2 @@ var analyticsUtils = (function (exports) { | ||
function hasAdblock() { | ||
if (!inBrowser) return false; // Create fake ad | ||
var fakeAd = document.createElement('div'); | ||
fakeAd.innerHTML = ' '; | ||
fakeAd.className = 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'; | ||
fakeAd.style = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'; | ||
try { | ||
// insert into page | ||
document.body.appendChild(fakeAd); | ||
if (document.body.getAttribute('abp') !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) { | ||
return true; | ||
} | ||
if (typeof getComputedStyle !== 'undefined') { | ||
var css = window.getComputedStyle(fakeAd, null); | ||
if (css && (css.getPropertyValue('display') === 'none' || css.getPropertyValue('visibility') === 'hidden')) { | ||
return true; | ||
} | ||
} // remove from page | ||
document.body.removeChild(fakeAd); | ||
} catch (e) {// swallow errors | ||
} | ||
return false; | ||
} | ||
function getBrowserLocale() { | ||
@@ -184,27 +152,2 @@ if (!inBrowser) return null; | ||
function onRouteChange() { | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noOp; | ||
if (!inBrowser) return; | ||
var _window = window, | ||
addEventListener = _window.addEventListener, | ||
history = _window.history, | ||
location = _window.location; // Observe native navigation | ||
addEventListener('popstate', function () { | ||
callback(location.pathname); | ||
}); // Observe manual navigation | ||
var methods = ['push', 'replace']; | ||
methods.map(function (type) { | ||
// eslint-disable-line | ||
var state = "".concat(type, "State"); | ||
var historyState = history[state]; | ||
history[state] = function () { | ||
callback(arguments[2]); | ||
return historyState.apply(history, arguments); | ||
}; | ||
}); | ||
} | ||
function paramsClean(url, param) { | ||
@@ -782,3 +725,2 @@ var search = (url.split('?') || [,])[1]; | ||
exports.decodeUri = decode; | ||
exports.detectAdBlock = hasAdblock; | ||
exports.getBrowserLocale = getBrowserLocale; | ||
@@ -789,3 +731,2 @@ exports.getTimeZone = getTimeZone; | ||
exports.isScriptLoaded = isScriptLoaded; | ||
exports.onRouteChange = onRouteChange; | ||
exports.noOp = noOp; | ||
@@ -792,0 +733,0 @@ exports.paramsClean = paramsClean; |
@@ -1,1 +0,1 @@ | ||
var analyticsUtils=function(e){"use strict";var u="undefined"!=typeof window;var a=function(){try{if(!u)return!1;var e="cookietest=";document.cookie="".concat(e,"1");var t=-1!==document.cookie.indexOf(e);return document.cookie="".concat(e,"1; expires=Thu, 01-Jan-1970 00:00:01 GMT"),t}catch(e){return!1}}();function l(e,t,n){if(!a)return!1;var r="";if(n){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),r="; expires=".concat(o.toGMTString())}document.cookie="".concat(e,"=").concat(t).concat(r,"; path=/")}function f(e){if(!a)return!1;for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "===o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return null}function r(e){if(!a)return!1;l(e,"",-1)}var t={getCookie:f,setCookie:l,removeCookie:r};function s(e){return decodeURIComponent(e).replace(/\+/g," ")}function m(e){if(!u)return!1;var t=e||document.referrer;if(t){var n=window.document.location.port,r=t.split("/")[2];return n&&(r=r.replace(":".concat(n),"")),r!==window.location.hostname}return!1}function i(){}function c(e,t){var n=(e.split("?")||[,])[1];if(!n||-1===n.indexOf(t))return e;var r=new RegExp("(\\&|\\?)".concat(t,'([_A-Za-z0-9"+=.%]+)'),"g"),o="?".concat(n).replace(r,"").replace(/^&/,"?");return e.replace("?".concat(n),o)}function d(e){var t=function(e){if(e){var t=e.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return u&&window.location.search.substring(1)}(e);return t?function(e){var t,n=/([^&=]+)=?([^&]*)/g,r={};for(;t=n.exec(e);){var o=s(t[1]),a=s(t[2]);if("[]"===o.substring(o.length-2))o=o.substring(0,o.length-2),(r[o]||(r[o]=[])).push(a);else{var i=""===a||a;r[o]=i}}for(var c in r){var u=c.split("[");if(1<u.length){var l=[];u.forEach(function(e,t){var n=e.replace(/[?[\]\\ ]/g,"");l.push(n)}),p(r,l,r[c]),delete r[c]}}return r}(t):{}}function p(e,t,n){for(var r=t.length-1,o=0;o<r;++o){var a=t[o];a in e||(e[a]={}),e=e[a]}e[t[r]]=n}function n(e){if(!u)return null;var t=document.createElement("a");return t.setAttribute("href",e),t.hostname}function g(e){return(n(e)||"").split(".").slice(-2).join(".")}function v(e){var t=e.split(".");return 1<t.length?t.slice(0,-1).join("."):e}var o={trimTld:v,getDomainBase:g,getDomainHost:n},h="google";var y={"daum.net":"q","eniro.se":"search_word","naver.com":"query","yahoo.com":"p","msn.com":"q","aol.com":"q","lycos.com":"q","ask.com":"q","cnn.com":"query","about.com":"terms","baidu.com":"wd","yandex.com":"text","seznam.cz":"q","search.com":"q","yam.com":"k","kvasir.no":"q","terra.com":"query","mynet.com":"q","rambler.ru":"words",google:"q","bing.com":{p:"q",n:"live"}};function b(e){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(t){var n;try{void 0===(n=JSON.parse(t))&&(n=t),"true"===n&&(n=!0),"false"===n&&(n=!1),parseFloat(n)===n&&"object"!==b(n)&&(n=parseFloat(n))}catch(e){n=t}return n}var x="undefined"!=typeof self&&self?self:"undefined"!=typeof window&&window?window:"undefined"!=typeof global&&global?global:"undefined"!=typeof globalThis&&globalThis?globalThis:void 0;var S=function(){if(!u)return!1;try{if("undefined"==typeof localStorage||"undefined"==typeof JSON)return!1;localStorage.setItem("_test_","1"),localStorage.removeItem("_test_")}catch(e){return!1}return!0}();function k(e){return"string"==typeof e?e:e.storage}function O(e){return S&&(!e||"localStorage"===e)}function T(e){return a&&(!e||"cookie"===e)}var q={getItem:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return null;var n=k(t);if(O(n)){var r=localStorage.getItem(e);if(r||"localStorage"===n)return w(r)}if(T(n)){var o=f(e);if(o||"cookie"===n)return w(o)}return x[e]||null},setItem:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return!1;var r=k(n),o=JSON.stringify(t);if(O(r)){var a=w(localStorage.getItem(e));return localStorage.setItem(e,o),{value:t,oldValue:a,type:"localStorage"}}if(T(r)){var i=w(f(e));return l(e,o),{value:t,oldValue:i,type:"cookie"}}var c=x[e];return{value:x[e]=t,oldValue:c,type:"window"}},removeItem:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return!1;var n=k(t);return O(n)?(localStorage.removeItem(e),null):T(n)?(r(e),null):x[e]=null}};function I(){return 4294967295*Math.random()|0}return e.cookie=t,e.decodeUri=s,e.detectAdBlock=function(){if(!u)return!1;var e=document.createElement("div");e.innerHTML=" ",e.className="pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links",e.style="width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;";try{if(document.body.appendChild(e),null!==document.body.getAttribute("abp")||0===e.offsetHeight||0===e.clientHeight)return!0;if("undefined"!=typeof getComputedStyle){var t=window.getComputedStyle(e,null);if(t&&("none"===t.getPropertyValue("display")||"hidden"===t.getPropertyValue("visibility")))return!0}document.body.removeChild(e)}catch(e){}return!1},e.getBrowserLocale=function(){if(!u)return null;var e=navigator,t=e.language,n=e.languages,r=e.userLanguage;return n&&n.length?n[0]:r||t},e.getTimeZone=function(){return"undefined"==typeof Intl||"function"!=typeof Intl.DateTimeFormat||"function"!=typeof Intl.DateTimeFormat().resolvedOptions?null:Intl.DateTimeFormat().resolvedOptions().timeZone},e.inBrowser=u,e.isExternalReferrer=m,e.isScriptLoaded=function(n){if(!u)return!0;var r=document.getElementsByTagName("script");return!!Object.keys(r).filter(function(e){var t=r[e].src;return"string"==typeof n?-1!==t.indexOf(n):n instanceof RegExp&&t.match(n)}).length},e.onRouteChange=function(){var r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:i;if(u){var e=window,t=e.addEventListener,o=e.history,n=e.location;t("popstate",function(){r(n.pathname)}),["push","replace"].map(function(e){var t="".concat(e,"State"),n=o[t];o[t]=function(){return r(arguments[2]),n.apply(o,arguments)}})}},e.noOp=i,e.paramsClean=c,e.paramsGet=function(e,t){return s((RegExp("".concat(e,"=(.+?)(&|$)")).exec(t)||[,""])[1])},e.paramsParse=d,e.paramsRemove=function(o,a){return u?new Promise(function(e,t){if(window.history&&window.history.replaceState){var n=window.location.href,r=c(n,o);n!==r&&history.replaceState({},"",r)}return a&&a(),e()}):Promise.resolve()},e.parseReferrer=function(e,t){if(!u)return!1;var n={source:"(direct)",medium:"(none)",campaign:"(not set)"};e&&m(e)&&(n.referrer=e);var r=function(e){if(!e||!u)return!1;var t=g(e),n=document.createElement("a");if(n.href=e,-1<n.hostname.indexOf(h)&&(t=h),y[t]){var r=y[t],o="string"==typeof r?r:r.p,a=new RegExp(o+"=.*?([^&#]*|$)","gi"),i=n.search.match(a);return{source:r.n||v(t),medium:"organic",term:(i?i[0].split("=")[1]:"")||"(not provided)"}}var c=m(e)?"referral":"internal";return{source:n.hostname,medium:c}}(e);r&&Object.keys(r).length&&(n=Object.assign({},n,r));var o=d(t),a=Object.keys(o);if(a.length){var i=a.reduce(function(e,t){return t.match(/^utm_/)&&(e["".concat(t.replace(/^utm_/,""))]=o[t]),t.match(/^(d|g)clid/)&&(e.source=h,e.medium=o.gclid?"cpc":"cpm",e[t]=o[t]),e},{});n=Object.assign({},n,i),(o.dclid||o.gclid)&&(n.source=h,n.medium=o.gclid?"cpc":"cpm")}return n},e.storage=q,e.url=o,e.uuid=function(){for(var e,t,n,r,o=[],a=0;a<256;a++)o[a]=(a<16?"0":"")+a.toString(16);return e=I(),t=I(),n=I(),r=I(),"".concat(o[255&e]+o[e>>8&255]+o[e>>16&255]+o[e>>24&255],"-").concat(o[255&t]).concat(o[t>>8&255],"-").concat(o[t>>16&15|64]).concat(o[t>>24&255],"-").concat(o[63&n|128]).concat(o[n>>8&255],"-").concat(o[n>>16&255]).concat(o[n>>24&255]).concat(o[255&r]).concat(o[r>>8&255]).concat(o[r>>16&255]).concat(o[r>>24&255])},e.globalContext=x,e}({}); | ||
var analyticsUtils=function(e){"use strict";var u="undefined"!=typeof window;var a=function(){try{if(!u)return!1;var e="cookietest=";document.cookie="".concat(e,"1");var t=-1!==document.cookie.indexOf(e);return document.cookie="".concat(e,"1; expires=Thu, 01-Jan-1970 00:00:01 GMT"),t}catch(e){return!1}}();function l(e,t,n){if(!a)return!1;var r="";if(n){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),r="; expires=".concat(o.toGMTString())}document.cookie="".concat(e,"=").concat(t).concat(r,"; path=/")}function f(e){if(!a)return!1;for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r<n.length;r++){for(var o=n[r];" "===o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return null}function r(e){if(!a)return!1;l(e,"",-1)}var t={getCookie:f,setCookie:l,removeCookie:r};function s(e){return decodeURIComponent(e).replace(/\+/g," ")}function m(e){if(!u)return!1;var t=e||document.referrer;if(t){var n=window.document.location.port,r=t.split("/")[2];return n&&(r=r.replace(":".concat(n),"")),r!==window.location.hostname}return!1}function c(e,t){var n=(e.split("?")||[,])[1];if(!n||-1===n.indexOf(t))return e;var r=new RegExp("(\\&|\\?)".concat(t,'([_A-Za-z0-9"+=.%]+)'),"g"),o="?".concat(n).replace(r,"").replace(/^&/,"?");return e.replace("?".concat(n),o)}function i(e){var t=function(e){if(e){var t=e.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return u&&window.location.search.substring(1)}(e);return t?function(e){var t,n=/([^&=]+)=?([^&]*)/g,r={};for(;t=n.exec(e);){var o=s(t[1]),a=s(t[2]);if("[]"===o.substring(o.length-2))o=o.substring(0,o.length-2),(r[o]||(r[o]=[])).push(a);else{var c=""===a||a;r[o]=c}}for(var i in r){var u=i.split("[");if(1<u.length){var l=[];u.forEach(function(e,t){var n=e.replace(/[?[\]\\ ]/g,"");l.push(n)}),g(r,l,r[i]),delete r[i]}}return r}(t):{}}function g(e,t,n){for(var r=t.length-1,o=0;o<r;++o){var a=t[o];a in e||(e[a]={}),e=e[a]}e[t[r]]=n}function n(e){if(!u)return null;var t=document.createElement("a");return t.setAttribute("href",e),t.hostname}function d(e){return(n(e)||"").split(".").slice(-2).join(".")}function v(e){var t=e.split(".");return 1<t.length?t.slice(0,-1).join("."):e}var o={trimTld:v,getDomainBase:d,getDomainHost:n},p="google";var h={"daum.net":"q","eniro.se":"search_word","naver.com":"query","yahoo.com":"p","msn.com":"q","aol.com":"q","lycos.com":"q","ask.com":"q","cnn.com":"query","about.com":"terms","baidu.com":"wd","yandex.com":"text","seznam.cz":"q","search.com":"q","yam.com":"k","kvasir.no":"q","terra.com":"query","mynet.com":"q","rambler.ru":"words",google:"q","bing.com":{p:"q",n:"live"}};function y(e){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(t){var n;try{void 0===(n=JSON.parse(t))&&(n=t),"true"===n&&(n=!0),"false"===n&&(n=!1),parseFloat(n)===n&&"object"!==y(n)&&(n=parseFloat(n))}catch(e){n=t}return n}var b="undefined"!=typeof self&&self?self:"undefined"!=typeof window&&window?window:"undefined"!=typeof global&&global?global:"undefined"!=typeof globalThis&&globalThis?globalThis:void 0;var S=function(){if(!u)return!1;try{if("undefined"==typeof localStorage||"undefined"==typeof JSON)return!1;localStorage.setItem("_test_","1"),localStorage.removeItem("_test_")}catch(e){return!1}return!0}();function k(e){return"string"==typeof e?e:e.storage}function x(e){return S&&(!e||"localStorage"===e)}function O(e){return a&&(!e||"cookie"===e)}var q={getItem:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return null;var n=k(t);if(x(n)){var r=localStorage.getItem(e);if(r||"localStorage"===n)return w(r)}if(O(n)){var o=f(e);if(o||"cookie"===n)return w(o)}return b[e]||null},setItem:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!e||!t)return!1;var r=k(n),o=JSON.stringify(t);if(x(r)){var a=w(localStorage.getItem(e));return localStorage.setItem(e,o),{value:t,oldValue:a,type:"localStorage"}}if(O(r)){var c=w(f(e));return l(e,o),{value:t,oldValue:c,type:"cookie"}}var i=b[e];return{value:b[e]=t,oldValue:i,type:"window"}},removeItem:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(!e)return!1;var n=k(t);return x(n)?(localStorage.removeItem(e),null):O(n)?(r(e),null):b[e]=null}};function I(){return 4294967295*Math.random()|0}return e.cookie=t,e.decodeUri=s,e.getBrowserLocale=function(){if(!u)return null;var e=navigator,t=e.language,n=e.languages,r=e.userLanguage;return n&&n.length?n[0]:r||t},e.getTimeZone=function(){return"undefined"==typeof Intl||"function"!=typeof Intl.DateTimeFormat||"function"!=typeof Intl.DateTimeFormat().resolvedOptions?null:Intl.DateTimeFormat().resolvedOptions().timeZone},e.inBrowser=u,e.isExternalReferrer=m,e.isScriptLoaded=function(n){if(!u)return!0;var r=document.getElementsByTagName("script");return!!Object.keys(r).filter(function(e){var t=r[e].src;return"string"==typeof n?-1!==t.indexOf(n):n instanceof RegExp&&t.match(n)}).length},e.noOp=function(){},e.paramsClean=c,e.paramsGet=function(e,t){return s((RegExp("".concat(e,"=(.+?)(&|$)")).exec(t)||[,""])[1])},e.paramsParse=i,e.paramsRemove=function(o,a){return u?new Promise(function(e,t){if(window.history&&window.history.replaceState){var n=window.location.href,r=c(n,o);n!==r&&history.replaceState({},"",r)}return a&&a(),e()}):Promise.resolve()},e.parseReferrer=function(e,t){if(!u)return!1;var n={source:"(direct)",medium:"(none)",campaign:"(not set)"};e&&m(e)&&(n.referrer=e);var r=function(e){if(!e||!u)return!1;var t=d(e),n=document.createElement("a");if(n.href=e,-1<n.hostname.indexOf(p)&&(t=p),h[t]){var r=h[t],o="string"==typeof r?r:r.p,a=new RegExp(o+"=.*?([^&#]*|$)","gi"),c=n.search.match(a);return{source:r.n||v(t),medium:"organic",term:(c?c[0].split("=")[1]:"")||"(not provided)"}}var i=m(e)?"referral":"internal";return{source:n.hostname,medium:i}}(e);r&&Object.keys(r).length&&(n=Object.assign({},n,r));var o=i(t),a=Object.keys(o);if(a.length){var c=a.reduce(function(e,t){return t.match(/^utm_/)&&(e["".concat(t.replace(/^utm_/,""))]=o[t]),t.match(/^(d|g)clid/)&&(e.source=p,e.medium=o.gclid?"cpc":"cpm",e[t]=o[t]),e},{});n=Object.assign({},n,c),(o.dclid||o.gclid)&&(n.source=p,n.medium=o.gclid?"cpc":"cpm")}return n},e.storage=q,e.url=o,e.uuid=function(){for(var e,t,n,r,o=[],a=0;a<256;a++)o[a]=(a<16?"0":"")+a.toString(16);return e=I(),t=I(),n=I(),r=I(),"".concat(o[255&e]+o[e>>8&255]+o[e>>16&255]+o[e>>24&255],"-").concat(o[255&t]).concat(o[t>>8&255],"-").concat(o[t>>16&15|64]).concat(o[t>>24&255],"-").concat(o[63&n|128]).concat(o[n>>8&255],"-").concat(o[n>>16&255]).concat(o[n>>24&255]).concat(o[255&r]).concat(o[r>>8&255]).concat(o[r>>16&255]).concat(o[r>>24&255])},e.globalContext=b,e}({}); |
@@ -74,34 +74,2 @@ 'use strict'; | ||
function hasAdblock() { | ||
if (!inBrowser) return false; // Create fake ad | ||
var fakeAd = document.createElement('div'); | ||
fakeAd.innerHTML = ' '; | ||
fakeAd.className = 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'; | ||
fakeAd.style = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'; | ||
try { | ||
// insert into page | ||
document.body.appendChild(fakeAd); | ||
if (document.body.getAttribute('abp') !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) { | ||
return true; | ||
} | ||
if (typeof getComputedStyle !== 'undefined') { | ||
var css = window.getComputedStyle(fakeAd, null); | ||
if (css && (css.getPropertyValue('display') === 'none' || css.getPropertyValue('visibility') === 'hidden')) { | ||
return true; | ||
} | ||
} // remove from page | ||
document.body.removeChild(fakeAd); | ||
} catch (e) {// swallow errors | ||
} | ||
return false; | ||
} | ||
function getBrowserLocale() { | ||
@@ -185,27 +153,2 @@ if (!inBrowser) return null; | ||
function onRouteChange() { | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noOp; | ||
if (!inBrowser) return; | ||
var _window = window, | ||
addEventListener = _window.addEventListener, | ||
history = _window.history, | ||
location = _window.location; // Observe native navigation | ||
addEventListener('popstate', function () { | ||
callback(location.pathname); | ||
}); // Observe manual navigation | ||
var methods = ['push', 'replace']; | ||
methods.map(function (type) { | ||
// eslint-disable-line | ||
var state = "".concat(type, "State"); | ||
var historyState = history[state]; | ||
history[state] = function () { | ||
callback(arguments[2]); | ||
return historyState.apply(history, arguments); | ||
}; | ||
}); | ||
} | ||
function paramsClean(url, param) { | ||
@@ -783,3 +726,2 @@ var search = (url.split('?') || [,])[1]; | ||
exports.decodeUri = decode; | ||
exports.detectAdBlock = hasAdblock; | ||
exports.getBrowserLocale = getBrowserLocale; | ||
@@ -790,3 +732,2 @@ exports.getTimeZone = getTimeZone; | ||
exports.isScriptLoaded = isScriptLoaded; | ||
exports.onRouteChange = onRouteChange; | ||
exports.noOp = noOp; | ||
@@ -793,0 +734,0 @@ exports.paramsClean = paramsClean; |
@@ -70,34 +70,2 @@ var inBrowser = typeof window !== 'undefined'; | ||
function hasAdblock() { | ||
if (!inBrowser) return false; // Create fake ad | ||
var fakeAd = document.createElement('div'); | ||
fakeAd.innerHTML = ' '; | ||
fakeAd.className = 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'; | ||
fakeAd.style = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'; | ||
try { | ||
// insert into page | ||
document.body.appendChild(fakeAd); | ||
if (document.body.getAttribute('abp') !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) { | ||
return true; | ||
} | ||
if (typeof getComputedStyle !== 'undefined') { | ||
var css = window.getComputedStyle(fakeAd, null); | ||
if (css && (css.getPropertyValue('display') === 'none' || css.getPropertyValue('visibility') === 'hidden')) { | ||
return true; | ||
} | ||
} // remove from page | ||
document.body.removeChild(fakeAd); | ||
} catch (e) {// swallow errors | ||
} | ||
return false; | ||
} | ||
function getBrowserLocale() { | ||
@@ -181,27 +149,2 @@ if (!inBrowser) return null; | ||
function onRouteChange() { | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noOp; | ||
if (!inBrowser) return; | ||
var _window = window, | ||
addEventListener = _window.addEventListener, | ||
history = _window.history, | ||
location = _window.location; // Observe native navigation | ||
addEventListener('popstate', function () { | ||
callback(location.pathname); | ||
}); // Observe manual navigation | ||
var methods = ['push', 'replace']; | ||
methods.map(function (type) { | ||
// eslint-disable-line | ||
var state = "".concat(type, "State"); | ||
var historyState = history[state]; | ||
history[state] = function () { | ||
callback(arguments[2]); | ||
return historyState.apply(history, arguments); | ||
}; | ||
}); | ||
} | ||
function paramsClean(url, param) { | ||
@@ -777,2 +720,2 @@ var search = (url.split('?') || [,])[1]; | ||
export { cookie, decode as decodeUri, hasAdblock as detectAdBlock, getBrowserLocale, getTimeZone, inBrowser, isExternalReferrer, isScriptLoaded, onRouteChange, noOp, paramsClean, getValueParamValue as paramsGet, paramsParse, paramsRemove, parseReferrer, index as storage, url, uuid, globalContext }; | ||
export { cookie, decode as decodeUri, getBrowserLocale, getTimeZone, inBrowser, isExternalReferrer, isScriptLoaded, noOp, paramsClean, getValueParamValue as paramsGet, paramsParse, paramsRemove, parseReferrer, index as storage, url, uuid, globalContext }; |
@@ -74,34 +74,2 @@ 'use strict'; | ||
function hasAdblock() { | ||
if (!inBrowser) return false; // Create fake ad | ||
var fakeAd = document.createElement('div'); | ||
fakeAd.innerHTML = ' '; | ||
fakeAd.className = 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'; | ||
fakeAd.style = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'; | ||
try { | ||
// insert into page | ||
document.body.appendChild(fakeAd); | ||
if (document.body.getAttribute('abp') !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) { | ||
return true; | ||
} | ||
if (typeof getComputedStyle !== 'undefined') { | ||
var css = window.getComputedStyle(fakeAd, null); | ||
if (css && (css.getPropertyValue('display') === 'none' || css.getPropertyValue('visibility') === 'hidden')) { | ||
return true; | ||
} | ||
} // remove from page | ||
document.body.removeChild(fakeAd); | ||
} catch (e) {// swallow errors | ||
} | ||
return false; | ||
} | ||
function getBrowserLocale() { | ||
@@ -185,27 +153,2 @@ if (!inBrowser) return null; | ||
function onRouteChange() { | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noOp; | ||
if (!inBrowser) return; | ||
var _window = window, | ||
addEventListener = _window.addEventListener, | ||
history = _window.history, | ||
location = _window.location; // Observe native navigation | ||
addEventListener('popstate', function () { | ||
callback(location.pathname); | ||
}); // Observe manual navigation | ||
var methods = ['push', 'replace']; | ||
methods.map(function (type) { | ||
// eslint-disable-line | ||
var state = "".concat(type, "State"); | ||
var historyState = history[state]; | ||
history[state] = function () { | ||
callback(arguments[2]); | ||
return historyState.apply(history, arguments); | ||
}; | ||
}); | ||
} | ||
function paramsClean(url, param) { | ||
@@ -783,3 +726,2 @@ var search = (url.split('?') || [,])[1]; | ||
exports.decodeUri = decode; | ||
exports.detectAdBlock = hasAdblock; | ||
exports.getBrowserLocale = getBrowserLocale; | ||
@@ -790,3 +732,2 @@ exports.getTimeZone = getTimeZone; | ||
exports.isScriptLoaded = isScriptLoaded; | ||
exports.onRouteChange = onRouteChange; | ||
exports.noOp = noOp; | ||
@@ -793,0 +734,0 @@ exports.paramsClean = paramsClean; |
@@ -70,34 +70,2 @@ var inBrowser = typeof window !== 'undefined'; | ||
function hasAdblock() { | ||
if (!inBrowser) return false; // Create fake ad | ||
var fakeAd = document.createElement('div'); | ||
fakeAd.innerHTML = ' '; | ||
fakeAd.className = 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'; | ||
fakeAd.style = 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'; | ||
try { | ||
// insert into page | ||
document.body.appendChild(fakeAd); | ||
if (document.body.getAttribute('abp') !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) { | ||
return true; | ||
} | ||
if (typeof getComputedStyle !== 'undefined') { | ||
var css = window.getComputedStyle(fakeAd, null); | ||
if (css && (css.getPropertyValue('display') === 'none' || css.getPropertyValue('visibility') === 'hidden')) { | ||
return true; | ||
} | ||
} // remove from page | ||
document.body.removeChild(fakeAd); | ||
} catch (e) {// swallow errors | ||
} | ||
return false; | ||
} | ||
function getBrowserLocale() { | ||
@@ -181,27 +149,2 @@ if (!inBrowser) return null; | ||
function onRouteChange() { | ||
var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : noOp; | ||
if (!inBrowser) return; | ||
var _window = window, | ||
addEventListener = _window.addEventListener, | ||
history = _window.history, | ||
location = _window.location; // Observe native navigation | ||
addEventListener('popstate', function () { | ||
callback(location.pathname); | ||
}); // Observe manual navigation | ||
var methods = ['push', 'replace']; | ||
methods.map(function (type) { | ||
// eslint-disable-line | ||
var state = "".concat(type, "State"); | ||
var historyState = history[state]; | ||
history[state] = function () { | ||
callback(arguments[2]); | ||
return historyState.apply(history, arguments); | ||
}; | ||
}); | ||
} | ||
function paramsClean(url, param) { | ||
@@ -777,2 +720,2 @@ var search = (url.split('?') || [,])[1]; | ||
export { cookie, decode as decodeUri, hasAdblock as detectAdBlock, getBrowserLocale, getTimeZone, inBrowser, isExternalReferrer, isScriptLoaded, onRouteChange, noOp, paramsClean, getValueParamValue as paramsGet, paramsParse, paramsRemove, parseReferrer, index as storage, url, uuid, globalContext }; | ||
export { cookie, decode as decodeUri, getBrowserLocale, getTimeZone, inBrowser, isExternalReferrer, isScriptLoaded, noOp, paramsClean, getValueParamValue as paramsGet, paramsParse, paramsRemove, parseReferrer, index as storage, url, uuid, globalContext }; |
{ | ||
"name": "analytics-utils", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Analytics utility functions used by 'analytics' module", | ||
@@ -59,3 +59,3 @@ "author": "David Wells <hello@davidwells.io>", | ||
}, | ||
"gitHead": "0104ab8c1ba4b05bbfb8e41abda9e60b901d2664" | ||
"gitHead": "0608c76283e53842be0ca5a54533e5c011c53734" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108307
2978