diff --git a/lib/countly.js b/lib/countly.js index 3390f52a..b8522986 100644 --- a/lib/countly.js +++ b/lib/countly.js @@ -1624,17 +1624,48 @@ * @param {function=} callback - Callback to notify with first param error and second param remote config object * */ this.fetch_remote_config = function(keys, omit_keys, callback) { + var keysFiltered = null; + var omitKeysFiltered = null; + var callbackFiltered = null; + + // check first param is truthy + if (keys) { + // if third parameter is falsy and first param is a function assign it as the callback function + if (!callback && typeof keys === "function") { + callbackFiltered = keys; + } + // else if first param is an array assign it as 'keys' + else if (Array.isArray(keys)) { + keysFiltered = keys; + } + } + // check second param is truthy + if (omit_keys) { + // if third parameter is falsy and second param is a function assign it as the callback function + if (!callback && typeof omit_keys === "function") { + callbackFiltered = omit_keys; + } + // else if second param is an array assign it as 'omit_keys' + else if (Array.isArray(omit_keys)) { + omitKeysFiltered = omit_keys; + } + } + // assign third param as a callback function if it was not assigned yet in first two params + if (!callbackFiltered && typeof callback === "function") { + callbackFiltered = callback; + } + // use new RC API if (this.useExplicitRcApi) { log(logLevelEnums.INFO, "fetch_remote_config, Fetching remote config"); // opt in is true(1) or false(0) var opt = this.rcAutoOptinAb ? 1 : 0; - fetch_remote_config_explicit(keys, omit_keys, opt, callback); + fetch_remote_config_explicit(keysFiltered, omitKeysFiltered, opt, null, callbackFiltered); return; } log(logLevelEnums.WARNING, "fetch_remote_config, Fetching remote config, with legacy API"); - fetch_remote_config_explicit(keys, omit_keys, "legacy", callback); + fetch_remote_config_explicit(keysFiltered, omitKeysFiltered, null, "legacy", callbackFiltered); }; /** @@ -1651,31 +1682,28 @@ method: "rc" }; // check if keys were provided - if (Array.isArray(arguments[0]) && arguments[0].length > 0) { - request.keys = JSON.stringify(arguments[0]); + if (keys.length > 0) { + request.keys = JSON.stringify(keys); } // check if omit_keys were provided - if (Array.isArray(arguments[1]) && arguments[1].length > 0) { - request.omit_keys = JSON.stringify(arguments[1]); + if (omit_keys.length > 0) { + request.omit_keys = JSON.stringify(omit_keys); } - var j = arguments.length - 1; - var provivedCall; - while (j--) { - // legacy api prompt check - if (arguments[j] === "legacy") { - request.method = "fetch_remote_config"; - } - // opted out/in check - if (arguments[j] === 0) { - request.oi = 0; - } - if (arguments[j] === 1) { - request.oi = 1; - } - // callback check - if (typeof arguments[j] === "function") { - provivedCall = arguments[j]; - } + var providedCall; + // legacy api prompt check + if (api === "legacy") { + request.method = "fetch_remote_config"; + } + // opted out/in check + if (optIn === 0) { + request.oi = 0; + } + if (optIn === 1) { + request.oi = 1; + } + // callback check + if (typeof callback === "function") { + providedCall = callback; } if (self.check_consent(featureEnums.SESSIONS)) { request.metrics = JSON.stringify(getMetrics()); @@ -1704,17 +1732,17 @@ catch (ex) { log(logLevelEnums.ERROR, "fetch_remote_config_explicit, Had an issue while parsing the response: " + ex); } - if (provivedCall) { + if (providedCall) { log(logLevelEnums.INFO, "fetch_remote_config_explicit, Callback function is provided"); - provivedCall(err, remoteConfigs); + providedCall(err, remoteConfigs); } // JSON array can pass }, true); } else { log(logLevelEnums.ERROR, "fetch_remote_config_explicit, Remote config requires explicit consent"); - if (provivedCall) { - provivedCall(new Error("Remote config requires explicit consent"), remoteConfigs); + if (providedCall) { + providedCall(new Error("Remote config requires explicit consent"), remoteConfigs); } } } diff --git a/lib/countly.min.js b/lib/countly.min.js index 297b014c..070f5a1f 100644 --- a/lib/countly.min.js +++ b/lib/countly.min.js @@ -1,137 +1,136 @@ -(function(n,ka){"function"===typeof define&&define.amd?define([],function(){return ka(n.Countly)}):"object"===typeof module&&module.exports?module.exports=ka(n.Countly):n.Countly=ka(n.Countly)})("undefined"!==typeof window?window:this,function(n){function ka(h){var p=[];if("undefined"!==typeof h.options)for(var u=0;u=h?Ba++:Ba=h;return Ba}function r(h,p,u){if(p&&Object.keys(p).length){if("undefined"!==typeof p[h])return p[h]}else if("undefined"!==typeof n[h])return n[h];return u}function Sa(h,p,u){for(var C in n.i)n.i[C].tracking_crashes&&n.i[C].recordError(h,p,u)}function bb(h){var p=[],u;for(u in h)p.push(u+ -"="+encodeURIComponent(h[u]));return p.join("&")}function la(h){return"string"===typeof h&&"/"===h.substring(h.length-1)?h.substring(0,h.length-1):h}function oa(h,p){for(var u={},C,K=0,O=p.length;KC){var Z={},pa=0,ba;for(ba in h)pap&&(K=h.substring(0,p),C(d.DEBUG,u+", Key: [ "+h+" ] is longer than accepted length. It will be truncated."));return K}function qa(h){if(h)return h;h=navigator.userAgent;!h&&navigator.userAgentData&&(h=navigator.userAgentData.brands.map(function(p){return p.brand+":"+p.version}).join(),h+=navigator.userAgentData.mobile?" mobi ":" ",h+=navigator.userAgentData.platform);return h}function cb(h){if(!h){if(navigator.userAgentData.mobile)return"phone";h=qa()}h=h.toLowerCase(); +(function(n,ja){"function"===typeof define&&define.amd?define([],function(){return ja(n.Countly)}):"object"===typeof module&&module.exports?module.exports=ja(n.Countly):n.Countly=ja(n.Countly)})("undefined"!==typeof window?window:this,function(n){function ja(h){var p=[];if("undefined"!==typeof h.options)for(var u=0;u=h?Aa++:Aa=h;return Aa}function r(h,p,u){if(p&&Object.keys(p).length){if("undefined"!==typeof p[h])return p[h]}else if("undefined"!==typeof n[h])return n[h];return u}function Ra(h,p,u){for(var C in n.i)n.i[C].tracking_crashes&&n.i[C].recordError(h,p,u)}function bb(h){var p=[],u;for(u in h)p.push(u+ +"="+encodeURIComponent(h[u]));return p.join("&")}function ka(h){return"string"===typeof h&&"/"===h.substring(h.length-1)?h.substring(0,h.length-1):h}function oa(h,p){for(var u={},C,J=0,O=p.length;JC){var Z={},pa=0,ba;for(ba in h)pap&&(J=h.substring(0,p),C(d.DEBUG,u+", Key: [ "+h+" ] is longer than accepted length. It will be truncated."));return J}function qa(h){if(h)return h;h=navigator.userAgent;!h&&navigator.userAgentData&&(h=navigator.userAgentData.brands.map(function(p){return p.brand+":"+p.version}).join(),h+=navigator.userAgentData.mobile?" mobi ":" ",h+=navigator.userAgentData.platform);return h}function cb(h){if(!h){if(navigator.userAgentData.mobile)return"phone";h=qa()}h=h.toLowerCase(); var p="desktop",u=/(mobi|ipod|phone|blackberry|opera mini|fennec|minimo|symbian|psp|nintendo ds|archos|skyfire|puffin|blazer|bolt|gobrowser|iris|maemo|semc|teashark|uzard)/;/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(h)?p="tablet":u.test(h)&&(p="phone");return p}function db(h){return/(CountlySiteBot|nuhk|Googlebot|GoogleSecurityScanner|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver|bingbot|Google Web Preview|Mediapartners-Google|AdsBot-Google|Baiduspider|Ezooms|YahooSeeker|AltaVista|AVSearch|Mercator|Scooter|InfoSeek|Ultraseek|Lycos|Wget|YandexBot|Yandex|YaDirectFetcher|SiteBot|Exabot|AhrefsBot|MJ12bot|TurnitinBot|magpie-crawler|Nutch Crawler|CMS Crawler|rogerbot|Domnutch|ssearch_bot|XoviBot|netseer|digincore|fr-crawler|wesee|AliasIO|contxbot|PingdomBot|BingPreview|HeadlessChrome)/.test(h|| -qa())}function Ta(h){"undefined"===typeof h.pageY&&"number"===typeof h.clientX&&document.documentElement&&(h.pageX=h.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.pageY=h.clientY+document.body.scrollTop+document.documentElement.scrollTop);return h}function Ca(){var h=document;return Math.max(Math.max(h.body.scrollHeight,h.documentElement.scrollHeight),Math.max(h.body.offsetHeight,h.documentElement.offsetHeight),Math.max(h.body.clientHeight,h.documentElement.clientHeight))} -function Ua(){var h=document;return Math.max(Math.max(h.body.scrollWidth,h.documentElement.scrollWidth),Math.max(h.body.offsetWidth,h.documentElement.offsetWidth),Math.max(h.body.clientWidth,h.documentElement.clientWidth))}function eb(){var h=document;return Math.min(Math.min(h.body.clientHeight,h.documentElement.clientHeight),Math.min(h.body.offsetHeight,h.documentElement.offsetHeight),window.innerHeight)}function fb(h,p,u,C,K,O){h=document.createElement(h);var Y;h.setAttribute(p,u);h.setAttribute(C, -K);p=function(){Y||O();Y=!0};O&&(h.onreadystatechange=p,h.onload=p);document.getElementsByTagName("head")[0].appendChild(h)}function gb(h,p){fb("script","type","text/javascript","src",h,p)}function Da(h,p){fb("link","rel","stylesheet","href",h,p)}function hb(){var h=document.getElementById("cly-loader");if(!h){var p=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.type="text/css";u.styleSheet?u.styleSheet.cssText="#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}": +qa())}function Sa(h){"undefined"===typeof h.pageY&&"number"===typeof h.clientX&&document.documentElement&&(h.pageX=h.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.pageY=h.clientY+document.body.scrollTop+document.documentElement.scrollTop);return h}function Ba(){var h=document;return Math.max(Math.max(h.body.scrollHeight,h.documentElement.scrollHeight),Math.max(h.body.offsetHeight,h.documentElement.offsetHeight),Math.max(h.body.clientHeight,h.documentElement.clientHeight))} +function Ta(){var h=document;return Math.max(Math.max(h.body.scrollWidth,h.documentElement.scrollWidth),Math.max(h.body.offsetWidth,h.documentElement.offsetWidth),Math.max(h.body.clientWidth,h.documentElement.clientWidth))}function eb(){var h=document;return Math.min(Math.min(h.body.clientHeight,h.documentElement.clientHeight),Math.min(h.body.offsetHeight,h.documentElement.offsetHeight),window.innerHeight)}function fb(h,p,u,C,J,O){h=document.createElement(h);var Y;h.setAttribute(p,u);h.setAttribute(C, +J);p=function(){Y||O();Y=!0};O&&(h.onreadystatechange=p,h.onload=p);document.getElementsByTagName("head")[0].appendChild(h)}function gb(h,p){fb("script","type","text/javascript","src",h,p)}function Ca(h,p){fb("link","rel","stylesheet","href",h,p)}function hb(){var h=document.getElementById("cly-loader");if(!h){var p=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.type="text/css";u.styleSheet?u.styleSheet.cssText="#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}": u.appendChild(document.createTextNode("#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}")); p.appendChild(u);h=document.createElement("div");h.setAttribute("id","cly-loader");document.body.onload=function(){if(!n.showLoaderProtection)try{document.body.appendChild(h)}catch(C){}}}h.style.display="block"}function ib(){n.showLoaderProtection=!0;var h=document.getElementById("cly-loader");h&&(h.style.display="none")}if("undefined"!==typeof window){n=n||{};n.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" "); var d={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "};n.q=n.q||[];n.onload=n.onload||[];var jb=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;n.CountlyClass=function(h){function p(a){if(g.ignore_visitor)c(d.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);a.key=w(a.key,g.maxKeyLength, -"add_cly_event",c);a.segmentation=T(a.segmentation,g.maxKeyLength,g.maxValueSize,g.maxSegmentationValues,"add_cly_event",c);var b=oa(a,["key","count","sum","dur","segmentation"]);b.timestamp=Ra();var e=new Date;b.hour=e.getHours();b.dow=e.getDay();G.push(b);v("cly_event",G);c(d.INFO,"Successfully adding event: ",a)}else c(d.ERROR,"Adding event failed. Event must have a key property")}function u(a,b,e,k,l){c(d.INFO,"fetch_remote_config_explicit, Fetching sequence initiated");var f={method:"rc"};Array.isArray(arguments[0])&& -0a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;t.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;t.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;t.id="countly-feedback-sticker-"+a._id;f.appendChild(m);t.appendChild(f);t.appendChild(q);document.body.appendChild(t);var I=document.getElementById("smileyPathInStickerSvg"); -I&&(I.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);x(document.getElementById("countly-feedback-sticker-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block";document.getElementById("cfbg").style.display="block"})}else document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block",document.getElementById("cfbg").style.display="block"}catch(U){c(d.ERROR,"Somethings went wrong while element injecting process: "+ -U)}}function Y(){var a;if("undefined"!==typeof g.onload&&0Ga&&E.shift(),E.push(a),v("cly_queue",E,!0)):c(d.ERROR,"app_key or device_id is missing ",g.app_key,g.device_id)} -function Ha(){Y();if(g.ignore_visitor)Ia=!1,c(d.WARNING,"User opt_out, no heartbeat");else{Ia=!0;var a=0;if(Ja&&"undefined"!==typeof n.q&&0Ka&&(g.session_duration(a-fa),fa=a));0Va&&(La=!1,a=E[0],c(d.DEBUG,"Processing request",a),v("cly_queue",E,!0),g.test_mode||aa("send_request_queue",g.url+kb,a,function(m,q){c(d.DEBUG,"Request Finished",q,m);m?(Va=B()+Ma,c(d.ERROR, -"Request error: ",m)):E.shift();v("cly_queue",E,!0);La=!0},!1));setTimeout(Ha,Na)}}function Wa(){var a=y("cly_id");return a?(D=y("cly_id_type"),a):ab()}function Ea(){var a=JSON.parse(JSON.stringify(g.metrics||{}));a._app_version=a._app_version||g.app_version;a._ua=a._ua||qa();if(screen.width){var b=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==b&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&window.devicePixelRatio)b=Math.round(b* +"add_cly_event",c);a.segmentation=U(a.segmentation,g.maxKeyLength,g.maxValueSize,g.maxSegmentationValues,"add_cly_event",c);var b=oa(a,["key","count","sum","dur","segmentation"]);b.timestamp=Qa();var e=new Date;b.hour=e.getHours();b.dow=e.getDay();G.push(b);v("cly_event",G);c(d.INFO,"Successfully adding event: ",a)}else c(d.ERROR,"Adding event failed. Event must have a key property")}function u(a,b,e,k,l){c(d.INFO,"fetch_remote_config_explicit, Fetching sequence initiated");var f={method:"rc"};0< +a.length&&(f.keys=JSON.stringify(a));0a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;t.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;t.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;t.id="countly-feedback-sticker-"+a._id;f.appendChild(m);t.appendChild(f);t.appendChild(q);document.body.appendChild(t);var H=document.getElementById("smileyPathInStickerSvg"); +H&&(H.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);x(document.getElementById("countly-feedback-sticker-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block";document.getElementById("cfbg").style.display="block"})}else document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block",document.getElementById("cfbg").style.display="block"}catch(P){c(d.ERROR,"Somethings went wrong while element injecting process: "+ +P)}}function Y(){var a;if("undefined"!==typeof g.onload&&0Fa&&E.shift(),E.push(a),v("cly_queue",E,!0)):c(d.ERROR,"app_key or device_id is missing ",g.app_key,g.device_id)} +function Ga(){Y();if(g.ignore_visitor)Ha=!1,c(d.WARNING,"User opt_out, no heartbeat");else{Ha=!0;var a=0;if(Ia&&"undefined"!==typeof n.q&&0Ja&&(g.session_duration(a-ea),ea=a));0Ua&&(Ka=!1,a=E[0],c(d.DEBUG,"Processing request",a),v("cly_queue",E,!0),g.test_mode||aa("send_request_queue",g.url+kb,a,function(m,q){c(d.DEBUG,"Request Finished",q,m);m?(Ua=B()+La,c(d.ERROR, +"Request error: ",m)):E.shift();v("cly_queue",E,!0);Ka=!0},!1));setTimeout(Ga,Ma)}}function Va(){var a=y("cly_id");return a?(D=y("cly_id_type"),a):ab()}function Da(){var a=JSON.parse(JSON.stringify(g.metrics||{}));a._app_version=a._app_version||g.app_version;a._ua=a._ua||qa();if(screen.width){var b=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==b&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&window.devicePixelRatio)b=Math.round(b* window.devicePixelRatio),e=Math.round(e*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var k=b;b=e;e=k}a._resolution=a._resolution||""+b+"x"+e}}window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);b=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof b&&(a._locale=a._locale||b);if("undefined"!==typeof document.referrer&&document.referrer.length&&(b=jb.exec(document.referrer))&&b[11]&&b[11]!== -window.location.hostname){b=!1;if(Q&&Q.length)for(e=0;ea))return c(d.ERROR,"Http response status code is not within the expected range:["+a+"]"),!1;try{var e=JSON.parse(b);return"[object Object]"!==Object.prototype.toString.call(e)?(c(d.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(k){return c(d.ERROR,"Http response is not JSON: "+k),!1}}function lb(a,b){if(!(200<=a&&300>a))return c(d.ERROR, -"Http response status code is not within the expected range: "+a),!1;try{var e=JSON.parse(b);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(c(d.ERROR,"Http response is not JSON Object nor JSON Array"),!1)}catch(k){return c(d.ERROR,"Http response is not JSON: "+k),!1}}function nb(){xa=Math.max(xa,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop)}function Xa(){if(ya){ya=!1;var a=Ca(),b=Ua(),e=eb();g.check_consent("scrolls")&&(a={type:"scroll", -y:xa+e,width:b,height:a,view:g.getViewUrl()},a=T(a,g.maxKeyLength,g.maxValueSize,g.maxSegmentationValues,"processScrollView",c),g.track_domains&&(a.domain=window.location.hostname),p({key:"[CLY]_action",segmentation:a}))}}function ob(a){v("cly_token",a)}function pb(a,b,e){var k=new Date;k.setTime(k.getTime()+864E5*e);e="; expires="+k.toGMTString();document.cookie=a+"="+b+e+"; path=/"}function y(a,b,e){if("none"===g.storage)c(d.WARNING,"Storage is disabled. Value with key: "+a+" won't be retrieved"); -else{e||(a=g.app_key+"/"+a,g.namespace&&(a=la(g.namespace)+"/"+a));void 0===b&&(b=ha);if(b)var k=localStorage.getItem(a);else if("localstorage"!==g.storage)a:{a+="=";b=document.cookie.split(";");e=0;for(k=b.length;ea))return c(d.ERROR,"Http response status code is not within the expected range:["+a+"]"),!1;try{var e=JSON.parse(b);return"[object Object]"!==Object.prototype.toString.call(e)?(c(d.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(k){return c(d.ERROR,"Http response is not JSON: "+k),!1}}function lb(a,b){if(!(200<=a&&300>a))return c(d.ERROR, +"Http response status code is not within the expected range: "+a),!1;try{var e=JSON.parse(b);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(c(d.ERROR,"Http response is not JSON Object nor JSON Array"),!1)}catch(k){return c(d.ERROR,"Http response is not JSON: "+k),!1}}function nb(){wa=Math.max(wa,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop)}function Wa(){if(xa){xa=!1;var a=Ba(),b=Ta(),e=eb();g.check_consent("scrolls")&&(a={type:"scroll", +y:wa+e,width:b,height:a,view:g.getViewUrl()},a=U(a,g.maxKeyLength,g.maxValueSize,g.maxSegmentationValues,"processScrollView",c),g.track_domains&&(a.domain=window.location.hostname),p({key:"[CLY]_action",segmentation:a}))}}function ob(a){v("cly_token",a)}function pb(a,b,e){var k=new Date;k.setTime(k.getTime()+864E5*e);e="; expires="+k.toGMTString();document.cookie=a+"="+b+e+"; path=/"}function y(a,b,e){if("none"===g.storage)c(d.WARNING,"Storage is disabled. Value with key: "+a+" won't be retrieved"); +else{e||(a=g.app_key+"/"+a,g.namespace&&(a=ka(g.namespace)+"/"+a));void 0===b&&(b=fa);if(b)var k=localStorage.getItem(a);else if("localstorage"!==g.storage)a:{a+="=";b=document.cookie.split(";");e=0;for(k=b.length;ewindow.innerHeight?"landscape":"portrait")}})};this.report_conversion=function(a,b){c(d.WARNING,"report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!");this.recordDirectAttribution(a,b)};this.recordDirectAttribution=function(a,b){c(d.INFO,"recordDirectAttribution, Recording the attribution for campaign ID: ["+a+"] and the user ID: ["+b+"]");this.check_consent("attribution")&& (a=a||y("cly_cmp_id")||"cly_organic",(b=b||y("cly_cmp_uid"))?F({campaign_id:a,campaign_user:b}):F({campaign_id:a}))};this.user_details=function(a){c(d.INFO,"user_details, Trying to add user details: ",a);this.check_consent("users")&&(a.name=w(a.name,g.maxValueSize,"user_details",c),a.username=w(a.username,g.maxValueSize,"user_details",c),a.email=w(a.email,g.maxValueSize,"user_details",c),a.organization=w(a.organization,g.maxValueSize,"user_details",c),a.phone=w(a.phone,g.maxValueSize,"user_details", -c),a.picture=w(a.picture,4096,"user_details",c),a.gender=w(a.gender,g.maxValueSize,"user_details",c),a.byear=w(a.byear,g.maxValueSize,"user_details",c),a.custom=T(a.custom,g.maxKeyLength,g.maxValueSize,g.maxSegmentationValues,"user_details",c),F({user_details:JSON.stringify(oa(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var S={},X=function(a,b,e){g.check_consent("users")&&(S[a]||(S[a]={}),"$push"===e||"$pull"===e||"$addToSet"===e?(S[a][e]||(S[a][e]=[]), -S[a][e].push(b)):S[a][e]=b)};this.userData={set:function(a,b){c(d.INFO,"set, Setting user's custom property value: ["+b+"] under the key: ["+a+"]");a=w(a,g.maxKeyLength,"userData set",c);b=w(b,g.maxValueSize,"userData set",c);S[a]=b},unset:function(a){c(d.INFO,"unset, Resetting user's custom property with key: ["+a+"] ");S[a]=""},set_once:function(a,b){c(d.INFO,"set_once, Setting user's unique custom property value: ["+b+"] under the key: ["+a+"] ");a=w(a,g.maxKeyLength,"userData set_once",c);b=w(b, +c),a.picture=w(a.picture,4096,"user_details",c),a.gender=w(a.gender,g.maxValueSize,"user_details",c),a.byear=w(a.byear,g.maxValueSize,"user_details",c),a.custom=U(a.custom,g.maxKeyLength,g.maxValueSize,g.maxSegmentationValues,"user_details",c),F({user_details:JSON.stringify(oa(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var T={},X=function(a,b,e){g.check_consent("users")&&(T[a]||(T[a]={}),"$push"===e||"$pull"===e||"$addToSet"===e?(T[a][e]||(T[a][e]=[]), +T[a][e].push(b)):T[a][e]=b)};this.userData={set:function(a,b){c(d.INFO,"set, Setting user's custom property value: ["+b+"] under the key: ["+a+"]");a=w(a,g.maxKeyLength,"userData set",c);b=w(b,g.maxValueSize,"userData set",c);T[a]=b},unset:function(a){c(d.INFO,"unset, Resetting user's custom property with key: ["+a+"] ");T[a]=""},set_once:function(a,b){c(d.INFO,"set_once, Setting user's unique custom property value: ["+b+"] under the key: ["+a+"] ");a=w(a,g.maxKeyLength,"userData set_once",c);b=w(b, g.maxValueSize,"userData set_once",c);X(a,b,"$setOnce")},increment:function(a){c(d.INFO,"increment, Increasing user's custom property value under the key: ["+a+"] by one");a=w(a,g.maxKeyLength,"userData increment",c);X(a,1,"$inc")},increment_by:function(a,b){c(d.INFO,"increment_by, Increasing user's custom property value under the key: ["+a+"] by: ["+b+"]");a=w(a,g.maxKeyLength,"userData increment_by",c);b=w(b,g.maxValueSize,"userData increment_by",c);X(a,b,"$inc")},multiply:function(a,b){c(d.INFO, "multiply, Multiplying user's custom property value under the key: ["+a+"] by: ["+b+"]");a=w(a,g.maxKeyLength,"userData multiply",c);b=w(b,g.maxValueSize,"userData multiply",c);X(a,b,"$mul")},max:function(a,b){c(d.INFO,"max, Saving user's maximum custom property value compared to the value: ["+b+"] under the key: ["+a+"]");a=w(a,g.maxKeyLength,"userData max",c);b=w(b,g.maxValueSize,"userData max",c);X(a,b,"$max")},min:function(a,b){c(d.INFO,"min, Saving user's minimum custom property value compared to the value: ["+ b+"] under the key: ["+a+"]");a=w(a,g.maxKeyLength,"userData min",c);b=w(b,g.maxValueSize,"userData min",c);X(a,b,"$min")},push:function(a,b){c(d.INFO,"push, Pushing a value: ["+b+"] under the key: ["+a+"] to user's custom property array");a=w(a,g.maxKeyLength,"userData push",c);b=w(b,g.maxValueSize,"userData push",c);X(a,b,"$push")},push_unique:function(a,b){c(d.INFO,"push_unique, Pushing a unique value: ["+b+"] under the key: ["+a+"] to user's custom property array");a=w(a,g.maxKeyLength,"userData push_unique", -c);b=w(b,g.maxValueSize,"userData push_unique",c);X(a,b,"$addToSet")},pull:function(a,b){c(d.INFO,"pull, Removing the value: ["+b+"] under the key: ["+a+"] from user's custom property array");X(a,b,"$pull")},save:function(){c(d.INFO,"save, Saving changes to user's custom property");g.check_consent("users")&&F({user_details:JSON.stringify({custom:S})});S={}}};this.report_trace=function(a){c(d.INFO,"report_trace, Reporting performance trace");if(this.check_consent("apm")){for(var b="type name stz etz apm_metrics apm_attr".split(" "), -e=0;e=g.maxBreadcrumbCount;)ia.shift(),c(d.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one."); -ia.push(a)}};this.fetch_remote_config=function(a,b,e){this.useExplicitRcApi?(c(d.INFO,"fetch_remote_config, Fetching remote config"),u(a,b,this.rcAutoOptinAb?1:0,e)):(c(d.WARNING,"fetch_remote_config, Fetching remote config, with legacy API"),u(a,b,"legacy",e))};this.enrollUserToAb=function(a){c(d.INFO,"enrollUserToAb, Providing AB test keys to opt in for");a&&Array.isArray(a)&&0!==a.length?(a={method:"ab",keys:JSON.stringify(a)},ba(a),aa("enrollUserToAb",this.url+Fa,a,function(b,e,k){if(b)c(d.ERROR, -"enrollUserToAb, An error occurred: "+b);else try{var l=JSON.parse(k);c(d.DEBUG,"enrollUserToAb, Parsed the response's result: ["+l.result+"]")}catch(f){c(d.ERROR,"enrollUserToAb, Had an issue while parsing the response: "+f)}},!0)):c(d.ERROR,"enrollUserToAb, No keys provided")};this.get_remote_config=function(a){c(d.INFO,"get_remote_config, Getting remote config from storage");return"undefined"!==typeof a?M[a]:M};this.stop_time=function(){c(d.INFO,"stop_time, Stopping tracking duration");da&&(da= -!1,Za=B()-fa,ta=B()-sa)};this.start_time=function(){c(d.INFO,"start_time, Starting tracking duration");da||(da=!0,fa=B()-Za,sa=B()-ta,ta=0,pa())};this.track_sessions=function(){function a(){document[e]||!document.hasFocus()?g.stop_time():g.start_time()}function b(){Aa>=za&&g.start_time();Aa=0}c(d.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();x(window,"beforeunload",function(){K();g.end_session()});var e="hidden";x(window,"focus",a);x(window,"blur",a); -x(window,"pageshow",a);x(window,"pagehide",a);"onfocusin"in document&&(x(window,"focusin",a),x(window,"focusout",a));e in document?document.addEventListener("visibilitychange",a):"mozHidden"in document?(e="mozHidden",document.addEventListener("mozvisibilitychange",a)):"webkitHidden"in document?(e="webkitHidden",document.addEventListener("webkitvisibilitychange",a)):"msHidden"in document&&(e="msHidden",document.addEventListener("msvisibilitychange",a));x(window,"mousemove",b);x(window,"click",b);x(window, -"keydown",b);x(window,"scroll",b);setInterval(function(){Aa++;Aa>=za&&g.stop_time()},6E4)};this.track_pageview=function(a,b,e){c(d.INFO,"track_pageview, Tracking page views");c(d.VERBOSE,"track_pageview, last view is:["+P+"]");P&&(c(d.DEBUG,"track_pageview, Scroll registry triggered"),Xa(),ya=!0,xa=0);Z();(a=w(a,g.maxKeyLength,"track_pageview",c))&&Array.isArray(a)&&(b=a,a=null);a||(a=this.getViewName());if(void 0===a||""===a)c(d.ERROR,"track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked."); -else if(null===a)c(d.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(b&&b.length)for(var k=0;k