@wireapp/telemetry 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/embed.js +161 -159
  2. package/package.json +3 -3
package/lib/embed.js CHANGED
@@ -1,159 +1,161 @@
1
- (function(ma,L){"object"===typeof exports&&"undefined"!==typeof module?L(exports):"function"===typeof define&&define.amd?define(["exports"],L):(ma="undefined"!==typeof globalThis?globalThis:ma||self,L(ma.Countly=ma.Countly||{}))})(this,function(ma){function L(l){"@babel/helpers - typeof";return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(k){return typeof k}:function(k){return k&&"function"==typeof Symbol&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},L(l)}
2
- function zb(l,k){for(var q=0;q<k.length;q++){var t=k[q];t.enumerable=t.enumerable||!1;t.configurable=!0;"value"in t&&(t.writable=!0);Object.defineProperty(l,Wb(t.key),t)}}function Wb(l){a:if("object"===typeof l&&null!==l){var k=l[Symbol.toPrimitive];if(void 0!==k){l=k.call(l,"string");if("object"!==typeof l)break a;throw new TypeError("@@toPrimitive must return a primitive value.");}l=String(l)}return"symbol"===typeof l?l:String(l)}function Ab(l){var k=[];if("undefined"!==typeof l.options)for(var q=
3
- 0;q<l.options.length;q++)l.options[q].selected&&k.push(l.options[q].value);return k.join(", ")}function fb(){var l=Bb("xxxxxxxx","[x]");var k=Date.now().toString();return l+k}function gb(){return Bb("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx","[xy]")}function Bb(l,k){var q=(new Date).getTime();return l.replace(new RegExp(k,"g"),function(t){var C=(q+16*Math.random())%16|0;return("x"===t?C:C&3|8).toString(16)})}function F(){return Math.floor((new Date).getTime()/1E3)}function hb(){var l=(new Date).getTime();
4
- Pa>=l?Pa++:Pa=l;return Pa}function u(l,k,q){if(k&&Object.keys(k).length){if("undefined"!==typeof k[l])return k[l]}else if("undefined"!==typeof p[l])return p[l];return q}function ib(l,k,q){for(var t in p.i)p.i[t].tracking_crashes&&p.i[t].recordError(l,k,q)}function jb(l,k){var q=[],t;for(t in l)q.push(t+"="+encodeURIComponent(l[t]));var C=q.join("&");return k?Cb(C,k).then(function(O){return C+="&checksum256="+O}):Promise.resolve(C)}function ta(l){return"string"===typeof l&&"/"===l.substring(l.length-
5
- 1)?l.substring(0,l.length-1):l}function za(l,k){for(var q={},t,C=0,O=k.length;C<O;C++)t=k[C],"undefined"!==typeof l[t]&&(q[t]=l[t]);return q}function ba(l,k,q,t,C,O){var Q={};if(l){if(Object.keys(l).length>t){var W={},Aa=0,na;for(na in l)Aa<t&&(W[na]=l[na],Aa++);l=W}for(var Ba in l)t=z(Ba,k,C,O),W=z(l[Ba],q,C,O),Q[t]=W}return Q}function z(l,k,q,t){var C=l;"number"===typeof l&&(l=l.toString());"string"===typeof l&&l.length>k&&(C=l.substring(0,k),t(c.DEBUG,q+", Key: [ "+l+" ] is longer than accepted length. It will be truncated."));
6
- return C}function Cb(l,k){l=(new TextEncoder).encode(l+k);return crypto.subtle.digest("SHA-256",l).then(function(q){return Array.from(new Uint8Array(q)).map(function(t){return t.toString(16).padStart(2,"0")}).join("")})}function A(l,k,q){x&&(null===l||"undefined"===typeof l?Ca()&&console.warn("[WARNING] [Countly] add_event_listener, Can't bind ["+k+"] event to nonexisting element"):"undefined"!==typeof l.addEventListener?l.addEventListener(k,q,!1):l.attachEvent("on"+k,q))}function Qa(l){return l?
7
- "undefined"!==typeof l.target?l.target:l.srcElement:window.event.srcElement}function ua(l){if(l)return l;(l=navigator.userAgent)||(l=kb());return l}function kb(l){if(l)return l;l="";navigator.userAgentData&&(l=navigator.userAgentData.brands.map(function(k){return k.brand+":"+k.version}).join(),l+=navigator.userAgentData.mobile?" mobi ":" ",l+=navigator.userAgentData.platform);return l}function Db(l){if(!l){if(navigator.userAgentData&&navigator.userAgentData.mobile)return"phone";l=ua()}l=l.toLowerCase();
8
- var k="desktop",q=/(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(l)?k="tablet":q.test(l)&&(k="phone");return k}function Eb(l){var k=/(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|Lighthouse)/;
9
- if(l)return k.test(l);l=k.test(ua());k=k.test(kb());return l||k}function lb(l){"undefined"===typeof l.pageY&&"number"===typeof l.clientX&&document.documentElement&&(l.pageX=l.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l.pageY=l.clientY+document.body.scrollTop+document.documentElement.scrollTop);return l}function Ra(){var l=document;return Math.max(Math.max(l.body.scrollHeight,l.documentElement.scrollHeight),Math.max(l.body.offsetHeight,l.documentElement.offsetHeight),Math.max(l.body.clientHeight,
10
- l.documentElement.clientHeight))}function mb(){var l=document;return Math.max(Math.max(l.body.scrollWidth,l.documentElement.scrollWidth),Math.max(l.body.offsetWidth,l.documentElement.offsetWidth),Math.max(l.body.clientWidth,l.documentElement.clientWidth))}function Fb(){var l=document;return Math.min(Math.min(l.body.clientHeight,l.documentElement.clientHeight),Math.min(l.body.offsetHeight,l.documentElement.offsetHeight),window.innerHeight)}function Gb(l,k,q,t,C,O){l=document.createElement(l);var Q;
11
- l.setAttribute(k,q);l.setAttribute(t,C);k=function(){Q||O();Q=!0};O&&(l.onreadystatechange=k,l.onload=k);document.getElementsByTagName("head")[0].appendChild(l)}function Hb(l,k){Gb("script","type","text/javascript","src",l,k)}function Sa(l,k){Gb("link","rel","stylesheet","href",l,k)}function Ib(){if(x){var l=document.getElementById("cly-loader");if(!l){var k=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=
12
- "#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%;}}":q.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%;}}"));
13
- k.appendChild(q);l=document.createElement("div");l.setAttribute("id","cly-loader");document.body.onload=function(){if(p.showLoaderProtection)Ca()&&console.warn("[WARNING] [Countly] showloader, Loader is already on");else try{document.body.appendChild(l)}catch(t){Ca()&&console.error("[ERROR] [Countly] showLoader, Body is not loaded for loader to append: "+t)}}}l.style.display="block"}}function Ca(){return p&&p.debug&&"undefined"!==typeof console?!0:!1}function Jb(){if(x){p.showLoaderProtection=!0;
14
- var l=document.getElementById("cly-loader");l&&(l.style.display="none")}}function Xb(l){var k=document.createElement("script"),q=document.createElement("script");k.async=!0;q.async=!0;k.src=p.customSourceBoomerang||Kb.BOOMERANG_SRC;q.src=p.customSourceCountlyBoomerang||Kb.CLY_BOOMERANG_SRC;document.getElementsByTagName("head")[0].appendChild(k);document.getElementsByTagName("head")[0].appendChild(q);var t=!1,C=!1;k.onload=function(){t=!0};q.onload=function(){C=!0};var O=0,Q=setInterval(function(){O+=
15
- 50;if(t&&C||1500<=O){if(p.debug){var W="BoomerangJS loaded:["+t+"], countly_boomerang loaded:["+C+"].";t&&C?console.log("[DEBUG] "+W):console.warn("[WARNING] "+W+" Initializing without APM.")}p.init(l);clearInterval(Q)}},50)}var M={NPS:"[CLY]_nps",SURVEY:"[CLY]_survey",STAR_RATING:"[CLY]_star_rating",VIEW:"[CLY]_view",ORIENTATION:"[CLY]_orientation",ACTION:"[CLY]_action"},Yb=Object.values(M),c={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "},Kb={BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/boomerang.min.js",
16
- CLY_BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/countly_boomerang.js"},U=Object.freeze({errorCount:"cly_hc_error_count",warningCount:"cly_hc_warning_count",statusCode:"cly_hc_status_code",errorMessage:"cly_hc_error_message"}),Lb=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,x="undefined"!==typeof window,p=globalThis.Countly||{},
17
- Pa=0,Ub=function(l,k,q){k&&zb(l.prototype,k);q&&zb(l,q);Object.defineProperty(l,"prototype",{writable:!1});return l}(function q(k){function t(a,d){if(f.ignore_visitor)b(c.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);Yb.includes(a.key)||(a.key=z(a.key,f.maxKeyLength,"add_cly_event",b));a.segmentation=ba(a.segmentation,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"add_cly_event",b);a=za(a,["key","count","sum","dur","segmentation"]);a.timestamp=
18
- hb();var e=new Date;a.hour=e.getHours();a.dow=e.getDay();a.id=d||fb();a.key===M.VIEW?a.pvid=Da||"":a.cvid=ia||"";I.push(a);w("cly_event",I);b(c.INFO,"With event ID: ["+a.id+"], successfully adding the last event:",a)}else b(c.ERROR,"Adding event failed. Event must have a key property")}function C(a,d,e,h,m){b(c.INFO,"fetch_remote_config_explicit, Fetching sequence initiated");var g={method:"rc",av:f.app_version};a&&(g.keys=JSON.stringify(a));d&&(g.omit_keys=JSON.stringify(d));var n;"legacy"===h&&
19
- (g.method="fetch_remote_config");0===e&&(g.oi=0);1===e&&(g.oi=1);"function"===typeof m&&(n=m);f.check_consent("sessions")&&(g.metrics=JSON.stringify(Ta()));f.check_consent("remote-config")?(Ea(g),ca("fetch_remote_config_explicit",f.url+Ua,g,function(r,v,G){if(!r){try{var N=JSON.parse(G);if(g.keys||g.omit_keys)for(var J in N)S[J]=N[J];else S=N;w("cly_remote_configs",S)}catch(Fa){b(c.ERROR,"fetch_remote_config_explicit, Had an issue while parsing the response: "+Fa)}n&&(b(c.INFO,"fetch_remote_config_explicit, Callback function is provided"),
20
- n(r,S))}},!0)):(b(c.ERROR,"fetch_remote_config_explicit, Remote config requires explicit consent"),n&&n(Error("Remote config requires explicit consent"),S))}function O(){b(c.INFO,"checkIgnore, Checking if user or visit should be ignored");f.ignore_prefetch&&x&&"undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to prerendering"));f.ignore_bots&&Eb()&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to bot"))}
21
- function Q(){0<I.length&&(b(c.DEBUG,"Flushing events"),P({events:JSON.stringify(I)}),I=[],w("cly_event",I))}function W(a,d){if(x)if(document.getElementById("countly-feedback-sticker-"+a._id))b(c.ERROR,"Widget with same ID exists");else try{var e=document.createElement("div");e.className="countly-iframe-wrapper";e.id="countly-iframe-wrapper-"+a._id;var h=document.createElement("span");h.className="countly-feedback-close-icon";h.id="countly-feedback-close-icon-"+a._id;h.innerText="x";var m=document.createElement("iframe");
22
- m.name="countly-feedback-iframe";m.id="countly-feedback-iframe";m.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+f.device_id+"&sdk_version="+oa;document.body.appendChild(e);e.appendChild(h);e.appendChild(m);A(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="none";document.getElementById("cfbg").style.display="none"});if(d){var g=document.createElementNS("http://www.w3.org/2000/svg",
23
- "svg");g.id="feedback-sticker-svg";g.setAttribute("aria-hidden","true");g.setAttribute("data-prefix","far");g.setAttribute("data-icon","grin");g.setAttribute("class","svg-inline--fa fa-grin fa-w-16");g.setAttribute("role","img");g.setAttribute("xmlns","http://www.w3.org/2000/svg");g.setAttribute("viewBox","0 0 496 512");var n=document.createElementNS("http://www.w3.org/2000/svg","path");n.id="smileyPathInStickerSvg";n.setAttribute("fill","white");n.setAttribute("d","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm105.6-151.4c-25.9 8.3-64.4 13.1-105.6 13.1s-79.6-4.8-105.6-13.1c-9.9-3.1-19.4 5.4-17.7 15.3 7.9 47.1 71.3 80 123.3 80s115.3-32.9 123.3-80c1.6-9.8-7.7-18.4-17.7-15.3zM168 240c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z");
24
- var r=document.createElement("span");r.innerText=a.trigger_button_text;var v=document.createElement("div");v.style.color=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;v.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;v.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;v.id="countly-feedback-sticker-"+a._id;g.appendChild(n);v.appendChild(g);v.appendChild(r);document.body.appendChild(v);var G=document.getElementById("smileyPathInStickerSvg");
25
- G&&(G.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);A(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(N){b(c.ERROR,"Somethings went wrong while element injecting process: "+
26
- N)}else b(c.WARNING,"processWidget, window object is not available. Not processing widget.")}function Aa(){var a;if("undefined"!==typeof f.onload&&0<f.onload.length){for(a=0;a<f.onload.length;a++)if("function"===typeof f.onload[a])f.onload[a](f);f.onload=[]}}function na(){if(Y){var a={name:Y};f.check_consent("views")&&(t({key:M.VIEW,dur:pa?F()-Ga:Ha,segmentation:a},ia),Y=null)}}function Ba(){if(ja){var a=y("cly_session");if(!a||parseInt(a)<=F())X=!1,f.begin_session(!Ia);w("cly_session",F()+60*Ja)}}
27
- function Ea(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name=va;a.sdk_version=oa;a.t=D;a.av=f.app_version;var d=Mb();if(a.metrics){var e=JSON.parse(a.metrics);e._ua||(e._ua=d,a.metrics=JSON.stringify(e))}else a.metrics=JSON.stringify({_ua:d});f.check_consent("location")?(f.country_code&&(a.country_code=f.country_code),f.city&&(a.city=f.city),null!==f.ip_address&&(a.ip_address=f.ip_address)):a.location="";a.timestamp=hb();d=new Date;a.hour=d.getHours();a.dow=d.getDay()}function P(a){f.ignore_visitor?
28
- b(c.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(Ea(a),H.length>Va&&H.shift(),H.push(a),w("cly_queue",H,!0)):b(c.ERROR,"app_key or device_id is missing ",f.app_key,f.device_id)}function Wa(){Aa();if(f.ignore_visitor)Xa=!1,b(c.WARNING,"User opt_out, no heartbeat");else{Xa=!0;Ya&&"undefined"!==typeof p.q&&0<p.q.length&&wa();if(X&&Ia&&pa){var a=F();a-ka>Za&&(f.session_duration(a-ka),ka=a,0<f.hcErrorCount&&w(U.errorCount,f.hcErrorCount),0<f.hcWarningCount&&w(U.warningCount,
29
- f.hcWarningCount))}0<I.length&&!f.test_mode_eq&&(I.length<=Ka?(P({events:JSON.stringify(I)}),I=[]):(a=I.splice(0,Ka),P({events:JSON.stringify(a)})),w("cly_event",I));!K&&0<H.length&&$a&&F()>nb&&($a=!1,a=H[0],a.rr=H.length,b(c.DEBUG,"Processing request",a),w("cly_queue",H,!0),f.test_mode||ca("send_request_queue",f.url+ob,a,function(d,e){d?nb=F()+ab:H.shift();w("cly_queue",H,!0);$a=!0},!1));setTimeout(Wa,bb)}}function wa(){if("undefined"===typeof p||"undefined"===typeof p.i)b(c.DEBUG,"Countly is not finished initialization yet, will process the queue after initialization is done");
30
- else{var a=p.q;p.q=[];for(var d=0;d<a.length;d++){var e=a[d];b(c.DEBUG,"Processing queued calls:"+e);if("function"===typeof e)e();else if(Array.isArray(e)&&0<e.length){var h=f,m=0;try{p.i[e[m]]&&(h=p.i[e[m]],m++)}catch(n){b(c.DEBUG,"No instance found for the provided key while processing async queue");p.q.push(e);continue}if("function"===typeof h[e[m]])h[e[m]].apply(h,e.slice(m+1));else if(0===e[m].indexOf("userData.")){var g=e[m].replace("userData.","");"function"===typeof h.userData[g]&&h.userData[g].apply(h,
31
- e.slice(m+1))}else"function"===typeof p[e[m]]&&p[e[m]].apply(p,e.slice(m+1))}}}}function pb(){var a=y("cly_id");return a?(D=y("cly_id_type"),a):gb()}function Mb(){return f.metrics._ua||ua()}function Ta(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=a._app_version||f.app_version;a._ua=a._ua||ua();if(x&&screen.width){var d=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==d&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&
32
- window.devicePixelRatio)d=Math.round(d*window.devicePixelRatio),e=Math.round(e*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var h=d;d=e;e=h}a._resolution=a._resolution||""+d+"x"+e}}x&&window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);d=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof d&&(a._locale=a._locale||d);qb()&&(a._store=a._store||document.referrer);b(c.DEBUG,"Got metrics",a);return a}
33
- function qb(a){if(!x)return!1;a=a||document.referrer;var d=!1;if("undefined"===typeof a||0===a.length)b(c.DEBUG,"Invalid referrer:["+a+"], ignoring.");else{var e=Lb.exec(a);if(e)if(e[11])if(e[11]===window.location.hostname)b(c.DEBUG,"Referrer is current host:["+a+"], ignoring.");else if(da&&da.length)for(d=!0,e=0;e<da.length;e++){if(0<=a.indexOf(da[e])){b(c.DEBUG,"Referrer in ignore list:["+a+"], ignoring.");d=!1;break}}else b(c.DEBUG,"Valid referrer:["+a+"]"),d=!0;else b(c.DEBUG,"No path found in referrer:["+
34
- a+"], ignoring.");else b(c.DEBUG,"Referrer is corrupt:["+a+"], ignoring.")}return d}function b(a,d){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===L(arguments[2])&&(arguments[2]=JSON.stringify(arguments[2]));Ya||(d="["+f.app_key+"] "+d);a||(a=c.DEBUG);for(var e="",h=2;h<arguments.length;h++)e+=arguments[h];e=a+"[Countly] "+d+e;a===c.ERROR?(console.error(e),qa.incrementErrorCount()):a===c.WARNING?(console.warn(e),qa.incrementWarningCount()):a===c.INFO?console.info(e):a===c.VERBOSE?
35
- console.log(e):console.debug(e)}}function ca(a,d,e,h,m){x?Nb(a,d,e,h,m):Ob(a,d,e,h,m)}function Nb(a,d,e,h,m){m=m||!1;try{b(c.DEBUG,"Sending XML HTTP request");var g=new XMLHttpRequest;e=e||{};jb(e,f.salt).then(function(n){var r="GET";if(f.force_post||2E3<=n.length)r="POST";"GET"===r?g.open("GET",d+"?"+n,!0):(g.open("POST",d,!0),g.setRequestHeader("Content-type","application/x-www-form-urlencoded"));for(var v in f.headers)g.setRequestHeader(v,f.headers[v]);g.onreadystatechange=function(){4===this.readyState&&
36
- (b(c.DEBUG,a+" HTTP request completed with status code: ["+this.status+"] and response: ["+this.responseText+"]"),(m?rb(this.status,this.responseText):sb(this.status,this.responseText))?"function"===typeof h&&h(!1,e,this.responseText):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(this.status,this.responseText),"function"===typeof h&&h(!0,e,this.status,this.responseText)))};"GET"===r?g.send():g.send(n)})}catch(n){b(c.ERROR,a+" Something went wrong while making an XML HTTP request: "+
37
- n),"function"===typeof h&&h(!0,e)}}function Ob(a,d,e,h,m){m=m||!1;var g;try{b(c.DEBUG,"Sending Fetch request");var n="GET",r={"Content-type":"application/x-www-form-urlencoded"},v=null;e=e||{};jb(e,f.salt).then(function(G){f.force_post||2E3<=G.length?(n="POST",v=G):d+="?"+G;for(var N in f.headers)r[N]=f.headers[N];fetch(d,{method:n,headers:r,body:v}).then(function(J){g=J;return g.text()}).then(function(J){b(c.DEBUG,a+" Fetch request completed wit status code: ["+g.status+"] and response: ["+J+"]");
38
- (m?rb(g.status,J):sb(g.status,J))?"function"===typeof h&&h(!1,e,J):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(g.status,J),"function"===typeof h&&h(!0,e,g.status,J))})["catch"](function(J){b(c.ERROR,a+" Failed Fetch request: "+J);"function"===typeof h&&h(!0,e)})})}catch(G){b(c.ERROR,a+" Something went wrong with the Fetch request attempt: "+G),"function"===typeof h&&h(!0,e)}}function sb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+
39
- a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"!==Object.prototype.toString.call(e)?(b(c.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function rb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(b(c.ERROR,"Http response is not JSON Object nor JSON Array"),
40
- !1)}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function Pb(){x?La=Math.max(La,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop):b(c.WARNING,"processScroll, window object is not available. Not processing scroll.")}function tb(){if(!x)b(c.WARNING,"processScrollView, window object is not available. Not processing scroll view.");else if(Ma){Ma=!1;var a=Ra(),d=mb(),e=Fb();f.check_consent("scrolls")&&(a={type:"scroll",y:La+e,width:d,height:a,view:f.getViewUrl()},
41
- a=ba(a,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processScrollView",b),f.track_domains&&(a.domain=window.location.hostname),t({key:M.ACTION,segmentation:a}))}}function Qb(a){w("cly_token",a)}function Rb(a,d,e){var h=new Date;h.setTime(h.getTime()+864E5*e);e="; expires="+h.toGMTString();document.cookie=a+"="+d+e+"; path=/"}function y(a,d,e){if("none"===f.storage||"object"!==L(f.storage)&&!x)b(c.DEBUG,"Storage is disabled. Value with key: ["+a+"] won't be retrieved");else{e||(a=f.app_key+
42
- "/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a));if("object"===L(f.storage)&&"function"===typeof f.storage.getItem){var h=f.storage.getItem(a);return a.endsWith("cly_id")?h:f.deserialize(h)}void 0===d&&(d=ra);if(d)h=localStorage.getItem(a);else if("localstorage"!==f.storage)a:{d=a+"=";e=document.cookie.split(";");h=0;for(var m=e.length;h<m;h++){for(var g=e[h];" "===g.charAt(0);)g=g.substring(1,g.length);if(0===g.indexOf(d)){h=g.substring(d.length,g.length);break a}}h=null}return a.endsWith("cly_id")?
43
- h:f.deserialize(h)}}function w(a,d,e,h){"none"===f.storage||"object"!==L(f.storage)&&!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be stored"):(h||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"undefined"!==typeof d&&null!==d&&("object"===L(f.storage)&&"function"===typeof f.storage.setItem?f.storage.setItem(a,d):(void 0===e&&(e=ra),d=f.serialize(d),e?localStorage.setItem(a,d):"localstorage"!==f.storage&&Rb(a,d,30))))}function T(a,d,e){"none"===f.storage||"object"!==L(f.storage)&&
44
- !x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be removed"):(e||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"object"===L(f.storage)&&"function"===typeof f.storage.removeItem?f.storage.removeItem(a):(void 0===d&&(d=ra),d?localStorage.removeItem(a):"localstorage"!==f.storage&&Rb(a,"",-1)))}function Zb(){if(y(f.namespace+"cly_id",!1,!0)){w("cly_id",y(f.namespace+"cly_id",!1,!0));w("cly_id_type",y(f.namespace+"cly_id_type",!1,!0));w("cly_event",y(f.namespace+"cly_event",
45
- !1,!0));w("cly_session",y(f.namespace+"cly_session",!1,!0));var a=y(f.namespace+"cly_queue",!1,!0);Array.isArray(a)&&(a=a.filter(function(d){return d.app_key===f.app_key}),w("cly_queue",a));y(f.namespace+"cly_cmp_id",!1,!0)&&(w("cly_cmp_id",y(f.namespace+"cly_cmp_id",!1,!0)),w("cly_cmp_uid",y(f.namespace+"cly_cmp_uid",!1,!0)));y(f.namespace+"cly_ignore",!1,!0)&&w("cly_ignore",y(f.namespace+"cly_ignore",!1,!0));T("cly_id",!1,!0);T("cly_id_type",!1,!0);T("cly_event",!1,!0);T("cly_session",!1,!0);T("cly_queue",
46
- !1,!0);T("cly_cmp_id",!1,!0);T("cly_cmp_uid",!1,!0);T("cly_ignore",!1,!0)}}if(!(this instanceof q))throw new TypeError("Cannot call a class as a function");var f=this,Ya=!p.i,X=!1,ob="/i",Ua="/o/sdk",bb=u("interval",k,500),Va=u("queue_size",k,1E3),H=[],I=[],S={},sa=[],ea={},da=u("ignore_referrers",k,[]),ub=null,Ia=!0,ka,vb=0,Y=null,Ga=0,Ha=0,nb=0,ab=u("fail_timeout",k,60),Na=u("inactivity_time",k,20),Oa=0,Za=u("session_update",k,60),Ka=u("max_events",k,100),xa=u("max_logs",k,null),ja=u("use_session_cookie",
47
- k,!0),Ja=u("session_cookie_timeout",k,30),$a=!0,Xa=!1,K=u("offline_mode",k,!1),fa={},pa=!0,Sb=F(),ra=!0,ya=null,D=1,Ma=!1,La=0,wb=!1,ia=null,Da=null,la=null,va=u("sdk_name",k,"javascript_native_web"),oa=u("sdk_version",k,"24.4.1");try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(a){b(c.ERROR,"Local storage test failed, Halting local storage support: "+a),ra=!1}for(var E={},xb=0;xb<p.features.length;xb++)E[p.features[xb]]={};this.initialize=function(){this.serialize=
48
- u("serialize",k,p.serialize);this.deserialize=u("deserialize",k,p.deserialize);this.getViewName=u("getViewName",k,p.getViewName);this.getViewUrl=u("getViewUrl",k,p.getViewUrl);this.getSearchQuery=u("getSearchQuery",k,p.getSearchQuery);this.DeviceIdType=p.DeviceIdType;this.namespace=u("namespace",k,"");this.clearStoredId=u("clear_stored_id",k,!1);this.app_key=u("app_key",k,null);this.onload=u("onload",k,[]);this.utm=u("utm",k,{source:!0,medium:!0,campaign:!0,term:!0,content:!0});this.ignore_prefetch=
49
- u("ignore_prefetch",k,!0);this.rcAutoOptinAb=u("rc_automatic_optin_for_ab",k,!0);this.useExplicitRcApi=u("use_explicit_rc_api",k,!1);this.debug=u("debug",k,!1);this.test_mode=u("test_mode",k,!1);this.test_mode_eq=u("test_mode_eq",k,!1);this.metrics=u("metrics",k,{});this.headers=u("headers",k,{});this.url=ta(u("url",k,""));this.app_version=u("app_version",k,"0.0");this.country_code=u("country_code",k,null);this.city=u("city",k,null);this.ip_address=u("ip_address",k,null);this.ignore_bots=u("ignore_bots",
50
- k,!0);this.force_post=u("force_post",k,!1);this.remote_config=u("remote_config",k,!1);this.ignore_visitor=u("ignore_visitor",k,!1);this.require_consent=u("require_consent",k,!1);this.track_domains=x?u("track_domains",k,!0):void 0;this.storage=u("storage",k,"default");this.enableOrientationTracking=x?u("enable_orientation_tracking",k,!0):void 0;this.maxKeyLength=u("max_key_length",k,128);this.maxValueSize=u("max_value_size",k,256);this.maxSegmentationValues=u("max_segmentation_values",k,100);this.maxBreadcrumbCount=
51
- u("max_breadcrumb_count",k,null);this.maxStackTraceLinesPerThread=u("max_stack_trace_lines_per_thread",k,30);this.maxStackTraceLineLength=u("max_stack_trace_line_length",k,200);this.heatmapWhitelist=u("heatmap_whitelist",k,[]);f.salt=u("salt",k,null);f.hcErrorCount=y(U.errorCount)||0;f.hcWarningCount=y(U.warningCount)||0;f.hcStatusCode=y(U.statusCode)||-1;f.hcErrorMessage=y(U.errorMessage)||"";xa&&!this.maxBreadcrumbCount?(this.maxBreadcrumbCount=xa,b(c.WARNING,"initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!")):
52
- xa||this.maxBreadcrumbCount||(this.maxBreadcrumbCount=100);"cookie"===this.storage&&(ra=!1);this.rcAutoOptinAb||this.useExplicitRcApi||(b(c.WARNING,"initialize, Auto opting is disabled, switching to explicit RC API"),this.useExplicitRcApi=!0);Array.isArray(da)||(da=[]);""===this.url&&(b(c.ERROR,"initialize, Please provide server URL"),this.ignore_visitor=!0);y("cly_ignore")&&(this.ignore_visitor=!0);Zb();H=y("cly_queue")||[];I=y("cly_event")||[];S=y("cly_remote_configs")||{};this.clearStoredId&&(y("cly_id")&&
53
- !g&&(this.device_id=y("cly_id"),b(c.DEBUG,"initialize, temporarily using the previous device ID to flush existing events"),D=y("cly_id_type"),D||(b(c.DEBUG,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"),D=0),Q(),this.device_id=void 0,D=1),b(c.INFO,"initialize, Clearing the device ID storage"),T("cly_id"),T("cly_id_type"),T("cly_session"));O();if(x)if(window.name&&0===window.name.indexOf("cly:"))try{this.passed_data=JSON.parse(window.name.replace("cly:",
54
- ""))}catch(r){b(c.ERROR,"initialize, Could not parse name: "+window.name+", error: "+r)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{this.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(r){b(c.ERROR,"initialize, Could not parse hash: "+location.hash+", error: "+r)}if((this.passed_data&&this.passed_data.app_key&&this.passed_data.app_key===this.app_key||this.passed_data&&!this.passed_data.app_key&&Ya)&&this.passed_data.token&&this.passed_data.purpose){this.passed_data.token!==
55
- y("cly_old_token")&&(Qb(this.passed_data.token),w("cly_old_token",this.passed_data.token));var a=[];Array.isArray(this.heatmapWhitelist)?(this.heatmapWhitelist.push(this.url),a=this.heatmapWhitelist.map(function(r){return ta(r)})):a=[this.url];a.includes(this.passed_data.url)&&"heatmap"===this.passed_data.purpose&&(this.ignore_visitor=!0,Ib(),Hb(this.passed_data.url+"/views/heatmap.js",Jb))}if(this.ignore_visitor)b(c.WARNING,"initialize, ignore_visitor:["+this.ignore_visitor+"], this user will not be tracked");
56
- else{"javascript_native_web"===va&&"24.4.1"===oa?b(c.DEBUG,"initialize, SDK name:["+va+"], version:["+oa+"]"):b(c.DEBUG,"initialize, SDK name:["+va+"], version:["+oa+"], default name:[javascript_native_web] and default version:[24.4.1]");b(c.DEBUG,"initialize, app_key:["+this.app_key+"], url:["+this.url+"]");b(c.DEBUG,"initialize, device_id:["+u("device_id",k,void 0)+"]");b(c.DEBUG,"initialize, require_consent is enabled:["+this.require_consent+"]");try{b(c.DEBUG,"initialize, metric override:["+JSON.stringify(this.metrics)+
57
- "]"),b(c.DEBUG,"initialize, header override:["+JSON.stringify(this.headers)+"]"),b(c.DEBUG,"initialize, number of onload callbacks provided:["+this.onload.length+"]"),b(c.DEBUG,"initialize, utm tags:["+JSON.stringify(this.utm)+"]"),da&&b(c.DEBUG,"initialize, referrers to ignore :["+JSON.stringify(da)+"]"),b(c.DEBUG,"initialize, salt given:["+!!f.salt+"]")}catch(r){b(c.ERROR,"initialize, Could not stringify some config object values")}b(c.DEBUG,"initialize, app_version:["+this.app_version+"]");b(c.DEBUG,
58
- "initialize, provided location info; country_code:["+this.country_code+"], city:["+this.city+"], ip_address:["+this.ip_address+"]");""!==this.namespace&&b(c.DEBUG,"initialize, namespace given:["+this.namespace+"]");this.clearStoredId&&b(c.DEBUG,"initialize, clearStoredId flag set to:["+this.clearStoredId+"]");this.ignore_prefetch&&b(c.DEBUG,"initialize, ignoring pre-fetching and pre-rendering from counting as real website visits :["+this.ignore_prefetch+"]");this.test_mode&&b(c.WARNING,"initialize, test_mode:["+
59
- this.test_mode+"], request queue won't be processed");this.test_mode_eq&&b(c.WARNING,"initialize, test_mode_eq:["+this.test_mode_eq+"], event queue won't be processed");this.heatmapWhitelist&&b(c.DEBUG,"initialize, heatmap whitelist:["+JSON.stringify(this.heatmapWhitelist)+"], these domains will be whitelisted");"default"!==this.storage&&b(c.DEBUG,"initialize, storage is set to:["+this.storage+"]");this.ignore_bots&&b(c.DEBUG,"initialize, ignore traffic from bots :["+this.ignore_bots+"]");this.force_post&&
60
- b(c.DEBUG,"initialize, forced post method for all requests:["+this.force_post+"]");this.remote_config&&b(c.DEBUG,"initialize, remote_config callback provided:["+!!this.remote_config+"]");"boolean"===typeof this.rcAutoOptinAb&&b(c.DEBUG,"initialize, automatic RC optin is enabled:["+this.rcAutoOptinAb+"]");this.useExplicitRcApi||b(c.WARNING,"initialize, will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag");this.track_domains&&b(c.DEBUG,"initialize, tracking domain info:["+
61
- this.track_domains+"]");this.enableOrientationTracking&&b(c.DEBUG,"initialize, enableOrientationTracking:["+this.enableOrientationTracking+"]");ja||b(c.WARNING,"initialize, use_session_cookie is enabled:["+ja+"]");K&&b(c.DEBUG,"initialize, offline_mode:["+K+"], user info won't be send to the servers");K&&b(c.DEBUG,"initialize, stored remote configs:["+JSON.stringify(S)+"]");b(c.DEBUG,"initialize, 'getViewName' callback override provided:["+(this.getViewName!==p.getViewName)+"]");b(c.DEBUG,"initialize, 'getSearchQuery' callback override provided:["+
62
- (this.getSearchQuery!==p.getSearchQuery)+"]");128!==this.maxKeyLength&&b(c.DEBUG,"initialize, maxKeyLength set to:["+this.maxKeyLength+"] characters");256!==this.maxValueSize&&b(c.DEBUG,"initialize, maxValueSize set to:["+this.maxValueSize+"] characters");100!==this.maxSegmentationValues&&b(c.DEBUG,"initialize, maxSegmentationValues set to:["+this.maxSegmentationValues+"] key/value pairs");100!==this.maxBreadcrumbCount&&b(c.DEBUG,"initialize, maxBreadcrumbCount for custom logs set to:["+this.maxBreadcrumbCount+
63
- "] entries");30!==this.maxStackTraceLinesPerThread&&b(c.DEBUG,"initialize, maxStackTraceLinesPerThread set to:["+this.maxStackTraceLinesPerThread+"] lines");200!==this.maxStackTraceLineLength&&b(c.DEBUG,"initialize, maxStackTraceLineLength set to:["+this.maxStackTraceLineLength+"] characters");500!==bb&&b(c.DEBUG,"initialize, interval for heartbeats set to:["+bb+"] milliseconds");1E3!==Va&&b(c.DEBUG,"initialize, queue_size set to:["+Va+"] items max");60!==ab&&b(c.DEBUG,"initialize, fail_timeout set to:["+
64
- ab+"] seconds of wait time after a failed connection to server");20!==Na&&b(c.DEBUG,"initialize, inactivity_time set to:["+Na+"] minutes to consider a user as inactive after no observable action");60!==Za&&b(c.DEBUG,"initialize, session_update set to:["+Za+"] seconds to check if extending a session is needed while the user is active");100!==Ka&&b(c.DEBUG,"initialize, max_events set to:["+Ka+"] events to send in one batch");xa&&b(c.WARNING,"initialize, max_logs set to:["+xa+"] breadcrumbs to store for crash logs max, deprecated ");
65
- 30!==Ja&&b(c.DEBUG,"initialize, session_cookie_timeout set to:["+Ja+"] minutes to expire a cookies session");a=null;g=f.getSearchQuery();var d=!1,e={};if(g){0===g.indexOf("?")&&(g=g.substring(1));g=g.split("&");for(var h=0;h<g.length;h++){var m=g[h].split("=");"cly_id"===m[0]?w("cly_cmp_id",m[1]):"cly_uid"===m[0]?w("cly_cmp_uid",m[1]):"cly_device_id"===m[0]?a=m[1]:0===(m[0]+"").indexOf("utm_")&&this.utm[m[0].replace("utm_","")]&&(e[m[0].replace("utm_","")]=m[1],d=!0)}}var g="[CLY]_temp_id"===y("cly_id");
66
- h=u("device_id",k,void 0);"number"===typeof h&&(h=h.toString());y("cly_id")&&!g?(this.device_id=y("cly_id"),b(c.INFO,"initialize, Set the stored device ID"),D=y("cly_id_type"),D||(b(c.INFO,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"),D=0)):null!==a?(b(c.INFO,"initialize, Device ID set by URL"),this.device_id=a,D=3):h?(b(c.INFO,"initialize, Device ID set by developer"),this.device_id=h,k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==
67
- p.device_id&&(D=0)):K||g?(this.device_id="[CLY]_temp_id",D=2,K&&g?b(c.INFO,"initialize, Temp ID set, continuing offline mode from previous app session"):K&&!g?b(c.INFO,"initialize, Temp ID set, entering offline mode"):(K=!0,b(c.INFO,"initialize, Temp ID set, enabling offline mode"))):(b(c.INFO,"initialize, Generating the device ID"),this.device_id=u("device_id",k,pb()),k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==p.device_id&&(D=0));w("cly_id",this.device_id);w("cly_id_type",D);if(d){la=
68
- {};for(var n in this.utm)e[n]?(this.userData.set("utm_"+n,e[n]),la[n]=e[n]):this.userData.unset("utm_"+n);this.userData.save()}Aa();setTimeout(function(){p.noHeartBeat?b(c.WARNING,"initialize, Heartbeat disabled. This is for testing purposes only!"):Wa();f.remote_config&&f.fetch_remote_config(f.remote_config)},1);x&&document.documentElement.setAttribute("data-countly-useragent",ua());qa.sendInstantHCRequest();b(c.INFO,"initialize, Countly initialized")}};this.halt=function(){b(c.WARNING,"halt, Resetting Countly");
69
- p.i=void 0;p.q=[];p.noHeartBeat=void 0;Ya=!p.i;X=!1;ob="/i";Ua="/o/sdk";bb=500;Va=1E3;H=[];I=[];S={};sa=[];ea={};da=[];ub=null;Ia=!0;vb=0;Y=null;nb=Ha=Ga=0;ab=60;Na=20;Oa=0;Za=60;Ka=100;xa=null;ja=!0;Ja=30;$a=!0;K=Xa=!1;fa={};pa=!0;Sb=F();ra=!0;ya=null;D=1;Ma=!1;La=0;wb=!1;la=Da=ia=null;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(d){b(c.ERROR,"halt, Local storage test failed, will fallback to cookies"),ra=!1}p.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");
70
- E={};for(var a=0;a<p.features.length;a++)E[p.features[a]]={};f.app_key=void 0;f.device_id=void 0;f.onload=void 0;f.utm=void 0;f.ignore_prefetch=void 0;f.debug=void 0;f.test_mode=void 0;f.test_mode_eq=void 0;f.metrics=void 0;f.headers=void 0;f.url=void 0;f.app_version=void 0;f.country_code=void 0;f.city=void 0;f.ip_address=void 0;f.ignore_bots=void 0;f.force_post=void 0;f.rcAutoOptinAb=void 0;f.useExplicitRcApi=void 0;f.remote_config=void 0;f.ignore_visitor=void 0;f.require_consent=void 0;f.track_domains=
71
- void 0;f.storage=void 0;f.enableOrientationTracking=void 0;f.salt=void 0;f.maxKeyLength=void 0;f.maxValueSize=void 0;f.maxSegmentationValues=void 0;f.maxBreadcrumbCount=void 0;f.maxStackTraceLinesPerThread=void 0;f.maxStackTraceLineLength=void 0};this.group_features=function(a){b(c.INFO,"group_features, Grouping features");if(a)for(var d in a)E[d]?b(c.WARNING,"group_features, Feature name ["+d+"] is already reserved"):"string"===typeof a[d]?E[d]={features:[a[d]]}:a[d]&&Array.isArray(a[d])&&a[d].length?
72
- E[d]={features:a[d]}:b(c.ERROR,"group_features, Incorrect feature list for ["+d+"] value: ["+a[d]+"]");else b(c.ERROR,"group_features, Incorrect features:["+a+"]")};this.check_consent=function(a){b(c.INFO,"check_consent, Checking if consent is given for specific feature:["+a+"]");if(!this.require_consent)return b(c.INFO,"check_consent, require_consent is off, no consent is necessary"),!0;if(E[a])return!(!E[a]||!E[a].optin);b(c.ERROR,"check_consent, No feature available for ["+a+"]");return!1};this.get_device_id_type=
73
- function(){b(c.INFO,"check_device_id_type, Retrieving the current device id type.["+D+"]");switch(D){case 1:var a=f.DeviceIdType.SDK_GENERATED;break;case 3:case 0:a=f.DeviceIdType.DEVELOPER_SUPPLIED;break;case 2:a=f.DeviceIdType.TEMPORARY_ID;break;default:a=-1}return a};this.get_device_id=function(){b(c.INFO,"get_device_id, Retrieving the device id: ["+f.device_id+"]");return f.device_id};this.check_any_consent=function(){b(c.INFO,"check_any_consent, Checking if any consent is given");if(!this.require_consent)return b(c.INFO,
74
- "check_any_consent, require_consent is off, no consent is necessary"),!0;for(var a in E)if(E[a]&&E[a].optin)return!0;b(c.INFO,"check_any_consent, No consents given");return!1};this.add_consent=function(a){b(c.INFO,"add_consent, Adding consent for ["+a+"]");if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add_consent(a[d]);else E[a]?E[a].features?(E[a].optin=!0,this.add_consent(E[a].features)):!0!==E[a].optin&&(E[a].optin=!0,Tb(),setTimeout(function(){"sessions"===a&&fa.begin_session?(f.begin_session.apply(f,
75
- fa.begin_session),fa.begin_session=null):"views"===a&&fa.track_pageview&&(Y=null,f.track_pageview.apply(f,fa.track_pageview),fa.track_pageview=null)},1)):b(c.ERROR,"add_consent, No feature available for ["+a+"]")};this.remove_consent=function(a){b(c.INFO,"remove_consent, Removing consent for ["+a+"]");this.remove_consent_internal(a,!0)};this.remove_consent_internal=function(a,d){d=d||!1;if(Array.isArray(a))for(var e=0;e<a.length;e++)this.remove_consent_internal(a[e],d);else E[a]?E[a].features?this.remove_consent_internal(E[a].features,
76
- d):(E[a].optin=!1,d&&!1!==E[a].optin&&Tb()):b(c.WARNING,"remove_consent, No feature available for ["+a+"]")};var cb,Tb=function(){cb&&(clearTimeout(cb),cb=null);cb=setTimeout(function(){for(var a={},d=0;d<p.features.length;d++)a[p.features[d]]=!0===E[p.features[d]].optin?!0:!1;P({consent:JSON.stringify(a)});b(c.DEBUG,"Consent update request has been sent to the queue.")},1E3)};this.enable_offline_mode=function(){b(c.INFO,"enable_offline_mode, Enabling offline mode");this.remove_consent_internal(p.features,
77
- !1);K=!0;this.device_id="[CLY]_temp_id";f.device_id=this.device_id;D=2};this.disable_offline_mode=function(a){if(K){b(c.INFO,"disable_offline_mode, Disabling offline mode");K=!1;a&&this.device_id!==a?(this.device_id=a,f.device_id=this.device_id,D=0,w("cly_id",this.device_id),w("cly_id_type",0),b(c.INFO,"disable_offline_mode, Changing id to: "+this.device_id)):(this.device_id=pb(),"[CLY]_temp_id"===this.device_id&&(this.device_id=gb()),f.device_id=this.device_id,this.device_id!==y("cly_id")&&(w("cly_id",
78
- this.device_id),w("cly_id_type",1)));a=!1;if(0<H.length)for(var d=0;d<H.length;d++)"[CLY]_temp_id"===H[d].device_id&&(H[d].device_id=this.device_id,a=!0);a&&w("cly_queue",H,!0)}else b(c.WARNING,"disable_offline_mode, Countly was not in offline mode.")};this.begin_session=function(a,d){b(c.INFO,"begin_session, Starting the session. There was an ongoing session: ["+X+"]");a&&b(c.INFO,"begin_session, Heartbeats are disabled");d&&b(c.INFO,"begin_session, Session starts irrespective of session cookie");
79
- if(this.check_consent("sessions")){if(!X){this.enableOrientationTracking&&(this.report_orientation(),A(window,"resize",function(){f.report_orientation()}));ka=F();X=!0;Ia=!a;var e=y("cly_session");b(c.VERBOSE,"begin_session, Session state, forced: ["+d+"], useSessionCookie: ["+ja+"], seconds to expire: ["+(e-ka)+"], expired: ["+(parseInt(e)<=F())+"] ");if(d||!ja||!e||parseInt(e)<=F())b(c.INFO,"begin_session, Session started"),null===ya&&(ya=!0),e={begin_session:1},e.metrics=JSON.stringify(Ta()),P(e);
80
- w("cly_session",F()+60*Ja)}}else fa.begin_session=arguments};this.session_duration=function(a){b(c.INFO,"session_duration, Reporting session duration");this.check_consent("sessions")&&X&&(b(c.INFO,"session_duration, Session extended: ",a),P({session_duration:a}),Ba())};this.end_session=function(a,d){b(c.INFO,"end_session, Ending the current session. There was an on going session:["+X+"]");this.check_consent("sessions")&&X&&(a=a||F()-ka,na(),!ja||d?(b(c.INFO,"end_session, Session ended"),P({end_session:1,
81
- session_duration:a})):this.session_duration(a),X=!1)};this.set_id=function(a){b(c.INFO,"set_id, Changing the device ID to:["+a+"]");null==a||""===a?b(c.WARNING,"set_id, The provided device is not a valid ID"):0===D?this.change_id(a,!1):this.change_id(a,!0)};this.change_id=function(a,d){b(c.INFO,"change_id, Changing the device ID to: ["+a+"] with merge:["+d+"]");if(a&&"string"===typeof a&&0!==a.length)if(K)b(c.WARNING,"change_id, Offline mode was on, initiating disabling sequence instead."),this.disable_offline_mode(a);
82
- else if(this.device_id==a)b(c.DEBUG,"change_id, Provided device ID is equal to the current device ID. Aborting.");else{d||(wa(),Q(),this.end_session(null,!0),ea={},this.remove_consent_internal(p.features,!1));var e=this.device_id;this.device_id=a;f.device_id=this.device_id;D=0;w("cly_id",this.device_id);w("cly_id_type",0);b(c.INFO,"change_id, Changing ID from:["+e+"] to ["+a+"]");d?P({old_device_id:e}):this.begin_session(!Ia,!0);this.remote_config&&(S={},w("cly_remote_configs",S),this.fetch_remote_config(this.remote_config))}else b(c.WARNING,
83
- "change_id, The provided device ID is not a valid ID")};this.add_event=function(a){b(c.INFO,"add_event, Adding event: ",a);switch(a.key){case M.NPS:var d=this.check_consent("feedback");break;case M.SURVEY:d=this.check_consent("feedback");break;case M.STAR_RATING:d=this.check_consent("star-rating");break;case M.VIEW:d=this.check_consent("views");break;case M.ORIENTATION:d=this.check_consent("users");break;case M.ACTION:d=this.check_consent("clicks")||this.check_consent("scrolls");break;default:d=this.check_consent("events")}d&&
84
- t(a)};this.start_event=function(a){a&&"string"===typeof a?(b(c.INFO,"start_event, Starting timed event with key: ["+a+"]"),a=z(a,f.maxKeyLength,"start_event",b),ea[a]?b(c.WARNING,"start_event, Timed event with key: ["+a+"] already started"):ea[a]=F()):b(c.WARNING,"start_event, you have to provide a valid string key instead of: ["+a+"]")};this.cancel_event=function(a){if(!a||"string"!==typeof a)return b(c.WARNING,"cancel_event, you have to provide a valid string key instead of: ["+a+"]"),!1;b(c.INFO,
85
- "cancel_event, Canceling timed event with key: ["+a+"]");a=z(a,f.maxKeyLength,"cancel_event",b);if(ea[a])return delete ea[a],b(c.INFO,"cancel_event, Timed event with key: ["+a+"] is canceled"),!0;b(c.WARNING,"cancel_event, Timed event with key: ["+a+"] was not found");return!1};this.end_event=function(a){a?(b(c.INFO,"end_event, Ending timed event"),"string"===typeof a&&(a=z(a,f.maxKeyLength,"end_event",b),a={key:a}),a.key?ea[a.key]?(a.dur=F()-ea[a.key],this.add_event(a),delete ea[a.key]):b(c.ERROR,
86
- "end_event, Timed event with key: ["+a.key+"] was not started"):b(c.ERROR,"end_event, Timed event must have a key property")):b(c.WARNING,"end_event, you have to provide a valid string key or event object instead of: ["+a+"]")};this.report_orientation=function(a){b(c.INFO,"report_orientation, Reporting orientation");this.check_consent("users")&&t({key:M.ORIENTATION,segmentation:{mode:a||(window.innerWidth>window.innerHeight?"landscape":"portrait")}})};this.report_conversion=function(a,d){b(c.WARNING,
87
- "report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!");this.recordDirectAttribution(a,d)};this.recordDirectAttribution=function(a,d){b(c.INFO,"recordDirectAttribution, Recording the attribution for campaign ID: ["+a+"] and the user ID: ["+d+"]");this.check_consent("attribution")&&(a=a||y("cly_cmp_id")||"cly_organic",(d=d||y("cly_cmp_uid"))?P({campaign_id:a,campaign_user:d}):P({campaign_id:a}))};this.user_details=function(a){b(c.INFO,
88
- "user_details, Trying to add user details: ",a);this.check_consent("users")&&(wa(),Q(),b(c.INFO,"user_details, flushed the event queue"),a.name=z(a.name,f.maxValueSize,"user_details",b),a.username=z(a.username,f.maxValueSize,"user_details",b),a.email=z(a.email,f.maxValueSize,"user_details",b),a.organization=z(a.organization,f.maxValueSize,"user_details",b),a.phone=z(a.phone,f.maxValueSize,"user_details",b),a.picture=z(a.picture,4096,"user_details",b),a.gender=z(a.gender,f.maxValueSize,"user_details",
89
- b),a.byear=z(a.byear,f.maxValueSize,"user_details",b),a.custom=ba(a.custom,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"user_details",b),P({user_details:JSON.stringify(za(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var Z={},ha=function(a,d,e){f.check_consent("users")&&(Z[a]||(Z[a]={}),"$push"===e||"$pull"===e||"$addToSet"===e?(Z[a][e]||(Z[a][e]=[]),Z[a][e].push(d)):Z[a][e]=d)};this.userData={set:function(a,d){b(c.INFO,"[userData] set, Setting user's custom property value: ["+
90
- d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData set",b);d=z(d,f.maxValueSize,"userData set",b);Z[a]=d},unset:function(a){b(c.INFO,"[userData] unset, Resetting user's custom property with key: ["+a+"] ");Z[a]=""},set_once:function(a,d){b(c.INFO,"[userData] set_once, Setting user's unique custom property value: ["+d+"] under the key: ["+a+"] ");a=z(a,f.maxKeyLength,"userData set_once",b);d=z(d,f.maxValueSize,"userData set_once",b);ha(a,d,"$setOnce")},increment:function(a){b(c.INFO,"[userData] increment, Increasing user's custom property value under the key: ["+
91
- a+"] by one");a=z(a,f.maxKeyLength,"userData increment",b);ha(a,1,"$inc")},increment_by:function(a,d){b(c.INFO,"[userData] increment_by, Increasing user's custom property value under the key: ["+a+"] by: ["+d+"]");a=z(a,f.maxKeyLength,"userData increment_by",b);d=z(d,f.maxValueSize,"userData increment_by",b);ha(a,d,"$inc")},multiply:function(a,d){b(c.INFO,"[userData] multiply, Multiplying user's custom property value under the key: ["+a+"] by: ["+d+"]");a=z(a,f.maxKeyLength,"userData multiply",b);
92
- d=z(d,f.maxValueSize,"userData multiply",b);ha(a,d,"$mul")},max:function(a,d){b(c.INFO,"[userData] max, Saving user's maximum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData max",b);d=z(d,f.maxValueSize,"userData max",b);ha(a,d,"$max")},min:function(a,d){b(c.INFO,"[userData] min, Saving user's minimum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData min",b);d=z(d,f.maxValueSize,
93
- "userData min",b);ha(a,d,"$min")},push:function(a,d){b(c.INFO,"[userData] push, Pushing a value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push",b);d=z(d,f.maxValueSize,"userData push",b);ha(a,d,"$push")},push_unique:function(a,d){b(c.INFO,"[userData] push_unique, Pushing a unique value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push_unique",b);d=z(d,f.maxValueSize,"userData push_unique",b);
94
- ha(a,d,"$addToSet")},pull:function(a,d){b(c.INFO,"[userData] pull, Removing the value: ["+d+"] under the key: ["+a+"] from user's custom property array");ha(a,d,"$pull")},save:function(){b(c.INFO,"[userData] save, Saving changes to user's custom property");f.check_consent("users")&&(wa(),Q(),b(c.INFO,"user_details, flushed the event queue"),P({user_details:JSON.stringify({custom:Z})}));Z={}}};this.report_trace=function(a){b(c.INFO,"report_trace, Reporting performance trace");if(this.check_consent("apm")){for(var d=
95
- "type name stz etz apm_metrics apm_attr".split(" "),e=0;e<d.length;e++)if("apm_attr"!==d[e]&&"undefined"===typeof a[d[e]]){b(c.WARNING,"report_trace, APM trace don't have the property: "+d[e]);return}a.name=z(a.name,f.maxKeyLength,"report_trace",b);a.app_metrics=ba(a.app_metrics,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"report_trace",b);d=za(a,d);d.timestamp=a.stz;a=new Date;d.hour=a.getHours();d.dow=a.getDay();P({apm:JSON.stringify(d)});b(c.INFO,"report_trace, Successfully adding APM trace: ",
96
- d)}};this.track_errors=function(a){x?(b(c.INFO,"track_errors, Started tracking errors"),p.i[this.app_key].tracking_crashes=!0,window.cly_crashes||(window.cly_crashes=!0,ub=a,window.onerror=function r(e,h,m,g,n){if(void 0!==n&&null!==n)ib(n,!1);else{g=g||window.event&&window.event.errorCharacter;n="";"undefined"!==typeof e&&(n+=e+"\n");"undefined"!==typeof h&&(n+="at "+h);"undefined"!==typeof m&&(n+=":"+m);"undefined"!==typeof g&&(n+=":"+g);n+="\n";try{e=[];for(var v=r.caller;v;)e.push(v.name),v=v.caller;
97
- n+=e.join("\n")}catch(G){b(c.ERROR,"track_errors, Call stack generation experienced a problem: "+G)}ib(n,!1)}},window.addEventListener("unhandledrejection",function(e){ib(Error("Unhandled rejection (reason: "+(e.reason&&e.reason.stack?e.reason.stack:e.reason)+")."),!0)}))):b(c.WARNING,"track_errors, window object is not available. Not tracking errors.")};this.log_error=function(a,d){b(c.INFO,"log_error, Logging errors");this.recordError(a,!0,d)};this.add_log=function(a){b(c.INFO,"add_log, Adding a new log of breadcrumbs: [ "+
98
- a+" ]");if(this.check_consent("crashes")){for(a=z(a,f.maxValueSize,"add_log",b);sa.length>=f.maxBreadcrumbCount;)sa.shift(),b(c.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one.");sa.push(a)}};this.fetch_remote_config=function(a,d,e){var h=null,m=null,g=null;a&&(e||"function"!==typeof a?Array.isArray(a)&&(h=a):g=a);d&&(e||"function"!==typeof d?Array.isArray(d)&&(m=d):g=d);g||"function"!==typeof e||(g=e);this.useExplicitRcApi?(b(c.INFO,"fetch_remote_config, Fetching remote config"),
99
- C(h,m,this.rcAutoOptinAb?1:0,null,g)):(b(c.WARNING,"fetch_remote_config, Fetching remote config, with legacy API"),C(h,m,null,"legacy",g))};this.enrollUserToAb=function(a){b(c.INFO,"enrollUserToAb, Providing AB test keys to opt in for");a&&Array.isArray(a)&&0!==a.length?(a={method:"ab",keys:JSON.stringify(a),av:f.app_version},Ea(a),ca("enrollUserToAb",this.url+Ua,a,function(d,e,h){if(!d)try{var m=JSON.parse(h);b(c.DEBUG,"enrollUserToAb, Parsed the response's result: ["+m.result+"]")}catch(g){b(c.ERROR,
100
- "enrollUserToAb, Had an issue while parsing the response: "+g)}},!0)):b(c.ERROR,"enrollUserToAb, No keys provided")};this.get_remote_config=function(a){b(c.INFO,"get_remote_config, Getting remote config from storage");return"undefined"!==typeof a?S[a]:S};this.stop_time=function(){b(c.INFO,"stop_time, Stopping tracking duration");pa&&(pa=!1,vb=F()-ka,Ha=F()-Ga)};this.start_time=function(){b(c.INFO,"start_time, Starting tracking duration");pa||(pa=!0,ka=F()-vb,Ga=F()-Ha,Ha=0,Ba())};this.track_sessions=
101
- function(){function a(){document[e]||!document.hasFocus()?f.stop_time():f.start_time()}function d(){Oa>=Na&&f.start_time();Oa=0}if(x){b(c.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();A(window,"beforeunload",function(){wa();Q();f.end_session()});var e="hidden";A(window,"focus",a);A(window,"blur",a);A(window,"pageshow",a);A(window,"pagehide",a);"onfocusin"in document&&(A(window,"focusin",a),A(window,"focusout",a));e in document?document.addEventListener("visibilitychange",
102
- 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));A(window,"mousemove",d);A(window,"click",d);A(window,"keydown",d);A(window,"scroll",d);setInterval(function(){Oa++;Oa>=Na&&f.stop_time()},6E4)}else b(c.WARNING,"track_sessions, window object is not available. Not tracking sessions.")};
103
- this.track_pageview=function(a,d,e){if(x||a)if(b(c.INFO,"track_pageview, Tracking page views"),b(c.VERBOSE,"track_pageview, last view is:["+Y+"], current view ID is:["+ia+"], previous view ID is:["+Da+"]"),Y&&wb&&(b(c.DEBUG,"track_pageview, Scroll registry triggered"),tb(),Ma=!0,La=0),na(),Da=ia,ia=fb(),(a=z(a,f.maxKeyLength,"track_pageview",b))&&Array.isArray(a)&&(d=a,a=null),a||(a=this.getViewName()),void 0===a||""===a)b(c.ERROR,"track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked.");
104
- else if(null===a)b(c.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(d&&d.length)for(var h=0;h<d.length;h++)try{if((new RegExp(d[h])).test(a)){b(c.INFO,"track_pageview, Ignoring the page: "+a);return}}catch(r){b(c.ERROR,"track_pageview, Problem with finding ignore list item: "+d[h]+", error: "+r)}Y=a;Ga=F();b(c.VERBOSE,"track_pageview, last view is assigned:["+Y+"], current view ID is:["+ia+"], previous view ID is:["+Da+"]");h={name:a,visit:1,view:f.getViewUrl()};
105
- h=ba(h,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);this.track_domains&&(h.domain=window.location.hostname);if(ja)if(X)ya&&(ya=!1,h.start=1);else{var m=y("cly_session");if(!m||parseInt(m)<=F())ya=!1,h.start=1}else x&&"undefined"!==typeof document.referrer&&document.referrer.length&&(m=Lb.exec(document.referrer))&&m[11]&&m[11]!==window.location.hostname&&(h.start=1);if(la&&Object.keys(la).length){b(c.INFO,"track_pageview, Adding fresh utm tags to segmentation:["+JSON.stringify(la)+
106
- "]");for(var g in la)"undefined"===typeof h["utm_"+g]&&(h["utm_"+g]=la[g])}x&&qb()&&(b(c.INFO,"track_pageview, Adding referrer to segmentation:["+document.referrer+"]"),h.referrer=document.referrer);if(e){e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);for(var n in e)"undefined"===typeof h[n]&&(h[n]=e[n])}this.check_consent("views")?t({key:M.VIEW,segmentation:h},ia):fa.track_pageview=arguments}else b(c.WARNING,"track_pageview, window object is not available. Not tracking page views is page is not provided.")};
107
- this.track_view=function(a,d,e){b(c.INFO,"track_view, Initiating tracking page views");this.track_pageview(a,d,e)};this.track_clicks=function(a){if(x){b(c.INFO,"track_clicks, Starting to track clicks");a&&b(c.INFO,"track_clicks, Tracking the specified children:["+a+"]");a=a||document;var d=!0;A(a,"click",function(e){if(d){d=!1;lb(e);if("undefined"!==typeof e.pageX&&"undefined"!==typeof e.pageY){var h=Ra(),m=mb();f.check_consent("clicks")&&(e={type:"click",x:e.pageX,y:e.pageY,width:m,height:h,view:f.getViewUrl()},
108
- e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processClick",b),f.track_domains&&(e.domain=window.location.hostname),t({key:M.ACTION,segmentation:e}))}setTimeout(function(){d=!0},1E3)}})}else b(c.WARNING,"track_clicks, window object is not available. Not tracking clicks.")};this.track_scrolls=function(a){x?(b(c.INFO,"track_scrolls, Starting to track scrolls"),a&&b(c.INFO,"track_scrolls, Tracking the specified children"),a=a||window,wb=Ma=!0,A(a,"scroll",Pb),A(a,"beforeunload",tb)):
109
- b(c.WARNING,"track_scrolls, window object is not available. Not tracking scrolls.")};this.track_links=function(a){x?(b(c.INFO,"track_links, Starting to track clicks to links"),a&&b(c.INFO,"track_links, Tracking the specified children"),a=a||document,A(a,"click",function(d){a:{var e=Qa(d);var h;for(h="A";e;){if(e.nodeName.toUpperCase()===h)break a;e=e.parentElement}e=void 0}e&&(lb(d),f.check_consent("clicks")&&t({key:"linkClick",segmentation:{href:e.href,text:e.innerText,id:e.id,view:f.getViewUrl()}}))})):
110
- b(c.WARNING,"track_links, window object is not available. Not tracking links.")};this.track_forms=function(a,d){function e(h){return h.name||h.id||h.type||h.nodeName}x?(b(c.INFO,"track_forms, Starting to track form submissions. DOM object provided:["+!!a+"] Tracking hidden inputs :["+!!d+"]"),a=a||document,A(a,"submit",function(h){h=Qa(h);var m={id:h.attributes.id&&h.attributes.id.nodeValue,name:h.attributes.name&&h.attributes.name.nodeValue,action:h.attributes.action&&h.attributes.action.nodeValue,
111
- method:h.attributes.method&&h.attributes.method.nodeValue,view:f.getViewUrl()},g;if("undefined"!==typeof h.elements){for(var n=0;n<h.elements.length;n++)(g=h.elements[n])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore")&&("undefined"===typeof m["input:"+e(g)]&&(m["input:"+e(g)]=[]),"select"===g.nodeName.toLowerCase()?"undefined"!==typeof g.multiple?m["input:"+e(g)].push(Ab(g)):m["input:"+e(g)].push(g.options[g.selectedIndex].value):"input"===g.nodeName.toLowerCase()?"undefined"!==
112
- typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&m["input:"+e(g)].push(g.value):("hidden"!==g.type.toLowerCase()||d)&&m["input:"+e(g)].push(g.value):m["input:"+e(g)].push(g.value):"textarea"===g.nodeName.toLowerCase()?m["input:"+e(g)].push(g.value):"undefined"!==typeof g.value&&m["input:"+e(g)].push(g.value));for(var r in m)m[r]&&"function"===typeof m[r].join&&(m[r]=m[r].join(", "))}f.check_consent("forms")&&t({key:"formSubmit",segmentation:m})})):b(c.WARNING,
113
- "track_forms, window object is not available. Not tracking forms.")};this.collect_from_forms=function(a,d){x?(b(c.INFO,"collect_from_forms, Starting to collect possible user data. DOM object provided:["+!!a+"] Submitting custom user property:["+!!d+"]"),a=a||document,A(a,"submit",function(e){e=Qa(e);var h={},m=!1,g;if("undefined"!==typeof e.elements){var n={},r=a.getElementsByTagName("LABEL"),v;for(v=0;v<r.length;v++)r[v].htmlFor&&""!==r[v].htmlFor&&(n[r[v].htmlFor]=r[v].innerText||r[v].textContent||
114
- r[v].innerHTML);for(v=0;v<e.elements.length;v++)if((g=e.elements[v])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore"))if(r="","select"===g.nodeName.toLowerCase()?r="undefined"!==typeof g.multiple?Ab(g):g.options[g.selectedIndex].value:"input"===g.nodeName.toLowerCase()?"undefined"!==typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&(r=g.value):r=g.value:r=g.value:"textarea"===g.nodeName.toLowerCase()?r=g.value:"undefined"!==typeof g.value&&
115
- (r=g.value),g.className&&-1!==g.className.indexOf("cly_user_")){var G=g.className.split(" ");for(g=0;g<G.length;g++)if(0===G[g].indexOf("cly_user_")){h[G[g].replace("cly_user_","")]=r;m=!0;break}}else if(g.type&&"email"===g.type.toLowerCase()||g.name&&-1!==g.name.toLowerCase().indexOf("email")||g.id&&-1!==g.id.toLowerCase().indexOf("email")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("email")||/[^@\s]+@[^@\s]+\.[^@\s]+/.test(r))h.email||(h.email=r),m=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("username")||
116
- g.id&&-1!==g.id.toLowerCase().indexOf("username")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("username"))h.username||(h.username=r),m=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("tel")||-1!==g.name.toLowerCase().indexOf("phone")||-1!==g.name.toLowerCase().indexOf("number"))||g.id&&(-1!==g.id.toLowerCase().indexOf("tel")||-1!==g.id.toLowerCase().indexOf("phone")||-1!==g.id.toLowerCase().indexOf("number"))||g.id&&n[g.id]&&(-1!==n[g.id].toLowerCase().indexOf("tel")||-1!==n[g.id].toLowerCase().indexOf("phone")||
117
- -1!==n[g.id].toLowerCase().indexOf("number")))h.phone||(h.phone=r),m=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("org")||-1!==g.name.toLowerCase().indexOf("company"))||g.id&&(-1!==g.id.toLowerCase().indexOf("org")||-1!==g.id.toLowerCase().indexOf("company"))||g.id&&n[g.id]&&(-1!==n[g.id].toLowerCase().indexOf("org")||-1!==n[g.id].toLowerCase().indexOf("company")))h.organization||(h.organization=r),m=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("name")||g.id&&-1!==g.id.toLowerCase().indexOf("name")||
118
- g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("name"))h.name||(h.name=""),h.name+=r+" ",m=!0}m&&(b(c.INFO,"collect_from_forms, Gathered user data",h),d?f.user_details({custom:h}):f.user_details(h))})):b(c.WARNING,"collect_from_forms, window object is not available. Not collecting from forms.")};this.collect_from_facebook=function(a){x?"undefined"!==typeof FB&&FB&&FB.api?(b(c.INFO,"collect_from_facebook, Starting to collect possible user data"),FB.api("/me",function(d){var e={};d.name&&(e.name=
119
- d.name);d.email&&(e.email=d.email);"male"===d.gender?e.gender="M":"female"===d.gender&&(e.gender="F");if(d.birthday){var h=d.birthday.split("/").pop();h&&4===h.length&&(e.byear=h)}d.work&&d.work[0]&&d.work[0].employer&&d.work[0].employer.name&&(e.organization=d.work[0].employer.name);if(a){e.custom={};for(var m in a){h=a[m].split(".");for(var g=d,n=0;n<h.length&&(g=g[h[n]],"undefined"!==typeof g);n++);"undefined"!==typeof g&&(e.custom[m]=g)}}f.user_details(e)})):b(c.ERROR,"collect_from_facebook, Facebook SDK is not available"):
120
- b(c.WARNING,"collect_from_facebook, window object is not available. Not collecting from Facebook.")};this.opt_out=function(){b(c.INFO,"opt_out, Opting out the user");this.ignore_visitor=!0;w("cly_ignore",!0)};this.opt_in=function(){b(c.INFO,"opt_in, Opting in the user");w("cly_ignore",!1);this.ignore_visitor=!1;O();this.ignore_visitor||Xa||Wa()};this.report_feedback=function(a){b(c.WARNING,"report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' or 'reportFeedbackWidgetManually' in place of this call. Call will be redirected to 'recordRatingWidgetWithID' now!");
121
- this.recordRatingWidgetWithID(a)};this.recordRatingWidgetWithID=function(a){b(c.INFO,"recordRatingWidgetWithID, Providing information about user with ID: [ "+a.widget_id+" ]");if(this.check_consent("star-rating"))if(a.widget_id)if(a.rating){var d={key:M.STAR_RATING,count:1,segmentation:{}};d.segmentation=za(a,"widget_id contactMe platform app_version rating email comment".split(" "));d.segmentation.app_version||(d.segmentation.app_version=this.metrics._app_version||this.app_version);5<d.segmentation.rating?
122
- (b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating higher than 5. Changing it back to 5 now."),d.segmentation.rating=5):1>d.segmentation.rating&&(b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating lower than 1. Changing it back to 1 now."),d.segmentation.rating=1);b(c.INFO,"recordRatingWidgetWithID, Reporting Rating Widget: ",d);t(d)}else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain rating property");else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain widget_id property")};
123
- this.reportFeedbackWidgetManually=function(a,d,e){if(this.check_consent("feedback"))if(a&&d)if(a._id)if(K)b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets can not be reported in offline mode");else{b(c.INFO,"reportFeedbackWidgetManually, Providing information about user with, provided result of the widget with ID: [ "+a._id+" ] and type: ["+a.type+"]");var h=[];d=a.type;if("nps"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=
124
- Math.round(e.rating);10<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 10. Changing it back to 10 now."),e.rating=10):0>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 0. Changing it back to 0 now."),e.rating=0);h=["rating","comment"]}var m=M.NPS}else if("survey"===d){if(e){if(1>Object.keys(e).length){b(c.ERROR,"reportFeedbackWidgetManually, Widget should have answers to be reported");return}h=Object.keys(e)}m=
125
- M.SURVEY}else if("rating"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=Math.round(e.rating);5<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 5. Changing it back to 5 now."),e.rating=5):1>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 1. Changing it back to 1 now."),e.rating=1);h=["rating","comment","email","contactMe"]}m=M.STAR_RATING}else{b(c.ERROR,
126
- "reportFeedbackWidgetManually, Widget has an unacceptable type");return}a={key:m,count:1,segmentation:{widget_id:a._id,platform:this.platform,app_version:this.metrics._app_version||this.app_version}};if(null===e)a.segmentation.closed=1;else{m=a.segmentation;if(h){for(var g,n=0,r=h.length;n<r;n++)g=h[n],"undefined"!==typeof e[g]&&(m[g]=e[g]);e=m}else e=void 0;a.segmentation=e}b(c.INFO,"reportFeedbackWidgetManually, Reporting "+d+": ",a);t(a)}else b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets must contain _id property");
127
- else b(c.ERROR,"reportFeedbackWidgetManually, Widget data and/or Widget object not provided. Aborting.")};this.show_feedback_popup=function(a){x?(b(c.WARNING,"show_feedback_popup, Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!"),this.presentRatingWidgetWithID(a)):b(c.WARNING,"show_feedback_popup, window object is not available. Not showing feedback popup.")};this.presentRatingWidgetWithID=function(a){x?(b(c.INFO,"presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ "+
128
- a+" ]"),this.check_consent("star-rating")&&(K?b(c.ERROR,"presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"):ca("presentRatingWidgetWithID,",this.url+"/o/feedback/widget",{widget_id:a,av:f.app_version},function(d,e,h){if(!d)try{var m=JSON.parse(h);W(m,!1)}catch(g){b(c.ERROR,"presentRatingWidgetWithID, JSON parse failed: "+g)}},!0))):b(c.WARNING,"presentRatingWidgetWithID, window object is not available. Not showing rating widget popup.")};this.initialize_feedback_popups=function(a){x?
129
- (b(c.WARNING,"initialize_feedback_popups, Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!"),this.initializeRatingWidgets(a)):b(c.WARNING,"initialize_feedback_popups, window object is not available. Not initializing feedback popups.")};this.initializeRatingWidgets=function(a){if(x){if(b(c.INFO,"initializeRatingWidgets, Initializing rating widget with provided widget IDs:[ "+a+"]"),this.check_consent("star-rating")){a||(a=y("cly_fb_widgets"));
130
- for(var d=document.getElementsByClassName("countly-feedback-sticker");0<d.length;)d[0].remove();ca("initializeRatingWidgets,",this.url+"/o/feedback/multiple-widgets-by-id",{widgets:JSON.stringify(a),av:f.app_version},function(e,h,m){if(!e)try{var g=JSON.parse(m);for(e=0;e<g.length;e++)if("true"===g[e].is_active){var n=g[e].target_devices,r=Db();if(n[r])if("string"===typeof g[e].hide_sticker&&(g[e].hide_sticker="true"===g[e].hide_sticker),"all"!==g[e].target_page||g[e].hide_sticker){var v=g[e].target_pages;
131
- for(h=0;h<v.length;h++){var G=v[h].substr(0,v[h].length-1)===window.location.pathname.substr(0,v[h].length-1),N=v[h]===window.location.pathname;(v[h].includes("*")&&G||N)&&!g[e].hide_sticker&&W(g[e],!0)}}else W(g[e],!0)}}catch(J){b(c.ERROR,"initializeRatingWidgets, JSON parse error: "+J)}},!0)}}else b(c.WARNING,"initializeRatingWidgets, window object is not available. Not initializing rating widgets.")};this.enable_feedback=function(a){x?(b(c.WARNING,"enable_feedback, Deprecated function call! Use 'enableRatingWidgets' in place of this call. Call will be redirected now!"),
132
- this.enableRatingWidgets(a)):b(c.WARNING,"enable_feedback, window object is not available. Not enabling feedback.")};this.enableRatingWidgets=function(a){x?(b(c.INFO,"enableRatingWidgets, Enabling rating widget with params:",a),this.check_consent("star-rating")&&(K?b(c.ERROR,"enableRatingWidgets, Cannot enable rating widgets in offline mode"):(w("cly_fb_widgets",a.popups||a.widgets),Sa(this.url+"/star-rating/stylesheets/countly-feedback-web.css"),a=a.popups||a.widgets,0<a.length?(document.body.insertAdjacentHTML("beforeend",
133
- '<div id="cfbg"></div>'),this.initializeRatingWidgets(a)):b(c.ERROR,"enableRatingWidgets, You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback")))):b(c.WARNING,"enableRatingWidgets, window object is not available. Not enabling rating widgets.")};this.get_available_feedback_widgets=function(a){b(c.INFO,"get_available_feedback_widgets, Getting the feedback list, callback function is provided:["+!!a+"]");this.check_consent("feedback")?
134
- K?b(c.ERROR,"get_available_feedback_widgets, Cannot enable feedback widgets in offline mode."):ca("get_available_feedback_widgets,",this.url+Ua,{method:"feedback",device_id:this.device_id,app_key:this.app_key,av:f.app_version},function(d,e,h){if(d)a&&a(null,d);else try{var m=JSON.parse(h).result||[];a&&a(m,null)}catch(g){b(c.ERROR,"get_available_feedback_widgets, Error while parsing feedback widgets list: "+g),a&&a(null,g)}},!1):a&&a(null,Error("Consent for feedback not provided."))};this.getFeedbackWidgetData=
135
- function(a,d){if(a.type)if(b(c.INFO,"getFeedbackWidgetData, Retrieving data for: ["+JSON.stringify(a)+"], callback function is provided:["+!!d+"]"),this.check_consent("feedback"))if(K)b(c.ERROR,"getFeedbackWidgetData, Cannot enable feedback widgets in offline mode.");else{var e=this.url,h={widget_id:a._id,shown:1,sdk_version:oa,sdk_name:va,platform:this.platform,app_version:this.app_version};if("nps"===a.type)e+="/o/surveys/nps/widget";else if("survey"===a.type)e+="/o/surveys/survey/widget";else if("rating"===
136
- a.type)e+="/o/surveys/rating/widget";else{b(c.ERROR,"getFeedbackWidgetData, Unknown type info: ["+a.type+"]");return}ca("getFeedbackWidgetData,",e,h,function(m,g,n){if(m)d&&d(null,m);else try{var r=JSON.parse(n);d&&d(r,null)}catch(v){b(c.ERROR,"getFeedbackWidgetData, Error while parsing feedback widgets list: "+v),d&&d(null,v)}},!0)}else d&&d(null,Error("Consent for feedback not provided."));else b(c.ERROR,"getFeedbackWidgetData, Expected the provided widget object to have a type but got: ["+JSON.stringify(a)+
137
- "], aborting.")};this.present_feedback_widget=function(a,d,e,h){function m(B){document.getElementById("countly-surveys-wrapper-"+B._id).style.display="block";document.getElementById("csbg").style.display="block"}function g(B){if(!B.appearance.hideS){b(c.DEBUG,"present_feedback_widget, handling the sticker as it was not set to hidden");var V=document.createElement("div");V.innerText=B.appearance.text;V.style.color=7>B.appearance.text_color.length?"#"+B.appearance.text_color:B.appearance.text_color;
138
- V.style.backgroundColor=7>B.appearance.bg_color.length?"#"+B.appearance.bg_color:B.appearance.bg_color;V.className="countly-feedback-sticker "+B.appearance.position+"-"+B.appearance.size;V.id="countly-feedback-sticker-"+B._id;document.body.appendChild(V);A(document.getElementById("countly-feedback-sticker-"+B._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+B._id).style.display="flex";document.getElementById("csbg").style.display="block"})}A(document.getElementById("countly-feedback-close-icon-"+
139
- B._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+B._id).style.display="none";document.getElementById("csbg").style.display="none"})}if(x){if(b(c.INFO,"present_feedback_widget, Presenting the feedback widget by appending to the element with ID: [ "+d+" ] and className: [ "+e+" ]"),this.check_consent("feedback"))if(!a||"object"!==L(a)||Array.isArray(a))b(c.ERROR,"present_feedback_widget, Please provide at least one feedback widget object.");else{b(c.INFO,"present_feedback_widget, Adding segmentation to feedback widgets:["+
140
- JSON.stringify(h)+"]");h&&"object"===L(h)&&0!==Object.keys(h).length||(b(c.DEBUG,"present_feedback_widget, Segmentation is not an object or empty"),h=null);try{var n=this.url;if("nps"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: nps."),n+="/feedback/nps";else if("survey"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: survey."),n+="/feedback/survey";else if("rating"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: rating."),n+="/feedback/rating";else{b(c.ERROR,"present_feedback_widget, Feedback widget only accepts nps, rating and survey types.");
141
- return}var r=window.origin||window.location.origin;if("rating"===a.type){b(c.DEBUG,"present_feedback_widget, Loading css for rating widget.");var v="ratings";Sa(this.url+"/star-rating/stylesheets/countly-feedback-web.css")}else b(c.DEBUG,"present_feedback_widget, Loading css for survey or nps."),Sa(this.url+"/surveys/stylesheets/countly-surveys.css"),v="surveys";n+="?widget_id="+a._id;n+="&app_key="+this.app_key;n+="&device_id="+this.device_id;n+="&sdk_name="+va;n+="&platform="+this.platform;n+="&app_version="+
142
- this.app_version;n+="&sdk_version="+oa;var G={tc:1};h&&(G.sg=h);n+="&custom="+JSON.stringify(G);n+="&origin="+r;n+="&widget_v=web";var N=document.createElement("iframe");N.src=n;N.name="countly-"+v+"-iframe";N.id="countly-"+v+"-iframe";var J=!1;N.onload=function(){J&&(document.getElementById("countly-"+v+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none");J=!0;b(c.DEBUG,"present_feedback_widget, Loaded iframe.")};for(var Fa=document.getElementById("csbg");Fa;)Fa.remove(),
143
- Fa=document.getElementById("csbg"),b(c.DEBUG,"present_feedback_widget, Removing past overlay.");var aa=document.getElementsByClassName("countly-"+v+"-wrapper");for(h=0;h<aa.length;h++)aa[h].remove(),b(c.DEBUG,"present_feedback_widget, Removed a wrapper.");aa=document.createElement("div");aa.className="countly-"+v+"-wrapper";aa.id="countly-"+v+"-wrapper-"+a._id;"survey"===a.type&&(aa.className=aa.className+" "+a.appearance.position);var db=document.body;h=!1;d&&(document.getElementById(d)?(db=document.getElementById(d),
144
- h=!0):b(c.ERROR,"present_feedback_widget, Provided ID not found."));h||e&&(document.getElementsByClassName(e)[0]?db=document.getElementsByClassName(e)[0]:b(c.ERROR,"present_feedback_widget, Provided class not found."));db.insertAdjacentHTML("beforeend",'<div id="csbg"></div>');db.appendChild(aa);if("rating"===a.type){var yb=document.createElement("div");yb.className="countly-ratings-overlay";yb.id="countly-ratings-overlay-"+a._id;aa.appendChild(yb);b(c.DEBUG,"present_feedback_widget, appended the rating overlay to wrapper");
145
- A(document.getElementById("countly-ratings-overlay-"+a._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+a._id).style.display="none"})}aa.appendChild(N);b(c.DEBUG,"present_feedback_widget, Appended the iframe");A(window,"message",function(B){var V={};try{V=JSON.parse(B.data),b(c.DEBUG,"present_feedback_widget, Parsed response message "+V)}catch($b){b(c.ERROR,"present_feedback_widget, Error while parsing message body "+$b)}V.close?(document.getElementById("countly-"+v+"-wrapper-"+
146
- a._id).style.display="none",document.getElementById("csbg").style.display="none"):b(c.DEBUG,"present_feedback_widget, Closing signal not sent yet")});if("survey"===a.type){var R=!1;switch(a.showPolicy){case "afterPageLoad":"complete"===document.readyState?R||(R=!0,m(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||R||(R=!0,m(a))});break;case "afterConstantDelay":setTimeout(function(){R||(R=!0,m(a))},1E4);break;case "onAbandon":"complete"===document.readyState?A(document,
147
- "mouseleave",function(){R||(R=!0,m(a))}):A(document,"readystatechange",function(B){"complete"===B.target.readyState&&A(document,"mouseleave",function(){R||(R=!0,m(a))})});break;case "onScrollHalfwayDown":A(window,"scroll",function(){if(!R){var B=Math.max(window.scrollY,document.body.scrollTop,document.documentElement.scrollTop),V=Ra();B>=V/2&&(R=!0,m(a))}});break;default:R||(R=!0,m(a))}}else if("nps"===a.type)document.getElementById("countly-"+v+"-wrapper-"+a._id).style.display="block",document.getElementById("csbg").style.display=
148
- "block";else if("rating"===a.type){var eb=!1;"complete"===document.readyState?eb||(eb=!0,g(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||eb||(eb=!0,g(a))})}}catch(B){b(c.ERROR,"present_feedback_widget, Something went wrong while presenting the widget: "+B)}}}else b(c.WARNING,"present_feedback_widget, window object is not available. Not presenting feedback widget.")};this.recordError=function(a,d,e){b(c.INFO,"recordError, Recording error");if(this.check_consent("crashes")&&
149
- a){e=e||ub;var h="";"object"===L(a)?"undefined"!==typeof a.stack?h=a.stack:("undefined"!==typeof a.name&&(h+=a.name+":"),"undefined"!==typeof a.message&&(h+=a.message+"\n"),"undefined"!==typeof a.fileName&&(h+="in "+a.fileName+"\n"),"undefined"!==typeof a.lineNumber&&(h+="on "+a.lineNumber),"undefined"!==typeof a.columnNumber&&(h+=":"+a.columnNumber)):h=a+"";if(h.length>f.maxStackTraceLineLength*f.maxStackTraceLinesPerThread){b(c.DEBUG,"record_error, Error stack is too long will be truncated");a=
150
- h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var m=a.length;h<m;h++)a[h].length>f.maxStackTraceLineLength&&(a[h]=a[h].substring(0,f.maxStackTraceLineLength));h=a.join("\n")}d=!!d;a=Ta();h={_resolution:a._resolution,_error:h,_app_version:a._app_version,_run:F()-Sb,_not_os_specific:!0,_javascript:!0};if(m=navigator.battery||navigator.webkitBattery||navigator.mozBattery||navigator.msBattery)h._bat=Math.floor(100*m.level);"undefined"!==typeof navigator.onLine&&
151
- (h._online=!!navigator.onLine);x&&(h._background=!document.hasFocus());0<sa.length&&(h._logs=sa.join("\n"));sa=[];h._nonfatal=d;h._view=this.getViewName();"undefined"!==typeof e&&(e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"record_error",b),h._custom=e);try{var g=document.createElement("canvas").getContext("experimental-webgl");h._opengl=g.getParameter(g.VERSION)}catch(n){b(c.ERROR,"Could not get the experimental-webgl context: "+n)}d={};d.crash=JSON.stringify(h);d.metrics=JSON.stringify({_ua:a._ua});
152
- P(d)}};this.onStorageChange=function(a,d){b(c.DEBUG,"onStorageChange, Applying storage changes for key:",a);b(c.DEBUG,"onStorageChange, Applying storage changes for value:",d);switch(a){case "cly_queue":H=f.deserialize(d||"[]");break;case "cly_event":I=f.deserialize(d||"[]");break;case "cly_remote_configs":S=f.deserialize(d||"{}");break;case "cly_ignore":f.ignore_visitor=f.deserialize(d);break;case "cly_id":f.device_id=d;break;case "cly_id_type":D=f.deserialize(d)}};this._internals={store:w,getDocWidth:mb,
153
- getDocHeight:Ra,getViewportHeight:Fb,get_page_coord:lb,get_event_target:Qa,add_event_listener:A,createNewObjectFromProperties:za,truncateObject:ba,truncateSingleValue:z,stripTrailingSlash:ta,prepareParams:jb,sendXmlHttpRequest:Nb,isResponseValid:sb,getInternalDeviceIdType:function(){return D},getMsTimestamp:hb,getTimestamp:F,isResponseValidBroad:rb,secureRandom:fb,log:b,checkIfLoggingIsOn:Ca,getMetrics:Ta,getUA:Mb,prepareRequest:Ea,generateUUID:gb,sendEventsForced:Q,isUUID:function(a){return/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-4[0-9a-fA-F]{3}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(a)},
154
- calculateChecksum:Cb,isReferrerUsable:qb,getId:pb,heartBeat:Wa,toRequestQueue:P,reportViewDuration:na,loadJS:Hb,loadCSS:Sa,getLastView:function(){return Y},setToken:Qb,getToken:function(){var a=y("cly_token");T("cly_token");return a},showLoader:Ib,hideLoader:Jb,setValueInStorage:w,getValueFromStorage:y,removeValueFromStorage:T,add_cly_events:t,processScrollView:tb,processScroll:Pb,currentUserAgentString:ua,currentUserAgentDataString:kb,userAgentDeviceDetection:Db,userAgentSearchBotDetection:Eb,getRequestQueue:function(){return H},
155
- getEventQueue:function(){return I},sendFetchRequest:Ob,processAsyncQueue:wa,makeNetworkRequest:ca,clearQueue:function(){H=[];w("cly_queue",[]);I=[];w("cly_event",[])},getLocalQueues:function(){return{eventQ:I,requestQ:H}}};var qa={sendInstantHCRequest:function(){var a=z(f.hcErrorMessage,1E3,"healthCheck",b);""!==a&&(a=JSON.stringify(a));a={hc:JSON.stringify({el:f.hcErrorCount,wl:f.hcWarningCount,sc:f.hcStatusCode,em:a}),metrics:JSON.stringify({_app_version:f.app_version})};Ea(a);ca("[healthCheck]",
156
- f.url+ob,a,function(d){d||qa.resetAndSaveCounters()},!0)},resetAndSaveCounters:function(){qa.resetCounters();w(U.errorCount,f.hcErrorCount);w(U.warningCount,f.hcWarningCount);w(U.statusCode,f.hcStatusCode);w(U.errorMessage,f.hcErrorMessage)},incrementErrorCount:function(){f.hcErrorCount++},incrementWarningCount:function(){f.hcWarningCount++},resetCounters:function(){f.hcErrorCount=0;f.hcWarningCount=0;f.hcStatusCode=-1;f.hcErrorMessage=""},saveRequestCounters:function(a,d){f.hcStatusCode=a;f.hcErrorMessage=
157
- d;w(U.statusCode,f.hcStatusCode);w(U.errorMessage,f.hcErrorMessage)}};this.initialize()}),Vb=!0;p.features="apm attribution clicks crashes events feedback forms location remote-config scrolls sessions star-rating users views".split(" ");p.q=p.q||[];p.onload=p.onload||[];p.CountlyClass=Ub;p.init=function(k){k=k||{};if(p.loadAPMScriptsAsync&&Vb)Vb=!1,Xb(k);else{var q=k.app_key||p.app_key;if(!p.i||!p.i[q]){k=new Ub(k);if(!p.i){p.i={};for(var t in k)p[t]=k[t]}p.i[q]=k}return p.i[q]}};p.serialize=function(k){"object"===
158
- L(k)&&(k=JSON.stringify(k));return k};p.deserialize=function(k){if(""===k)return k;try{k=JSON.parse(k)}catch(q){Ca()&&console.warn("[WARNING] [Countly] deserialize, Could not parse the file:["+k+"], error: "+q)}return k};p.getViewName=function(){return x?window.location.pathname:"web_worker"};p.getViewUrl=function(){return x?window.location.pathname:"web_worker"};p.getSearchQuery=function(){if(x)return window.location.search};p.DeviceIdType={DEVELOPER_SUPPLIED:0,SDK_GENERATED:1,TEMPORARY_ID:2};x&&
159
- window.addEventListener("storage",function(k){var q=(k.key+"").split("/"),t=q.pop();q=q.pop();if(p.i&&p.i[q])p.i[q].onStorageChange(t,k.newValue)});ma.default=p;Object.defineProperty(ma,"__esModule",{value:!0})});
1
+ (function(pa,ja){"object"===typeof exports&&"undefined"!==typeof module?ja(exports):"function"===typeof define&&define.amd?define(["exports"],ja):(pa="undefined"!==typeof globalThis?globalThis:pa||self,ja(pa.Countly=pa.Countly||{}))})(this,function(pa){function ja(m,k,r){if("function"==typeof m?m===k:m.has(k))return 3>arguments.length?k:r;throw new TypeError("Private element is not present on this object");}function Zb(m,k,r){if(k.has(m))throw new TypeError("Cannot initialize the same private elements twice on an object");
2
+ k.set(m,r)}function $b(m,k,r){return m.set(ja(m,k),r),r}function U(m){"@babel/helpers - typeof";return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(k){return typeof k}:function(k){return k&&"function"==typeof Symbol&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},U(m)}function Db(m){var k=[];if("undefined"!==typeof m.options)for(var r=0;r<m.options.length;r++)m.options[r].selected&&k.push(m.options[r].value);return k.join(", ")}function ib(){var m=Eb("xxxxxxxx",
3
+ "[x]");var k=Date.now().toString();return m+k}function jb(){return Eb("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx","[xy]")}function Eb(m,k){var r=(new Date).getTime();return m.replace(new RegExp(k,"g"),function(w){var D=(r+16*Math.random())%16|0;return("x"===w?D:D&3|8).toString(16)})}function G(){return Math.floor((new Date).getTime()/1E3)}function kb(){var m=(new Date).getTime();Ra>=m?Ra++:Ra=m;return Ra}function v(m,k,r){if(k&&Object.keys(k).length){if("undefined"!==typeof k[m])return k[m]}else if("undefined"!==
4
+ typeof q[m])return q[m];return r}function lb(m,k,r){for(var w in q.i)q.i[w].tracking_crashes&&q.i[w].recordError(m,k,r)}function mb(m,k){var r=[],w;for(w in m)r.push(w+"="+encodeURIComponent(m[w]));var D=r.join("&");return k?Fb(D,k).then(function(O){return D+="&checksum256="+O}):Promise.resolve(D)}function wa(m){return"string"===typeof m&&"/"===m.substring(m.length-1)?m.substring(0,m.length-1):m}function Ca(m,k){for(var r={},w,D=0,O=k.length;D<O;D++)w=k[D],"undefined"!==typeof m[w]&&(r[w]=m[w]);return r}
5
+ function ca(m,k,r,w,D,O){var R={};if(m){if(Object.keys(m).length>w){var X={},Da=0,qa;for(qa in m)Da<w&&(X[qa]=m[qa],Da++);m=X}for(var Ea in m)w=A(Ea,k,D,O),X=A(m[Ea],r,D,O),R[w]=X}return R}function A(m,k,r,w){var D=m;"number"===typeof m&&(m=m.toString());"string"===typeof m&&m.length>k&&(D=m.substring(0,k),w(c.DEBUG,r+", Key: [ "+m+" ] is longer than accepted length. It will be truncated."));return D}function Fb(m,k){m=(new TextEncoder).encode(m+k);return crypto.subtle.digest("SHA-256",m).then(function(r){return Array.from(new Uint8Array(r)).map(function(w){return w.toString(16).padStart(2,
6
+ "0")}).join("")})}function B(m,k,r){y&&(null===m||"undefined"===typeof m?Fa()&&console.warn("[WARNING] [Countly] add_event_listener, Can't bind ["+k+"] event to nonexisting element"):"undefined"!==typeof m.addEventListener?m.addEventListener(k,r,!1):m.attachEvent("on"+k,r))}function Sa(m){return m?"undefined"!==typeof m.target?m.target:m.srcElement:window.event.srcElement}function xa(m){if(m)return m;(m=navigator.userAgent)||(m=nb());return m}function nb(m){if(m)return m;m="";navigator.userAgentData&&
7
+ (m=navigator.userAgentData.brands.map(function(k){return k.brand+":"+k.version}).join(),m+=navigator.userAgentData.mobile?" mobi ":" ",m+=navigator.userAgentData.platform);return m}function Gb(m){if(!m){if(navigator.userAgentData&&navigator.userAgentData.mobile)return"phone";m=xa()}m=m.toLowerCase();var k="desktop",r=/(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(m)?
8
+ k="tablet":r.test(m)&&(k="phone");return k}function Hb(m){var k=/(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|Lighthouse)/;
9
+ if(m)return k.test(m);m=k.test(xa());k=k.test(nb());return m||k}function ob(m){"undefined"===typeof m.pageY&&"number"===typeof m.clientX&&document.documentElement&&(m.pageX=m.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,m.pageY=m.clientY+document.body.scrollTop+document.documentElement.scrollTop);return m}function Ta(){var m=document;return Math.max(Math.max(m.body.scrollHeight,m.documentElement.scrollHeight),Math.max(m.body.offsetHeight,m.documentElement.offsetHeight),Math.max(m.body.clientHeight,
10
+ m.documentElement.clientHeight))}function pb(){var m=document;return Math.max(Math.max(m.body.scrollWidth,m.documentElement.scrollWidth),Math.max(m.body.offsetWidth,m.documentElement.offsetWidth),Math.max(m.body.clientWidth,m.documentElement.clientWidth))}function Ib(){var m=document;return Math.min(Math.min(m.body.clientHeight,m.documentElement.clientHeight),Math.min(m.body.offsetHeight,m.documentElement.offsetHeight),window.innerHeight)}function Jb(m,k,r,w,D,O){m=document.createElement(m);var R;
11
+ m.setAttribute(k,r);m.setAttribute(w,D);k=function(){R||O();R=!0};O&&(m.onreadystatechange=k,m.onload=k);document.getElementsByTagName("head")[0].appendChild(m)}function Kb(m,k){Jb("script","type","text/javascript","src",m,k)}function Ua(m,k){Jb("link","rel","stylesheet","href",m,k)}function Lb(){if(y){var m=document.getElementById("cly-loader");if(!m){var k=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css";r.styleSheet?r.styleSheet.cssText=
12
+ "#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%;}}":r.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%;}}"));
13
+ k.appendChild(r);m=document.createElement("div");m.setAttribute("id","cly-loader");document.body.onload=function(){if(q.showLoaderProtection)Fa()&&console.warn("[WARNING] [Countly] showloader, Loader is already on");else try{document.body.appendChild(m)}catch(w){Fa()&&console.error("[ERROR] [Countly] showLoader, Body is not loaded for loader to append: "+w)}}}m.style.display="block"}}function Fa(){return q&&q.debug&&"undefined"!==typeof console?!0:!1}function Mb(){if(y){q.showLoaderProtection=!0;
14
+ var m=document.getElementById("cly-loader");m&&(m.style.display="none")}}function ac(m){var k=document.createElement("script"),r=document.createElement("script");k.async=!0;r.async=!0;k.src=q.customSourceBoomerang||Nb.BOOMERANG_SRC;r.src=q.customSourceCountlyBoomerang||Nb.CLY_BOOMERANG_SRC;document.getElementsByTagName("head")[0].appendChild(k);document.getElementsByTagName("head")[0].appendChild(r);var w=!1,D=!1;k.onload=function(){w=!0};r.onload=function(){D=!0};var O=0,R=setInterval(function(){O+=
15
+ 50;if(w&&D||1500<=O){if(q.debug){var X="BoomerangJS loaded:["+w+"], countly_boomerang loaded:["+D+"].";w&&D?console.log("[DEBUG] "+X):console.warn("[WARNING] "+X+" Initializing without APM.")}q.init(m);clearInterval(R)}},50)}var M={NPS:"[CLY]_nps",SURVEY:"[CLY]_survey",STAR_RATING:"[CLY]_star_rating",VIEW:"[CLY]_view",ORIENTATION:"[CLY]_orientation",ACTION:"[CLY]_action"},bc=Object.values(M),c={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "},Nb={BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/boomerang.min.js",
16
+ CLY_BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/countly_boomerang.js"},W=Object.freeze({errorCount:"cly_hc_error_count",warningCount:"cly_hc_warning_count",statusCode:"cly_hc_status_code",errorMessage:"cly_hc_error_message"}),Ob=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,y="undefined"!==typeof window,q=globalThis.Countly||{},
17
+ Ra=0,ka=new WeakMap,Xb=function(m,k,r){return Object.defineProperty(m,"prototype",{writable:!1}),m}(function r(k){function w(a,d){if(f.ignore_visitor)b(c.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);bc.includes(a.key)||(a.key=A(a.key,f.maxKeyLength,"add_cly_event",b));a.segmentation=ca(a.segmentation,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"add_cly_event",b);a=Ca(a,["key","count","sum","dur","segmentation"]);a.timestamp=kb();var e=new Date;
18
+ a.hour=e.getHours();a.dow=e.getDay();a.id=d||ib();a.key===M.VIEW?a.pvid=Va||"":a.cvid=ra||"";K.push(a);x("cly_event",K);b(c.INFO,"With event ID: ["+a.id+"], successfully adding the last event:",a)}else b(c.ERROR,"Adding event failed. Event must have a key property")}function D(a,d,e,h,n){b(c.INFO,"fetch_remote_config_explicit, Fetching sequence initiated");var g={method:"rc",av:f.app_version};a&&(g.keys=JSON.stringify(a));d&&(g.omit_keys=JSON.stringify(d));var p;"legacy"===h&&(g.method="fetch_remote_config");
19
+ 0===e&&(g.oi=0);1===e&&(g.oi=1);"function"===typeof n&&(p=n);f.check_consent("sessions")&&(g.metrics=JSON.stringify(Wa()));f.check_consent("remote-config")?(Ga(g),da("fetch_remote_config_explicit",f.url+Xa,g,function(u,t,H){if(!u){try{var N=JSON.parse(H);if(g.keys||g.omit_keys)for(var L in N)S[L]=N[L];else S=N;x("cly_remote_configs",S)}catch(Ha){b(c.ERROR,"fetch_remote_config_explicit, Had an issue while parsing the response: "+Ha)}p&&(b(c.INFO,"fetch_remote_config_explicit, Callback function is provided"),
20
+ p(u,S))}},!0)):(b(c.ERROR,"fetch_remote_config_explicit, Remote config requires explicit consent"),p&&p(Error("Remote config requires explicit consent"),S))}function O(){b(c.INFO,"checkIgnore, Checking if user or visit should be ignored");f.ignore_prefetch&&y&&"undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to prerendering"));f.ignore_bots&&Hb()&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to bot"))}
21
+ function R(){0<K.length&&(b(c.DEBUG,"Flushing events"),P({events:JSON.stringify(K)}),K=[],x("cly_event",K))}function X(a,d){if(y)if(document.getElementById("countly-feedback-sticker-"+a._id))b(c.ERROR,"Widget with same ID exists");else try{var e=document.createElement("div");e.className="countly-iframe-wrapper";e.id="countly-iframe-wrapper-"+a._id;var h=document.createElement("span");h.className="countly-feedback-close-icon";h.id="countly-feedback-close-icon-"+a._id;h.innerText="x";var n=document.createElement("iframe");
22
+ n.name="countly-feedback-iframe";n.id="countly-feedback-iframe";n.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+f.device_id+"&sdk_version="+sa;document.body.appendChild(e);e.appendChild(h);e.appendChild(n);B(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="none";document.getElementById("cfbg").style.display="none"});if(d){var g=document.createElementNS("http://www.w3.org/2000/svg",
23
+ "svg");g.id="feedback-sticker-svg";g.setAttribute("aria-hidden","true");g.setAttribute("data-prefix","far");g.setAttribute("data-icon","grin");g.setAttribute("class","svg-inline--fa fa-grin fa-w-16");g.setAttribute("role","img");g.setAttribute("xmlns","http://www.w3.org/2000/svg");g.setAttribute("viewBox","0 0 496 512");var p=document.createElementNS("http://www.w3.org/2000/svg","path");p.id="smileyPathInStickerSvg";p.setAttribute("fill","white");p.setAttribute("d","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm105.6-151.4c-25.9 8.3-64.4 13.1-105.6 13.1s-79.6-4.8-105.6-13.1c-9.9-3.1-19.4 5.4-17.7 15.3 7.9 47.1 71.3 80 123.3 80s115.3-32.9 123.3-80c1.6-9.8-7.7-18.4-17.7-15.3zM168 240c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z");
24
+ var u=document.createElement("span");u.innerText=a.trigger_button_text;var t=document.createElement("div");t.style.color=7>a.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;g.appendChild(p);t.appendChild(g);t.appendChild(u);document.body.appendChild(t);var H=document.getElementById("smileyPathInStickerSvg");
25
+ H&&(H.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);B(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(N){b(c.ERROR,"Somethings went wrong while element injecting process: "+
26
+ N)}else b(c.WARNING,"processWidget, window object is not available. Not processing widget.")}function Da(){var a;if("undefined"!==typeof f.onload&&0<f.onload.length){for(a=0;a<f.onload.length;a++)if("function"===typeof f.onload[a])f.onload[a](f);f.onload=[]}}function qa(){if(Z){var a={name:Z};f.check_consent("views")&&(w({key:M.VIEW,dur:ta?G()-Ia:Ja,segmentation:a},ra),Z=null)}}function Ea(){if(la){var a=z("cly_session");if(!a||parseInt(a)<=G())Y=!1,f.begin_session(!Ka);x("cly_session",G()+60*La)}}
27
+ function Ga(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name=ya;a.sdk_version=sa;a.t=E;a.av=f.app_version;var d=Pb();if(a.metrics){var e=JSON.parse(a.metrics);e._ua||(e._ua=d,a.metrics=JSON.stringify(e))}else a.metrics=JSON.stringify({_ua:d});f.check_consent("location")?(f.country_code&&(a.country_code=f.country_code),f.city&&(a.city=f.city),null!==f.ip_address&&(a.ip_address=f.ip_address)):a.location="";a.timestamp=kb();d=new Date;a.hour=d.getHours();a.dow=d.getDay()}function P(a){f.ignore_visitor?
28
+ b(c.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(Ga(a),I.length>Ya&&I.shift(),I.push(a),x("cly_queue",I,!0)):b(c.ERROR,"app_key or device_id is missing ",f.app_key,f.device_id)}function Za(){Da();if(f.ignore_visitor)$a=!1,b(c.WARNING,"User opt_out, no heartbeat");else{$a=!0;ab&&"undefined"!==typeof q.q&&0<q.q.length&&za();if(Y&&Ka&&ta){var a=G();a-ma>bb&&(f.session_duration(a-ma),ma=a,0<f.hcErrorCount&&x(W.errorCount,f.hcErrorCount),0<f.hcWarningCount&&x(W.warningCount,
29
+ f.hcWarningCount))}0<K.length&&!f.test_mode_eq&&(K.length<=Ma?(P({events:JSON.stringify(K)}),K=[]):(a=K.splice(0,Ma),P({events:JSON.stringify(a)})),x("cly_event",K));!J&&0<I.length&&cb&&G()>qb&&(cb=!1,a=I[0],a.rr=I.length,b(c.DEBUG,"Processing request",a),x("cly_queue",I,!0),f.test_mode||da("send_request_queue",f.url+rb,a,function(d,e){d?qb=G()+db:I.shift();x("cly_queue",I,!0);cb=!0},!1));setTimeout(Za,eb)}}function za(){if("undefined"===typeof q||"undefined"===typeof q.i)b(c.DEBUG,"Countly is not finished initialization yet, will process the queue after initialization is done");
30
+ else{var a=q.q;q.q=[];for(var d=0;d<a.length;d++){var e=a[d];b(c.DEBUG,"Processing queued calls:"+e);if("function"===typeof e)e();else if(Array.isArray(e)&&0<e.length){var h=f,n=0;try{q.i[e[n]]&&(h=q.i[e[n]],n++)}catch(p){b(c.DEBUG,"No instance found for the provided key while processing async queue");q.q.push(e);continue}if("function"===typeof h[e[n]])h[e[n]].apply(h,e.slice(n+1));else if(0===e[n].indexOf("userData.")){var g=e[n].replace("userData.","");"function"===typeof h.userData[g]&&h.userData[g].apply(h,
31
+ e.slice(n+1))}else"function"===typeof q[e[n]]&&q[e[n]].apply(q,e.slice(n+1))}}}}function sb(){var a=z("cly_id");return a?(E=z("cly_id_type"),a):jb()}function Pb(){return f.metrics._ua||xa()}function Wa(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=a._app_version||f.app_version;a._ua=a._ua||xa();if(y&&screen.width){var d=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==d&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&
32
+ window.devicePixelRatio)d=Math.round(d*window.devicePixelRatio),e=Math.round(e*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var h=d;d=e;e=h}a._resolution=a._resolution||""+d+"x"+e}}y&&window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);d=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof d&&(a._locale=a._locale||d);tb()&&(a._store=a._store||document.referrer);b(c.DEBUG,"Got metrics",a);return a}
33
+ function tb(a){if(!y)return!1;a=a||document.referrer;var d=!1;if("undefined"===typeof a||0===a.length)b(c.DEBUG,"Invalid referrer:["+a+"], ignoring.");else{var e=Ob.exec(a);if(e)if(e[11])if(e[11]===window.location.hostname)b(c.DEBUG,"Referrer is current host:["+a+"], ignoring.");else if(ea&&ea.length)for(d=!0,e=0;e<ea.length;e++){if(0<=a.indexOf(ea[e])){b(c.DEBUG,"Referrer in ignore list:["+a+"], ignoring.");d=!1;break}}else b(c.DEBUG,"Valid referrer:["+a+"]"),d=!0;else b(c.DEBUG,"No path found in referrer:["+
34
+ a+"], ignoring.");else b(c.DEBUG,"Referrer is corrupt:["+a+"], ignoring.")}return d}function b(a,d){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===U(arguments[2])&&(arguments[2]=JSON.stringify(arguments[2]));ab||(d="["+f.app_key+"] "+d);a||(a=c.DEBUG);for(var e="",h=2;h<arguments.length;h++)e+=arguments[h];e=a+"[Countly] "+d+e;a===c.ERROR?(console.error(e),na.incrementErrorCount()):a===c.WARNING?(console.warn(e),na.incrementWarningCount()):a===c.INFO?console.info(e):a===c.VERBOSE?
35
+ console.log(e):console.debug(e)}}function da(a,d,e,h,n){y?Qb(a,d,e,h,n):Rb(a,d,e,h,n)}function Qb(a,d,e,h,n){n=n||!1;try{b(c.DEBUG,"Sending XML HTTP request");var g=new XMLHttpRequest;e=e||{};mb(e,f.salt).then(function(p){var u="POST";if(f.force_post||2E3<=p.length)u="POST";"GET"===u?g.open("GET",d+"?"+p,!0):(g.open("POST",d,!0),g.setRequestHeader("Content-type","application/x-www-form-urlencoded"));for(var t in f.headers)g.setRequestHeader(t,f.headers[t]);g.onreadystatechange=function(){4===this.readyState&&
36
+ (b(c.DEBUG,a+" HTTP request completed with status code: ["+this.status+"] and response: ["+this.responseText+"]"),(n?ub(this.status,this.responseText):vb(this.status,this.responseText))?"function"===typeof h&&h(!1,e,this.responseText):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&na.saveRequestCounters(this.status,this.responseText),"function"===typeof h&&h(!0,e,this.status,this.responseText)))};"GET"===u?g.send():g.send(p)})}catch(p){b(c.ERROR,a+" Something went wrong while making an XML HTTP request: "+
37
+ p),"function"===typeof h&&h(!0,e)}}function Rb(a,d,e,h,n){n=n||!1;var g;try{b(c.DEBUG,"Sending Fetch request");var p="POST",u={"Content-type":"application/x-www-form-urlencoded"},t=null;e=e||{};mb(e,f.salt).then(function(H){f.force_post||2E3<=H.length?(p="POST",t=H):d+="?"+H;for(var N in f.headers)u[N]=f.headers[N];fetch(d,{method:p,headers:u,body:t}).then(function(L){g=L;return g.text()}).then(function(L){b(c.DEBUG,a+" Fetch request completed wit status code: ["+g.status+"] and response: ["+L+"]");
38
+ (n?ub(g.status,L):vb(g.status,L))?"function"===typeof h&&h(!1,e,L):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&na.saveRequestCounters(g.status,L),"function"===typeof h&&h(!0,e,g.status,L))})["catch"](function(L){b(c.ERROR,a+" Failed Fetch request: "+L);"function"===typeof h&&h(!0,e)})})}catch(H){b(c.ERROR,a+" Something went wrong with the Fetch request attempt: "+H),"function"===typeof h&&h(!0,e)}}function vb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+
39
+ a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"!==Object.prototype.toString.call(e)?(b(c.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function ub(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(b(c.ERROR,"Http response is not JSON Object nor JSON Array"),
40
+ !1)}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function Sb(){y?Na=Math.max(Na,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop):b(c.WARNING,"processScroll, window object is not available. Not processing scroll.")}function wb(){if(!y)b(c.WARNING,"processScrollView, window object is not available. Not processing scroll view.");else if(Oa){Oa=!1;var a=Ta(),d=pb(),e=Ib();f.check_consent("scrolls")&&(a={type:"scroll",y:Na+e,width:d,height:a,view:f.getViewUrl()},
41
+ a=ca(a,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processScrollView",b),f.track_domains&&(a.domain=window.location.hostname),w({key:M.ACTION,segmentation:a}))}}function Tb(a){x("cly_token",a)}function Ub(a,d,e){var h=new Date;h.setTime(h.getTime()+864E5*e);e="; expires="+h.toGMTString();document.cookie=a+"="+d+e+"; path=/"}function z(a,d,e){if("none"===f.storage||"object"!==U(f.storage)&&!y)b(c.DEBUG,"Storage is disabled. Value with key: ["+a+"] won't be retrieved");else{e||(a=f.app_key+
42
+ "/"+a,f.namespace&&(a=wa(f.namespace)+"/"+a));if("object"===U(f.storage)&&"function"===typeof f.storage.getItem){var h=f.storage.getItem(a);return a.endsWith("cly_id")?h:f.deserialize(h)}void 0===d&&(d=ua);if(d)h=localStorage.getItem(a);else if("localstorage"!==f.storage)a:{d=a+"=";e=document.cookie.split(";");h=0;for(var n=e.length;h<n;h++){for(var g=e[h];" "===g.charAt(0);)g=g.substring(1,g.length);if(0===g.indexOf(d)){h=g.substring(d.length,g.length);break a}}h=null}return a.endsWith("cly_id")?
43
+ h:f.deserialize(h)}}function x(a,d,e,h){"none"===f.storage||"object"!==U(f.storage)&&!y?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be stored"):(h||(a=f.app_key+"/"+a,f.namespace&&(a=wa(f.namespace)+"/"+a)),"undefined"!==typeof d&&null!==d&&("object"===U(f.storage)&&"function"===typeof f.storage.setItem?f.storage.setItem(a,d):(void 0===e&&(e=ua),d=f.serialize(d),e?localStorage.setItem(a,d):"localstorage"!==f.storage&&Ub(a,d,30))))}function V(a,d,e){"none"===f.storage||"object"!==U(f.storage)&&
44
+ !y?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be removed"):(e||(a=f.app_key+"/"+a,f.namespace&&(a=wa(f.namespace)+"/"+a)),"object"===U(f.storage)&&"function"===typeof f.storage.removeItem?f.storage.removeItem(a):(void 0===d&&(d=ua),d?localStorage.removeItem(a):"localstorage"!==f.storage&&Ub(a,"",-1)))}function cc(){if(z(f.namespace+"cly_id",!1,!0)){x("cly_id",z(f.namespace+"cly_id",!1,!0));x("cly_id_type",z(f.namespace+"cly_id_type",!1,!0));x("cly_event",z(f.namespace+"cly_event",
45
+ !1,!0));x("cly_session",z(f.namespace+"cly_session",!1,!0));var a=z(f.namespace+"cly_queue",!1,!0);Array.isArray(a)&&(a=a.filter(function(d){return d.app_key===f.app_key}),x("cly_queue",a));z(f.namespace+"cly_cmp_id",!1,!0)&&(x("cly_cmp_id",z(f.namespace+"cly_cmp_id",!1,!0)),x("cly_cmp_uid",z(f.namespace+"cly_cmp_uid",!1,!0)));z(f.namespace+"cly_ignore",!1,!0)&&x("cly_ignore",z(f.namespace+"cly_ignore",!1,!0));V("cly_id",!1,!0);V("cly_id_type",!1,!0);V("cly_event",!1,!0);V("cly_session",!1,!0);V("cly_queue",
46
+ !1,!0);V("cly_cmp_id",!1,!0);V("cly_cmp_uid",!1,!0);V("cly_ignore",!1,!0)}}var l=this;if(!(this instanceof r))throw new TypeError("Cannot call a class as a function");Zb(this,ka,void 0);var f=this,ab=!q.i,Y=!1,rb="/i",Xa="/o/sdk",eb=v("interval",k,500),Ya=v("queue_size",k,1E3),I=[],K=[],S={},va=[],fa={},ea=v("ignore_referrers",k,[]),xb=null,Ka=!0,ma,yb=0,Z=null,Ia=0,Ja=0,qb=0,db=v("fail_timeout",k,60),Pa=v("inactivity_time",k,20),Qa=0,bb=v("session_update",k,60),Ma=v("max_events",k,100),Aa=v("max_logs",
47
+ k,null),la=v("use_session_cookie",k,!0),La=v("session_cookie_timeout",k,30),cb=!0,$a=!1,J=v("offline_mode",k,!1),ha={},ta=!0,Vb=G(),ua=!0,Ba=null,E=1,Oa=!1,Na=0,zb=!1,ra=null,Va=null,oa=null,ya=v("sdk_name",k,"javascript_native_web"),sa=v("sdk_version",k,"24.11.0"),Ab=!1;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(a){b(c.ERROR,"Local storage test failed, Halting local storage support: "+a),ua=!1}for(var F={},Bb=0;Bb<q.features.length;Bb++)F[q.features[Bb]]=
48
+ {};this.initialize=function(){l.serialize=v("serialize",k,q.serialize);l.deserialize=v("deserialize",k,q.deserialize);l.getViewName=v("getViewName",k,q.getViewName);l.getViewUrl=v("getViewUrl",k,q.getViewUrl);l.getSearchQuery=v("getSearchQuery",k,q.getSearchQuery);l.DeviceIdType=q.DeviceIdType;l.namespace=v("namespace",k,"");l.clearStoredId=v("clear_stored_id",k,!1);l.app_key=v("app_key",k,null);l.onload=v("onload",k,[]);l.utm=v("utm",k,{source:!0,medium:!0,campaign:!0,term:!0,content:!0});l.ignore_prefetch=
49
+ v("ignore_prefetch",k,!0);l.rcAutoOptinAb=v("rc_automatic_optin_for_ab",k,!0);l.useExplicitRcApi=v("use_explicit_rc_api",k,!1);l.debug=v("debug",k,!1);l.test_mode=v("test_mode",k,!1);l.test_mode_eq=v("test_mode_eq",k,!1);l.metrics=v("metrics",k,{});l.headers=v("headers",k,{});l.url=wa(v("url",k,""));l.app_version=v("app_version",k,"0.0");l.country_code=v("country_code",k,null);l.city=v("city",k,null);l.ip_address=v("ip_address",k,null);l.ignore_bots=v("ignore_bots",k,!0);l.force_post=v("force_post",
50
+ k,!1);l.remote_config=v("remote_config",k,!1);l.ignore_visitor=v("ignore_visitor",k,!1);l.require_consent=v("require_consent",k,!1);l.track_domains=y?v("track_domains",k,!0):void 0;l.storage=v("storage",k,"default");l.enableOrientationTracking=y?v("enable_orientation_tracking",k,!0):void 0;l.maxKeyLength=v("max_key_length",k,128);l.maxValueSize=v("max_value_size",k,256);l.maxSegmentationValues=v("max_segmentation_values",k,100);l.maxBreadcrumbCount=v("max_breadcrumb_count",k,null);l.maxStackTraceLinesPerThread=
51
+ v("max_stack_trace_lines_per_thread",k,30);l.maxStackTraceLineLength=v("max_stack_trace_line_length",k,200);l.heatmapWhitelist=v("heatmap_whitelist",k,[]);l.salt=v("salt",k,null);l.hcErrorCount=z(W.errorCount)||0;l.hcWarningCount=z(W.warningCount)||0;l.hcStatusCode=z(W.statusCode)||-1;l.hcErrorMessage=z(W.errorMessage)||"";Aa&&!l.maxBreadcrumbCount?(l.maxBreadcrumbCount=Aa,b(c.WARNING,"initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!")):Aa||l.maxBreadcrumbCount||(l.maxBreadcrumbCount=
52
+ 100);"cookie"===l.storage&&(ua=!1);l.rcAutoOptinAb||l.useExplicitRcApi||(b(c.WARNING,"initialize, Auto opting is disabled, switching to explicit RC API"),l.useExplicitRcApi=!0);Array.isArray(ea)||(ea=[]);""===l.url&&(b(c.ERROR,"initialize, Please provide server URL"),l.ignore_visitor=!0);z("cly_ignore")&&(l.ignore_visitor=!0);cc();I=z("cly_queue")||[];K=z("cly_event")||[];S=z("cly_remote_configs")||{};var a="[CLY]_temp_id"===z("cly_id");l.clearStoredId&&(z("cly_id")&&!a&&(l.device_id=z("cly_id"),
53
+ b(c.DEBUG,"initialize, temporarily using the previous device ID to flush existing events"),E=z("cly_id_type"),E||(b(c.DEBUG,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"),E=0),R(),l.device_id=void 0,E=1),b(c.INFO,"initialize, Clearing the device ID storage"),V("cly_id"),V("cly_id_type"),V("cly_session"));O();if(y)if(window.name&&0===window.name.indexOf("cly:"))try{l.passed_data=JSON.parse(window.name.replace("cly:",""))}catch(t){b(c.ERROR,
54
+ "initialize, Could not parse name: "+window.name+", error: "+t)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{l.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(t){b(c.ERROR,"initialize, Could not parse hash: "+location.hash+", error: "+t)}if((l.passed_data&&l.passed_data.app_key&&l.passed_data.app_key===l.app_key||l.passed_data&&!l.passed_data.app_key&&ab)&&l.passed_data.token&&l.passed_data.purpose){l.passed_data.token!==z("cly_old_token")&&(Tb(l.passed_data.token),
55
+ x("cly_old_token",l.passed_data.token));var d=[];Array.isArray(l.heatmapWhitelist)?(l.heatmapWhitelist.push(l.url),d=l.heatmapWhitelist.map(function(t){return wa(t)})):d=[l.url];d.includes(l.passed_data.url)&&"heatmap"===l.passed_data.purpose&&(l.ignore_visitor=!0,Lb(),Kb(l.passed_data.url+"/views/heatmap.js",Mb))}if(l.ignore_visitor)b(c.WARNING,"initialize, ignore_visitor:["+l.ignore_visitor+"], this user will not be tracked");else{"javascript_native_web"===ya&&"24.11.0"===sa?b(c.DEBUG,"initialize, SDK name:["+
56
+ ya+"], version:["+sa+"]"):b(c.DEBUG,"initialize, SDK name:["+ya+"], version:["+sa+"], default name:[javascript_native_web] and default version:[24.11.0]");b(c.DEBUG,"initialize, app_key:["+l.app_key+"], url:["+l.url+"]");b(c.DEBUG,"initialize, device_id:["+v("device_id",k,void 0)+"]");b(c.DEBUG,"initialize, require_consent is enabled:["+l.require_consent+"]");try{b(c.DEBUG,"initialize, metric override:["+JSON.stringify(l.metrics)+"]"),b(c.DEBUG,"initialize, header override:["+JSON.stringify(l.headers)+
57
+ "]"),b(c.DEBUG,"initialize, number of onload callbacks provided:["+l.onload.length+"]"),b(c.DEBUG,"initialize, utm tags:["+JSON.stringify(l.utm)+"]"),ea&&b(c.DEBUG,"initialize, referrers to ignore :["+JSON.stringify(ea)+"]"),b(c.DEBUG,"initialize, salt given:["+!!l.salt+"]")}catch(t){b(c.ERROR,"initialize, Could not stringify some config object values")}b(c.DEBUG,"initialize, app_version:["+l.app_version+"]");b(c.DEBUG,"initialize, provided location info; country_code:["+l.country_code+"], city:["+
58
+ l.city+"], ip_address:["+l.ip_address+"]");""!==l.namespace&&b(c.DEBUG,"initialize, namespace given:["+l.namespace+"]");l.clearStoredId&&b(c.DEBUG,"initialize, clearStoredId flag set to:["+l.clearStoredId+"]");l.ignore_prefetch&&b(c.DEBUG,"initialize, ignoring pre-fetching and pre-rendering from counting as real website visits :["+l.ignore_prefetch+"]");l.test_mode&&b(c.WARNING,"initialize, test_mode:["+l.test_mode+"], request queue won't be processed");l.test_mode_eq&&b(c.WARNING,"initialize, test_mode_eq:["+
59
+ l.test_mode_eq+"], event queue won't be processed");l.heatmapWhitelist&&b(c.DEBUG,"initialize, heatmap whitelist:["+JSON.stringify(l.heatmapWhitelist)+"], these domains will be whitelisted");"default"!==l.storage&&b(c.DEBUG,"initialize, storage is set to:["+l.storage+"]");l.ignore_bots&&b(c.DEBUG,"initialize, ignore traffic from bots :["+l.ignore_bots+"]");l.force_post&&b(c.DEBUG,"initialize, forced post method for all requests:["+l.force_post+"]");l.remote_config&&b(c.DEBUG,"initialize, remote_config callback provided:["+
60
+ !!l.remote_config+"]");"boolean"===typeof l.rcAutoOptinAb&&b(c.DEBUG,"initialize, automatic RC optin is enabled:["+l.rcAutoOptinAb+"]");l.useExplicitRcApi||b(c.WARNING,"initialize, will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag");l.track_domains&&b(c.DEBUG,"initialize, tracking domain info:["+l.track_domains+"]");l.enableOrientationTracking&&b(c.DEBUG,"initialize, enableOrientationTracking:["+l.enableOrientationTracking+"]");la||b(c.WARNING,"initialize, use_session_cookie is enabled:["+
61
+ la+"]");J&&b(c.DEBUG,"initialize, offline_mode:["+J+"], user info won't be send to the servers");S&&b(c.DEBUG,"initialize, stored remote configs:["+JSON.stringify(S)+"]");b(c.DEBUG,"initialize, 'getViewName' callback override provided:["+(l.getViewName!==q.getViewName)+"]");b(c.DEBUG,"initialize, 'getSearchQuery' callback override provided:["+(l.getSearchQuery!==q.getSearchQuery)+"]");128!==l.maxKeyLength&&b(c.DEBUG,"initialize, maxKeyLength set to:["+l.maxKeyLength+"] characters");256!==l.maxValueSize&&
62
+ b(c.DEBUG,"initialize, maxValueSize set to:["+l.maxValueSize+"] characters");100!==l.maxSegmentationValues&&b(c.DEBUG,"initialize, maxSegmentationValues set to:["+l.maxSegmentationValues+"] key/value pairs");100!==l.maxBreadcrumbCount&&b(c.DEBUG,"initialize, maxBreadcrumbCount for custom logs set to:["+l.maxBreadcrumbCount+"] entries");30!==l.maxStackTraceLinesPerThread&&b(c.DEBUG,"initialize, maxStackTraceLinesPerThread set to:["+l.maxStackTraceLinesPerThread+"] lines");200!==l.maxStackTraceLineLength&&
63
+ b(c.DEBUG,"initialize, maxStackTraceLineLength set to:["+l.maxStackTraceLineLength+"] characters");500!==eb&&b(c.DEBUG,"initialize, interval for heartbeats set to:["+eb+"] milliseconds");1E3!==Ya&&b(c.DEBUG,"initialize, queue_size set to:["+Ya+"] items max");60!==db&&b(c.DEBUG,"initialize, fail_timeout set to:["+db+"] seconds of wait time after a failed connection to server");20!==Pa&&b(c.DEBUG,"initialize, inactivity_time set to:["+Pa+"] minutes to consider a user as inactive after no observable action");
64
+ 60!==bb&&b(c.DEBUG,"initialize, session_update set to:["+bb+"] seconds to check if extending a session is needed while the user is active");100!==Ma&&b(c.DEBUG,"initialize, max_events set to:["+Ma+"] events to send in one batch");Aa&&b(c.WARNING,"initialize, max_logs set to:["+Aa+"] breadcrumbs to store for crash logs max, deprecated ");30!==La&&b(c.DEBUG,"initialize, session_cookie_timeout set to:["+La+"] minutes to expire a cookies session");d=null;var e=l.getSearchQuery(),h=!1,n={};if(e){0===e.indexOf("?")&&
65
+ (e=e.substring(1));e=e.split("&");for(var g=0;g<e.length;g++){var p=e[g].split("=");"cly_id"===p[0]?x("cly_cmp_id",p[1]):"cly_uid"===p[0]?x("cly_cmp_uid",p[1]):"cly_device_id"===p[0]?d=p[1]:0===(p[0]+"").indexOf("utm_")&&l.utm[p[0].replace("utm_","")]&&(n[p[0].replace("utm_","")]=p[1],h=!0)}}e=v("device_id",k,void 0);"number"===typeof e&&(e=e.toString());z("cly_id")&&!a?(l.device_id=z("cly_id"),b(c.INFO,"initialize, Set the stored device ID"),E=z("cly_id_type"),E||(b(c.INFO,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"),
66
+ E=0),J=!1):null!==d?(b(c.INFO,"initialize, Device ID set by URL"),l.device_id=d,E=3,J=!1):e?(b(c.INFO,"initialize, Device ID set by developer"),l.device_id=e,k&&Object.keys(k).length?void 0!==k.device_id&&(E=0):void 0!==q.device_id&&(E=0),J=!1):J||a?(l.device_id="[CLY]_temp_id",E=2,J&&a?b(c.INFO,"initialize, Temp ID set, continuing offline mode from previous app session"):J&&!a?b(c.INFO,"initialize, Temp ID set, entering offline mode"):(J=!0,b(c.INFO,"initialize, Temp ID set, enabling offline mode"))):
67
+ (b(c.INFO,"initialize, Generating the device ID"),l.device_id=v("device_id",k,sb()),k&&Object.keys(k).length?void 0!==k.device_id&&(E=0):void 0!==q.device_id&&(E=0));x("cly_id",l.device_id);x("cly_id_type",E);if(h){oa={};for(var u in l.utm)n[u]?(l.userData.set("utm_"+u,n[u]),oa[u]=n[u]):l.userData.unset("utm_"+u);l.userData.save()}Da();setTimeout(function(){q.noHeartBeat?b(c.WARNING,"initialize, Heartbeat disabled. This is for testing purposes only!"):Za();l.remote_config&&l.fetch_remote_config(l.remote_config)},
68
+ 1);y&&document.documentElement.setAttribute("data-countly-useragent",xa());na.sendInstantHCRequest();b(c.INFO,"initialize, Countly initialized")}};this.halt=function(){b(c.WARNING,"halt, Resetting Countly");q.i=void 0;q.q=[];q.noHeartBeat=void 0;ab=!q.i;Y=!1;rb="/i";Xa="/o/sdk";eb=500;Ya=1E3;I=[];K=[];S={};va=[];fa={};ea=[];xb=null;Ka=!0;yb=0;Z=null;qb=Ja=Ia=0;db=60;Pa=20;Qa=0;bb=60;Ma=100;Aa=null;la=!0;La=30;cb=!0;J=$a=!1;ha={};ta=!0;Vb=G();ua=!0;Ba=null;E=1;Oa=!1;Na=0;zb=!1;oa=Va=ra=null;try{localStorage.setItem("cly_testLocal",
69
+ !0),localStorage.removeItem("cly_testLocal")}catch(d){b(c.ERROR,"halt, Local storage test failed, will fallback to cookies"),ua=!1}q.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");F={};for(var a=0;a<q.features.length;a++)F[q.features[a]]={};f.app_key=void 0;f.device_id=void 0;f.onload=void 0;f.utm=void 0;f.ignore_prefetch=void 0;f.debug=void 0;f.test_mode=void 0;f.test_mode_eq=void 0;f.metrics=void 0;f.headers=
70
+ void 0;f.url=void 0;f.app_version=void 0;f.country_code=void 0;f.city=void 0;f.ip_address=void 0;f.ignore_bots=void 0;f.force_post=void 0;f.rcAutoOptinAb=void 0;f.useExplicitRcApi=void 0;f.remote_config=void 0;f.ignore_visitor=void 0;f.require_consent=void 0;f.track_domains=void 0;f.storage=void 0;f.enableOrientationTracking=void 0;f.salt=void 0;f.maxKeyLength=void 0;f.maxValueSize=void 0;f.maxSegmentationValues=void 0;f.maxBreadcrumbCount=void 0;f.maxStackTraceLinesPerThread=void 0;f.maxStackTraceLineLength=
71
+ void 0};this.group_features=function(a){b(c.INFO,"group_features, Grouping features");if(a)for(var d in a)F[d]?b(c.WARNING,"group_features, Feature name ["+d+"] is already reserved"):"string"===typeof a[d]?F[d]={features:[a[d]]}:a[d]&&Array.isArray(a[d])&&a[d].length?F[d]={features:a[d]}:b(c.ERROR,"group_features, Incorrect feature list for ["+d+"] value: ["+a[d]+"]");else b(c.ERROR,"group_features, Incorrect features:["+a+"]")};this.check_consent=function(a){b(c.INFO,"check_consent, Checking if consent is given for specific feature:["+
72
+ a+"]");if(!this.require_consent)return b(c.INFO,"check_consent, require_consent is off, no consent is necessary"),!0;if(F[a])return!(!F[a]||!F[a].optin);b(c.ERROR,"check_consent, No feature available for ["+a+"]");return!1};this.get_device_id_type=function(){b(c.INFO,"check_device_id_type, Retrieving the current device id type.["+E+"]");switch(E){case 1:var a=f.DeviceIdType.SDK_GENERATED;break;case 3:case 0:a=f.DeviceIdType.DEVELOPER_SUPPLIED;break;case 2:a=f.DeviceIdType.TEMPORARY_ID;break;default:a=
73
+ -1}return a};this.get_device_id=function(){b(c.INFO,"get_device_id, Retrieving the device id: ["+f.device_id+"]");return f.device_id};this.check_any_consent=function(){b(c.INFO,"check_any_consent, Checking if any consent is given");if(!this.require_consent)return b(c.INFO,"check_any_consent, require_consent is off, no consent is necessary"),!0;for(var a in F)if(F[a]&&F[a].optin)return!0;b(c.INFO,"check_any_consent, No consents given");return!1};this.add_consent=function(a){b(c.INFO,"add_consent, Adding consent for ["+
74
+ a+"]");if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add_consent(a[d]);else F[a]?F[a].features?(F[a].optin=!0,this.add_consent(F[a].features)):!0!==F[a].optin&&(F[a].optin=!0,Wb(),setTimeout(function(){"sessions"===a&&ha.begin_session?(f.begin_session.apply(f,ha.begin_session),ha.begin_session=null):"views"===a&&ha.track_pageview&&(Z=null,f.track_pageview.apply(f,ha.track_pageview),ha.track_pageview=null)},1)):b(c.ERROR,"add_consent, No feature available for ["+a+"]")};this.remove_consent=function(a){b(c.INFO,
75
+ "remove_consent, Removing consent for ["+a+"]");this.remove_consent_internal(a,!0)};this.remove_consent_internal=function(a,d){d=d||!1;if(Array.isArray(a))for(var e=0;e<a.length;e++)this.remove_consent_internal(a[e],d);else F[a]?F[a].features?this.remove_consent_internal(F[a].features,d):(F[a].optin=!1,d&&!1!==F[a].optin&&Wb()):b(c.WARNING,"remove_consent, No feature available for ["+a+"]")};var fb,Wb=function(){fb&&(clearTimeout(fb),fb=null);fb=setTimeout(function(){for(var a={},d=0;d<q.features.length;d++)a[q.features[d]]=
76
+ !0===F[q.features[d]].optin?!0:!1;P({consent:JSON.stringify(a)});b(c.DEBUG,"Consent update request has been sent to the queue.")},1E3)};this.enable_offline_mode=function(){b(c.INFO,"enable_offline_mode, Enabling offline mode");this.remove_consent_internal(q.features,!1);J=!0;this.device_id="[CLY]_temp_id";f.device_id=this.device_id;E=2};this.disable_offline_mode=function(a){if(J){b(c.INFO,"disable_offline_mode, Disabling offline mode");J=!1;a&&this.device_id!==a?(this.device_id=a,f.device_id=this.device_id,
77
+ E=0,x("cly_id",this.device_id),x("cly_id_type",0),b(c.INFO,"disable_offline_mode, Changing id to: "+this.device_id)):(this.device_id=sb(),"[CLY]_temp_id"===this.device_id&&(this.device_id=jb()),f.device_id=this.device_id,this.device_id!==z("cly_id")&&(x("cly_id",this.device_id),x("cly_id_type",1)));a=!1;if(0<I.length)for(var d=0;d<I.length;d++)"[CLY]_temp_id"===I[d].device_id&&(I[d].device_id=this.device_id,a=!0);a&&x("cly_queue",I,!0);Ab&&(na.sendInstantHCRequest(),Ab=!1)}else b(c.WARNING,"disable_offline_mode, Countly was not in offline mode.")};
78
+ this.begin_session=function(a,d){b(c.INFO,"begin_session, Starting the session. There was an ongoing session: ["+Y+"]");a&&b(c.INFO,"begin_session, Heartbeats are disabled");d&&b(c.INFO,"begin_session, Session starts irrespective of session cookie");if(this.check_consent("sessions")){if(!Y){this.enableOrientationTracking&&(this.report_orientation(),B(window,"resize",function(){f.report_orientation()}));ma=G();Y=!0;Ka=!a;var e=z("cly_session");b(c.VERBOSE,"begin_session, Session state, forced: ["+
79
+ d+"], useSessionCookie: ["+la+"], seconds to expire: ["+(e-ma)+"], expired: ["+(parseInt(e)<=G())+"] ");if(d||!la||!e||parseInt(e)<=G())b(c.INFO,"begin_session, Session started"),null===Ba&&(Ba=!0),e={begin_session:1},e.metrics=JSON.stringify(Wa()),P(e);x("cly_session",G()+60*La)}}else ha.begin_session=arguments};this.session_duration=function(a){b(c.INFO,"session_duration, Reporting session duration");this.check_consent("sessions")&&Y&&(b(c.INFO,"session_duration, Session extended: ",a),P({session_duration:a}),
80
+ Ea())};this.end_session=function(a,d){b(c.INFO,"end_session, Ending the current session. There was an on going session:["+Y+"]");this.check_consent("sessions")&&Y&&(a=a||G()-ma,qa(),!la||d?(b(c.INFO,"end_session, Session ended"),P({end_session:1,session_duration:a})):this.session_duration(a),Y=!1)};this.set_id=function(a){b(c.INFO,"set_id, Changing the device ID to:["+a+"]");null==a||""===a?b(c.WARNING,"set_id, The provided device is not a valid ID"):0===E?this.change_id(a,!1):this.change_id(a,!0)};
81
+ this.change_id=function(a,d){b(c.INFO,"change_id, Changing the device ID to: ["+a+"] with merge:["+d+"]");if(a&&"string"===typeof a&&0!==a.length)if(J)b(c.WARNING,"change_id, Offline mode was on, initiating disabling sequence instead."),this.disable_offline_mode(a);else if(this.device_id==a)b(c.DEBUG,"change_id, Provided device ID is equal to the current device ID. Aborting.");else{d||(za(),R(),this.end_session(null,!0),fa={},this.remove_consent_internal(q.features,!1));var e=this.device_id;this.device_id=
82
+ a;f.device_id=this.device_id;E=0;x("cly_id",this.device_id);x("cly_id_type",0);b(c.INFO,"change_id, Changing ID from:["+e+"] to ["+a+"]");d?P({old_device_id:e}):this.begin_session(!Ka,!0);this.remote_config&&(S={},x("cly_remote_configs",S),this.fetch_remote_config(this.remote_config))}else b(c.WARNING,"change_id, The provided device ID is not a valid ID")};this.add_event=function(a){b(c.INFO,"add_event, Adding event: ",a);switch(a.key){case M.NPS:var d=this.check_consent("feedback");break;case M.SURVEY:d=
83
+ this.check_consent("feedback");break;case M.STAR_RATING:d=this.check_consent("star-rating");break;case M.VIEW:d=this.check_consent("views");break;case M.ORIENTATION:d=this.check_consent("users");break;case M.ACTION:d=this.check_consent("clicks")||this.check_consent("scrolls");break;default:d=this.check_consent("events")}d&&w(a)};this.start_event=function(a){a&&"string"===typeof a?(b(c.INFO,"start_event, Starting timed event with key: ["+a+"]"),a=A(a,f.maxKeyLength,"start_event",b),fa[a]?b(c.WARNING,
84
+ "start_event, Timed event with key: ["+a+"] already started"):fa[a]=G()):b(c.WARNING,"start_event, you have to provide a valid string key instead of: ["+a+"]")};this.cancel_event=function(a){if(!a||"string"!==typeof a)return b(c.WARNING,"cancel_event, you have to provide a valid string key instead of: ["+a+"]"),!1;b(c.INFO,"cancel_event, Canceling timed event with key: ["+a+"]");a=A(a,f.maxKeyLength,"cancel_event",b);if(fa[a])return delete fa[a],b(c.INFO,"cancel_event, Timed event with key: ["+a+
85
+ "] is canceled"),!0;b(c.WARNING,"cancel_event, Timed event with key: ["+a+"] was not found");return!1};this.end_event=function(a){a?(b(c.INFO,"end_event, Ending timed event"),"string"===typeof a&&(a=A(a,f.maxKeyLength,"end_event",b),a={key:a}),a.key?fa[a.key]?(a.dur=G()-fa[a.key],this.add_event(a),delete fa[a.key]):b(c.ERROR,"end_event, Timed event with key: ["+a.key+"] was not started"):b(c.ERROR,"end_event, Timed event must have a key property")):b(c.WARNING,"end_event, you have to provide a valid string key or event object instead of: ["+
86
+ a+"]")};this.report_orientation=function(a){b(c.INFO,"report_orientation, Reporting orientation");this.check_consent("users")&&w({key:M.ORIENTATION,segmentation:{mode:a||(window.innerWidth>window.innerHeight?"landscape":"portrait")}})};this.report_conversion=function(a,d){b(c.WARNING,"report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!");this.recordDirectAttribution(a,d)};this.recordDirectAttribution=function(a,d){b(c.INFO,
87
+ "recordDirectAttribution, Recording the attribution for campaign ID: ["+a+"] and the user ID: ["+d+"]");this.check_consent("attribution")&&(a=a||z("cly_cmp_id")||"cly_organic",(d=d||z("cly_cmp_uid"))?P({campaign_id:a,campaign_user:d}):P({campaign_id:a}))};this.user_details=function(a){b(c.INFO,"user_details, Trying to add user details: ",a);this.check_consent("users")&&(za(),R(),b(c.INFO,"user_details, flushed the event queue"),a.name=A(a.name,f.maxValueSize,"user_details",b),a.username=A(a.username,
88
+ f.maxValueSize,"user_details",b),a.email=A(a.email,f.maxValueSize,"user_details",b),a.organization=A(a.organization,f.maxValueSize,"user_details",b),a.phone=A(a.phone,f.maxValueSize,"user_details",b),a.picture=A(a.picture,4096,"user_details",b),a.gender=A(a.gender,f.maxValueSize,"user_details",b),a.byear=A(a.byear,f.maxValueSize,"user_details",b),a.custom=ca(a.custom,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"user_details",b),P({user_details:JSON.stringify(Ca(a,"name username email organization phone picture gender byear custom".split(" ")))}))};
89
+ var aa={},ia=function(a,d,e){f.check_consent("users")&&(aa[a]||(aa[a]={}),"$push"===e||"$pull"===e||"$addToSet"===e?(aa[a][e]||(aa[a][e]=[]),aa[a][e].push(d)):aa[a][e]=d)};this.userData={set:function(a,d){b(c.INFO,"[userData] set, Setting user's custom property value: ["+d+"] under the key: ["+a+"]");a=A(a,f.maxKeyLength,"userData set",b);d=A(d,f.maxValueSize,"userData set",b);aa[a]=d},unset:function(a){b(c.INFO,"[userData] unset, Resetting user's custom property with key: ["+a+"] ");aa[a]=""},set_once:function(a,
90
+ d){b(c.INFO,"[userData] set_once, Setting user's unique custom property value: ["+d+"] under the key: ["+a+"] ");a=A(a,f.maxKeyLength,"userData set_once",b);d=A(d,f.maxValueSize,"userData set_once",b);ia(a,d,"$setOnce")},increment:function(a){b(c.INFO,"[userData] increment, Increasing user's custom property value under the key: ["+a+"] by one");a=A(a,f.maxKeyLength,"userData increment",b);ia(a,1,"$inc")},increment_by:function(a,d){b(c.INFO,"[userData] increment_by, Increasing user's custom property value under the key: ["+
91
+ a+"] by: ["+d+"]");a=A(a,f.maxKeyLength,"userData increment_by",b);d=A(d,f.maxValueSize,"userData increment_by",b);ia(a,d,"$inc")},multiply:function(a,d){b(c.INFO,"[userData] multiply, Multiplying user's custom property value under the key: ["+a+"] by: ["+d+"]");a=A(a,f.maxKeyLength,"userData multiply",b);d=A(d,f.maxValueSize,"userData multiply",b);ia(a,d,"$mul")},max:function(a,d){b(c.INFO,"[userData] max, Saving user's maximum custom property value compared to the value: ["+d+"] under the key: ["+
92
+ a+"]");a=A(a,f.maxKeyLength,"userData max",b);d=A(d,f.maxValueSize,"userData max",b);ia(a,d,"$max")},min:function(a,d){b(c.INFO,"[userData] min, Saving user's minimum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=A(a,f.maxKeyLength,"userData min",b);d=A(d,f.maxValueSize,"userData min",b);ia(a,d,"$min")},push:function(a,d){b(c.INFO,"[userData] push, Pushing a value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=A(a,f.maxKeyLength,"userData push",
93
+ b);d=A(d,f.maxValueSize,"userData push",b);ia(a,d,"$push")},push_unique:function(a,d){b(c.INFO,"[userData] push_unique, Pushing a unique value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=A(a,f.maxKeyLength,"userData push_unique",b);d=A(d,f.maxValueSize,"userData push_unique",b);ia(a,d,"$addToSet")},pull:function(a,d){b(c.INFO,"[userData] pull, Removing the value: ["+d+"] under the key: ["+a+"] from user's custom property array");ia(a,d,"$pull")},save:function(){b(c.INFO,"[userData] save, Saving changes to user's custom property");
94
+ f.check_consent("users")&&(za(),R(),b(c.INFO,"user_details, flushed the event queue"),P({user_details:JSON.stringify({custom:aa})}));aa={}}};this.report_trace=function(a){b(c.INFO,"report_trace, Reporting performance trace");if(this.check_consent("apm")){for(var d="type name stz etz apm_metrics apm_attr".split(" "),e=0;e<d.length;e++)if("apm_attr"!==d[e]&&"undefined"===typeof a[d[e]]){b(c.WARNING,"report_trace, APM trace don't have the property: "+d[e]);return}a.name=A(a.name,f.maxKeyLength,"report_trace",
95
+ b);a.app_metrics=ca(a.app_metrics,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"report_trace",b);d=Ca(a,d);d.timestamp=a.stz;a=new Date;d.hour=a.getHours();d.dow=a.getDay();P({apm:JSON.stringify(d)});b(c.INFO,"report_trace, Successfully adding APM trace: ",d)}};this.track_errors=function(a){y?(b(c.INFO,"track_errors, Started tracking errors"),q.i[this.app_key].tracking_crashes=!0,window.cly_crashes||(window.cly_crashes=!0,xb=a,window.onerror=function u(e,h,n,g,p){if(void 0!==p&&null!==p)lb(p,
96
+ !1);else{g=g||window.event&&window.event.errorCharacter;p="";"undefined"!==typeof e&&(p+=e+"\n");"undefined"!==typeof h&&(p+="at "+h);"undefined"!==typeof n&&(p+=":"+n);"undefined"!==typeof g&&(p+=":"+g);p+="\n";try{e=[];for(var t=u.caller;t;)e.push(t.name),t=t.caller;p+=e.join("\n")}catch(H){b(c.ERROR,"track_errors, Call stack generation experienced a problem: "+H)}lb(p,!1)}},window.addEventListener("unhandledrejection",function(e){lb(Error("Unhandled rejection (reason: "+(e.reason&&e.reason.stack?
97
+ e.reason.stack:e.reason)+")."),!0)}))):b(c.WARNING,"track_errors, window object is not available. Not tracking errors.")};this.log_error=function(a,d){b(c.INFO,"log_error, Logging errors");this.recordError(a,!0,d)};this.add_log=function(a){b(c.INFO,"add_log, Adding a new log of breadcrumbs: [ "+a+" ]");if(this.check_consent("crashes")){for(a=A(a,f.maxValueSize,"add_log",b);va.length>=f.maxBreadcrumbCount;)va.shift(),b(c.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one.");
98
+ va.push(a)}};this.fetch_remote_config=function(a,d,e){var h=null,n=null,g=null;a&&(e||"function"!==typeof a?Array.isArray(a)&&(h=a):g=a);d&&(e||"function"!==typeof d?Array.isArray(d)&&(n=d):g=d);g||"function"!==typeof e||(g=e);this.useExplicitRcApi?(b(c.INFO,"fetch_remote_config, Fetching remote config"),D(h,n,this.rcAutoOptinAb?1:0,null,g)):(b(c.WARNING,"fetch_remote_config, Fetching remote config, with legacy API"),D(h,n,null,"legacy",g))};this.enrollUserToAb=function(a){b(c.INFO,"enrollUserToAb, Providing AB test keys to opt in for");
99
+ a&&Array.isArray(a)&&0!==a.length?(a={method:"ab",keys:JSON.stringify(a),av:f.app_version},Ga(a),da("enrollUserToAb",this.url+Xa,a,function(d,e,h){if(!d)try{var n=JSON.parse(h);b(c.DEBUG,"enrollUserToAb, Parsed the response's result: ["+n.result+"]")}catch(g){b(c.ERROR,"enrollUserToAb, Had an issue while parsing the response: "+g)}},!0)):b(c.ERROR,"enrollUserToAb, No keys provided")};this.get_remote_config=function(a){b(c.INFO,"get_remote_config, Getting remote config from storage");return"undefined"!==
100
+ typeof a?S[a]:S};this.stop_time=function(){b(c.INFO,"stop_time, Stopping tracking duration");ta&&(ta=!1,yb=G()-ma,Ja=G()-Ia)};this.start_time=function(){b(c.INFO,"start_time, Starting tracking duration");ta||(ta=!0,ma=G()-yb,Ia=G()-Ja,Ja=0,Ea())};this.track_sessions=function(){function a(){document[e]||!document.hasFocus()?f.stop_time():f.start_time()}function d(){Qa>=Pa&&f.start_time();Qa=0}if(y){b(c.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();B(window,
101
+ "beforeunload",function(){za();R();f.end_session()});var e="hidden";B(window,"focus",a);B(window,"blur",a);B(window,"pageshow",a);B(window,"pagehide",a);"onfocusin"in document&&(B(window,"focusin",a),B(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=
102
+ "msHidden",document.addEventListener("msvisibilitychange",a));B(window,"mousemove",d);B(window,"click",d);B(window,"keydown",d);B(window,"scroll",d);setInterval(function(){Qa++;Qa>=Pa&&f.stop_time()},6E4)}else b(c.WARNING,"track_sessions, window object is not available. Not tracking sessions.")};this.track_pageview=function(a,d,e){if(y||a)if(b(c.INFO,"track_pageview, Tracking page views"),b(c.VERBOSE,"track_pageview, last view is:["+Z+"], current view ID is:["+ra+"], previous view ID is:["+Va+"]"),
103
+ Z&&zb&&(b(c.DEBUG,"track_pageview, Scroll registry triggered"),wb(),Oa=!0,Na=0),qa(),Va=ra,ra=ib(),(a=A(a,f.maxKeyLength,"track_pageview",b))&&Array.isArray(a)&&(d=a,a=null),a||(a=this.getViewName()),void 0===a||""===a)b(c.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)b(c.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(d&&d.length)for(var h=0;h<d.length;h++)try{if((new RegExp(d[h])).test(a)){b(c.INFO,
104
+ "track_pageview, Ignoring the page: "+a);return}}catch(u){b(c.ERROR,"track_pageview, Problem with finding ignore list item: "+d[h]+", error: "+u)}h={name:a,visit:1,view:f.getViewUrl()};h=ca(h,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);this.track_domains&&(h.domain=window.location.hostname);if(la)if(Y)Ba&&(Ba=!1,h.start=1);else{var n=z("cly_session");if(!n||parseInt(n)<=G())Ba=!1,h.start=1}else y&&"undefined"!==typeof document.referrer&&document.referrer.length&&(n=Ob.exec(document.referrer))&&
105
+ n[11]&&n[11]!==window.location.hostname&&(h.start=1);if(oa&&Object.keys(oa).length){b(c.INFO,"track_pageview, Adding fresh utm tags to segmentation:["+JSON.stringify(oa)+"]");for(var g in oa)"undefined"===typeof h["utm_"+g]&&(h["utm_"+g]=oa[g])}y&&tb()&&(b(c.INFO,"track_pageview, Adding referrer to segmentation:["+document.referrer+"]"),h.referrer=document.referrer);if(e){e=ca(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);for(var p in e)"undefined"===typeof h[p]&&(h[p]=
106
+ e[p])}this.check_consent("views")?(w({key:M.VIEW,segmentation:h},ra),Z=a,Ia=G(),b(c.VERBOSE,"track_pageview, last view is assigned:["+Z+"]")):ha.track_pageview=arguments}else b(c.WARNING,"track_pageview, window object is not available. Not tracking page views is page is not provided.")};this.track_view=function(a,d,e){b(c.INFO,"track_view, Initiating tracking page views");this.track_pageview(a,d,e)};this.track_clicks=function(a){if(y){b(c.INFO,"track_clicks, Starting to track clicks");a&&b(c.INFO,
107
+ "track_clicks, Tracking the specified children:["+a+"]");a=a||document;var d=!0;B(a,"click",function(e){if(d){d=!1;ob(e);if("undefined"!==typeof e.pageX&&"undefined"!==typeof e.pageY){var h=Ta(),n=pb();f.check_consent("clicks")&&(e={type:"click",x:e.pageX,y:e.pageY,width:n,height:h,view:f.getViewUrl()},e=ca(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processClick",b),f.track_domains&&(e.domain=window.location.hostname),w({key:M.ACTION,segmentation:e}))}setTimeout(function(){d=!0},1E3)}})}else b(c.WARNING,
108
+ "track_clicks, window object is not available. Not tracking clicks.")};this.track_scrolls=function(a){y?(b(c.INFO,"track_scrolls, Starting to track scrolls"),a&&b(c.INFO,"track_scrolls, Tracking the specified children"),a=a||window,zb=Oa=!0,B(a,"scroll",Sb),B(a,"beforeunload",wb)):b(c.WARNING,"track_scrolls, window object is not available. Not tracking scrolls.")};this.track_links=function(a){y?(b(c.INFO,"track_links, Starting to track clicks to links"),a&&b(c.INFO,"track_links, Tracking the specified children"),
109
+ a=a||document,B(a,"click",function(d){a:{var e=Sa(d);var h;for(h="A";e;){if(e.nodeName.toUpperCase()===h)break a;e=e.parentElement}e=void 0}e&&(ob(d),f.check_consent("clicks")&&w({key:"linkClick",segmentation:{href:e.href,text:e.innerText,id:e.id,view:f.getViewUrl()}}))})):b(c.WARNING,"track_links, window object is not available. Not tracking links.")};this.track_forms=function(a,d){function e(h){return h.name||h.id||h.type||h.nodeName}y?(b(c.INFO,"track_forms, Starting to track form submissions. DOM object provided:["+
110
+ !!a+"] Tracking hidden inputs :["+!!d+"]"),a=a||document,B(a,"submit",function(h){h=Sa(h);var n={id:h.attributes.id&&h.attributes.id.nodeValue,name:h.attributes.name&&h.attributes.name.nodeValue,action:h.attributes.action&&h.attributes.action.nodeValue,method:h.attributes.method&&h.attributes.method.nodeValue,view:f.getViewUrl()},g;if("undefined"!==typeof h.elements){for(var p=0;p<h.elements.length;p++)(g=h.elements[p])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore")&&("undefined"===
111
+ typeof n["input:"+e(g)]&&(n["input:"+e(g)]=[]),"select"===g.nodeName.toLowerCase()?"undefined"!==typeof g.multiple?n["input:"+e(g)].push(Db(g)):n["input:"+e(g)].push(g.options[g.selectedIndex].value):"input"===g.nodeName.toLowerCase()?"undefined"!==typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&n["input:"+e(g)].push(g.value):("hidden"!==g.type.toLowerCase()||d)&&n["input:"+e(g)].push(g.value):n["input:"+e(g)].push(g.value):"textarea"===g.nodeName.toLowerCase()?
112
+ n["input:"+e(g)].push(g.value):"undefined"!==typeof g.value&&n["input:"+e(g)].push(g.value));for(var u in n)n[u]&&"function"===typeof n[u].join&&(n[u]=n[u].join(", "))}f.check_consent("forms")&&w({key:"formSubmit",segmentation:n})})):b(c.WARNING,"track_forms, window object is not available. Not tracking forms.")};this.collect_from_forms=function(a,d){y?(b(c.INFO,"collect_from_forms, Starting to collect possible user data. DOM object provided:["+!!a+"] Submitting custom user property:["+!!d+"]"),a=
113
+ a||document,B(a,"submit",function(e){e=Sa(e);var h={},n=!1,g;if("undefined"!==typeof e.elements){var p={},u=a.getElementsByTagName("LABEL"),t;for(t=0;t<u.length;t++)u[t].htmlFor&&""!==u[t].htmlFor&&(p[u[t].htmlFor]=u[t].innerText||u[t].textContent||u[t].innerHTML);for(t=0;t<e.elements.length;t++)if((g=e.elements[t])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore"))if(u="","select"===g.nodeName.toLowerCase()?u="undefined"!==typeof g.multiple?Db(g):g.options[g.selectedIndex].value:
114
+ "input"===g.nodeName.toLowerCase()?"undefined"!==typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&(u=g.value):u=g.value:u=g.value:"textarea"===g.nodeName.toLowerCase()?u=g.value:"undefined"!==typeof g.value&&(u=g.value),g.className&&-1!==g.className.indexOf("cly_user_")){var H=g.className.split(" ");for(g=0;g<H.length;g++)if(0===H[g].indexOf("cly_user_")){h[H[g].replace("cly_user_","")]=u;n=!0;break}}else if(g.type&&"email"===g.type.toLowerCase()||g.name&&
115
+ -1!==g.name.toLowerCase().indexOf("email")||g.id&&-1!==g.id.toLowerCase().indexOf("email")||g.id&&p[g.id]&&-1!==p[g.id].toLowerCase().indexOf("email")||/[^@\s]+@[^@\s]+\.[^@\s]+/.test(u))h.email||(h.email=u),n=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("username")||g.id&&-1!==g.id.toLowerCase().indexOf("username")||g.id&&p[g.id]&&-1!==p[g.id].toLowerCase().indexOf("username"))h.username||(h.username=u),n=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("tel")||-1!==g.name.toLowerCase().indexOf("phone")||
116
+ -1!==g.name.toLowerCase().indexOf("number"))||g.id&&(-1!==g.id.toLowerCase().indexOf("tel")||-1!==g.id.toLowerCase().indexOf("phone")||-1!==g.id.toLowerCase().indexOf("number"))||g.id&&p[g.id]&&(-1!==p[g.id].toLowerCase().indexOf("tel")||-1!==p[g.id].toLowerCase().indexOf("phone")||-1!==p[g.id].toLowerCase().indexOf("number")))h.phone||(h.phone=u),n=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("org")||-1!==g.name.toLowerCase().indexOf("company"))||g.id&&(-1!==g.id.toLowerCase().indexOf("org")||
117
+ -1!==g.id.toLowerCase().indexOf("company"))||g.id&&p[g.id]&&(-1!==p[g.id].toLowerCase().indexOf("org")||-1!==p[g.id].toLowerCase().indexOf("company")))h.organization||(h.organization=u),n=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("name")||g.id&&-1!==g.id.toLowerCase().indexOf("name")||g.id&&p[g.id]&&-1!==p[g.id].toLowerCase().indexOf("name"))h.name||(h.name=""),h.name+=u+" ",n=!0}n&&(b(c.INFO,"collect_from_forms, Gathered user data",h),d?f.user_details({custom:h}):f.user_details(h))})):
118
+ b(c.WARNING,"collect_from_forms, window object is not available. Not collecting from forms.")};this.collect_from_facebook=function(a){y?"undefined"!==typeof FB&&FB&&FB.api?(b(c.INFO,"collect_from_facebook, Starting to collect possible user data"),FB.api("/me",function(d){var e={};d.name&&(e.name=d.name);d.email&&(e.email=d.email);"male"===d.gender?e.gender="M":"female"===d.gender&&(e.gender="F");if(d.birthday){var h=d.birthday.split("/").pop();h&&4===h.length&&(e.byear=h)}d.work&&d.work[0]&&d.work[0].employer&&
119
+ d.work[0].employer.name&&(e.organization=d.work[0].employer.name);if(a){e.custom={};for(var n in a){h=a[n].split(".");for(var g=d,p=0;p<h.length&&(g=g[h[p]],"undefined"!==typeof g);p++);"undefined"!==typeof g&&(e.custom[n]=g)}}f.user_details(e)})):b(c.ERROR,"collect_from_facebook, Facebook SDK is not available"):b(c.WARNING,"collect_from_facebook, window object is not available. Not collecting from Facebook.")};this.opt_out=function(){b(c.INFO,"opt_out, Opting out the user");this.ignore_visitor=!0;
120
+ x("cly_ignore",!0)};this.opt_in=function(){b(c.INFO,"opt_in, Opting in the user");x("cly_ignore",!1);this.ignore_visitor=!1;O();this.ignore_visitor||$a||Za()};this.report_feedback=function(a){b(c.WARNING,"report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' or 'reportFeedbackWidgetManually' in place of this call. Call will be redirected to 'recordRatingWidgetWithID' now!");this.recordRatingWidgetWithID(a)};this.recordRatingWidgetWithID=function(a){b(c.INFO,"recordRatingWidgetWithID, Providing information about user with ID: [ "+
121
+ a.widget_id+" ]");if(this.check_consent("star-rating"))if(a.widget_id)if(a.rating){var d={key:M.STAR_RATING,count:1,segmentation:{}};d.segmentation=Ca(a,"widget_id contactMe platform app_version rating email comment".split(" "));d.segmentation.app_version||(d.segmentation.app_version=this.metrics._app_version||this.app_version);5<d.segmentation.rating?(b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating higher than 5. Changing it back to 5 now."),d.segmentation.rating=5):1>d.segmentation.rating&&
122
+ (b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating lower than 1. Changing it back to 1 now."),d.segmentation.rating=1);b(c.INFO,"recordRatingWidgetWithID, Reporting Rating Widget: ",d);w(d)}else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain rating property");else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain widget_id property")};this.reportFeedbackWidgetManually=function(a,d,e){if(this.check_consent("feedback"))if(a&&d)if(a._id)if(J)b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets can not be reported in offline mode");
123
+ else{b(c.INFO,"reportFeedbackWidgetManually, Providing information about user with, provided result of the widget with ID: [ "+a._id+" ] and type: ["+a.type+"]");var h=[];d=a.type;if("nps"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=Math.round(e.rating);10<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 10. Changing it back to 10 now."),e.rating=10):0>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 0. Changing it back to 0 now."),
124
+ e.rating=0);h=["rating","comment"]}var n=M.NPS}else if("survey"===d){if(e){if(1>Object.keys(e).length){b(c.ERROR,"reportFeedbackWidgetManually, Widget should have answers to be reported");return}h=Object.keys(e)}n=M.SURVEY}else if("rating"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=Math.round(e.rating);5<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 5. Changing it back to 5 now."),
125
+ e.rating=5):1>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 1. Changing it back to 1 now."),e.rating=1);h=["rating","comment","email","contactMe"]}n=M.STAR_RATING}else{b(c.ERROR,"reportFeedbackWidgetManually, Widget has an unacceptable type");return}a={key:n,count:1,segmentation:{widget_id:a._id,platform:this.platform,app_version:this.metrics._app_version||this.app_version}};if(null===e)a.segmentation.closed=1;else{n=a.segmentation;if(h){for(var g,p=0,
126
+ u=h.length;p<u;p++)g=h[p],"undefined"!==typeof e[g]&&(n[g]=e[g]);e=n}else e=void 0;a.segmentation=e}b(c.INFO,"reportFeedbackWidgetManually, Reporting "+d+": ",a);w(a)}else b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets must contain _id property");else b(c.ERROR,"reportFeedbackWidgetManually, Widget data and/or Widget object not provided. Aborting.")};this.show_feedback_popup=function(a){y?(b(c.WARNING,"show_feedback_popup, Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!"),
127
+ this.presentRatingWidgetWithID(a)):b(c.WARNING,"show_feedback_popup, window object is not available. Not showing feedback popup.")};this.presentRatingWidgetWithID=function(a){y?(b(c.INFO,"presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ "+a+" ]"),this.check_consent("star-rating")&&(J?b(c.ERROR,"presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"):da("presentRatingWidgetWithID,",this.url+"/o/feedback/widget",{widget_id:a,av:f.app_version},function(d,
128
+ e,h){if(!d)try{var n=JSON.parse(h);X(n,!1)}catch(g){b(c.ERROR,"presentRatingWidgetWithID, JSON parse failed: "+g)}},!0))):b(c.WARNING,"presentRatingWidgetWithID, window object is not available. Not showing rating widget popup.")};this.initialize_feedback_popups=function(a){y?(b(c.WARNING,"initialize_feedback_popups, Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!"),this.initializeRatingWidgets(a)):b(c.WARNING,"initialize_feedback_popups, window object is not available. Not initializing feedback popups.")};
129
+ this.initializeRatingWidgets=function(a){if(y){if(b(c.INFO,"initializeRatingWidgets, Initializing rating widget with provided widget IDs:[ "+a+"]"),this.check_consent("star-rating")){a||(a=z("cly_fb_widgets"));for(var d=document.getElementsByClassName("countly-feedback-sticker");0<d.length;)d[0].remove();da("initializeRatingWidgets,",this.url+"/o/feedback/multiple-widgets-by-id",{widgets:JSON.stringify(a),av:f.app_version},function(e,h,n){if(!e)try{var g=JSON.parse(n);for(e=0;e<g.length;e++)if("true"===
130
+ g[e].is_active){var p=g[e].target_devices,u=Gb();if(p[u])if("string"===typeof g[e].hide_sticker&&(g[e].hide_sticker="true"===g[e].hide_sticker),"all"!==g[e].target_page||g[e].hide_sticker){var t=g[e].target_pages;for(h=0;h<t.length;h++){var H=t[h].substr(0,t[h].length-1)===window.location.pathname.substr(0,t[h].length-1),N=t[h]===window.location.pathname;(t[h].includes("*")&&H||N)&&!g[e].hide_sticker&&X(g[e],!0)}}else X(g[e],!0)}}catch(L){b(c.ERROR,"initializeRatingWidgets, JSON parse error: "+L)}},
131
+ !0)}}else b(c.WARNING,"initializeRatingWidgets, window object is not available. Not initializing rating widgets.")};this.enable_feedback=function(a){y?(b(c.WARNING,"enable_feedback, Deprecated function call! Use 'enableRatingWidgets' in place of this call. Call will be redirected now!"),this.enableRatingWidgets(a)):b(c.WARNING,"enable_feedback, window object is not available. Not enabling feedback.")};this.enableRatingWidgets=function(a){y?(b(c.INFO,"enableRatingWidgets, Enabling rating widget with params:",
132
+ a),this.check_consent("star-rating")&&(J?b(c.ERROR,"enableRatingWidgets, Cannot enable rating widgets in offline mode"):(x("cly_fb_widgets",a.popups||a.widgets),Ua(this.url+"/star-rating/stylesheets/countly-feedback-web.css"),a=a.popups||a.widgets,0<a.length?(document.body.insertAdjacentHTML("beforeend",'<div id="cfbg"></div>'),this.initializeRatingWidgets(a)):b(c.ERROR,"enableRatingWidgets, You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback")))):
133
+ b(c.WARNING,"enableRatingWidgets, window object is not available. Not enabling rating widgets.")};$b(ka,this,function(a,d){b(c.INFO,"showWidget, Showing ".concat(a," widget, nameIDorTag:[").concat(d,"]"));l.get_available_feedback_widgets(function(e,h){h?b(c.ERROR,"showWidget, Error while getting feedback widgets list: ".concat(h)):(h=e.find(function(n){return n.type===a}),d&&"string"===typeof d&&(e=e.find(function(n){return n.type===a&&(n.name===d||n._id===d||n.tg.includes(d))}))&&(h=e,b(c.VERBOSE,
134
+ "showWidget, Found ".concat(a," widget by name, id, or tag: [").concat(JSON.stringify(e),"]"))),h?l.present_feedback_widget(h,null,null,null):b(c.ERROR,"showWidget, No ".concat(a," widget found.")))})});this.feedback={showNPS:function(a){return ka.get(ja(ka,l)).call(l,"nps",a)},showSurvey:function(a){return ka.get(ja(ka,l)).call(l,"survey",a)},showRating:function(a){return ka.get(ja(ka,l)).call(l,"rating",a)}};this.get_available_feedback_widgets=function(a){b(c.INFO,"get_available_feedback_widgets, Getting the feedback list, callback function is provided:["+
135
+ !!a+"]");this.check_consent("feedback")?J?b(c.ERROR,"get_available_feedback_widgets, Cannot enable feedback widgets in offline mode."):da("get_available_feedback_widgets,",this.url+Xa,{method:"feedback",device_id:this.device_id,app_key:this.app_key,av:f.app_version},function(d,e,h){if(d)a&&a(null,d);else try{var n=JSON.parse(h).result||[];a&&a(n,null)}catch(g){b(c.ERROR,"get_available_feedback_widgets, Error while parsing feedback widgets list: "+g),a&&a(null,g)}},!1):a&&a(null,Error("Consent for feedback not provided."))};
136
+ this.getFeedbackWidgetData=function(a,d){if(a.type)if(b(c.INFO,"getFeedbackWidgetData, Retrieving data for: ["+JSON.stringify(a)+"], callback function is provided:["+!!d+"]"),this.check_consent("feedback"))if(J)b(c.ERROR,"getFeedbackWidgetData, Cannot enable feedback widgets in offline mode.");else{var e=this.url,h={widget_id:a._id,shown:1,sdk_version:sa,sdk_name:ya,platform:this.platform,app_version:this.app_version};if("nps"===a.type)e+="/o/surveys/nps/widget";else if("survey"===a.type)e+="/o/surveys/survey/widget";
137
+ else if("rating"===a.type)e+="/o/surveys/rating/widget";else{b(c.ERROR,"getFeedbackWidgetData, Unknown type info: ["+a.type+"]");return}da("getFeedbackWidgetData,",e,h,function(n,g,p){if(n)d&&d(null,n);else try{var u=JSON.parse(p);d&&d(u,null)}catch(t){b(c.ERROR,"getFeedbackWidgetData, Error while parsing feedback widgets list: "+t),d&&d(null,t)}},!0)}else d&&d(null,Error("Consent for feedback not provided."));else b(c.ERROR,"getFeedbackWidgetData, Expected the provided widget object to have a type but got: ["+
138
+ JSON.stringify(a)+"], aborting.")};this.present_feedback_widget=function(a,d,e,h){function n(C){document.getElementById("countly-surveys-wrapper-"+C._id).style.display="block";document.getElementById("csbg").style.display="block"}function g(C){for(var Q=document.getElementsByClassName("countly-feedback-sticker");0<Q.length;)b(c.VERBOSE,"present_feedback_widget, Removing old stickers"),Q[0].remove();C.appearance.hideS||(b(c.DEBUG,"present_feedback_widget, handling the sticker as it was not set to hidden"),
139
+ Q=document.createElement("div"),Q.innerText=C.appearance.text,Q.style.color=7>C.appearance.text_color.length?"#"+C.appearance.text_color:C.appearance.text_color,Q.style.backgroundColor=7>C.appearance.bg_color.length?"#"+C.appearance.bg_color:C.appearance.bg_color,Q.className="countly-feedback-sticker "+C.appearance.position+"-"+C.appearance.size,Q.id="countly-feedback-sticker-"+C._id,document.body.appendChild(Q),B(document.getElementById("countly-feedback-sticker-"+C._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+
140
+ C._id).style.display="flex";document.getElementById("csbg").style.display="block"}));B(document.getElementById("countly-feedback-close-icon-"+C._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+C._id).style.display="none";document.getElementById("csbg").style.display="none"})}if(y){if(b(c.INFO,"present_feedback_widget, Presenting the feedback widget by appending to the element with ID: [ "+d+" ] and className: [ "+e+" ]"),this.check_consent("feedback"))if(!a||"object"!==U(a)||
141
+ Array.isArray(a))b(c.ERROR,"present_feedback_widget, Please provide at least one feedback widget object.");else{b(c.INFO,"present_feedback_widget, Adding segmentation to feedback widgets:["+JSON.stringify(h)+"]");h&&"object"===U(h)&&0!==Object.keys(h).length||(b(c.DEBUG,"present_feedback_widget, Segmentation is not an object or empty"),h=null);try{var p=this.url;if("nps"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: nps."),p+="/feedback/nps";else if("survey"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: survey."),
142
+ p+="/feedback/survey";else if("rating"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: rating."),p+="/feedback/rating";else{b(c.ERROR,"present_feedback_widget, Feedback widget only accepts nps, rating and survey types.");return}var u=window.origin||window.location.origin;if("rating"===a.type){b(c.DEBUG,"present_feedback_widget, Loading css for rating widget.");var t="ratings";Ua(this.url+"/star-rating/stylesheets/countly-feedback-web.css")}else b(c.DEBUG,"present_feedback_widget, Loading css for survey or nps."),
143
+ Ua(this.url+"/surveys/stylesheets/countly-surveys.css"),t="surveys";p+="?widget_id="+a._id;p+="&app_key="+this.app_key;p+="&device_id="+this.device_id;p+="&sdk_name="+ya;p+="&platform="+this.platform;p+="&app_version="+this.app_version;p+="&sdk_version="+sa;var H={tc:1};h&&(H.sg=h);p+="&custom="+JSON.stringify(H);p+="&origin="+u;p+="&widget_v=web";var N=document.createElement("iframe");N.src=p;N.name="countly-"+t+"-iframe";N.id="countly-"+t+"-iframe";var L=!1;N.onload=function(){L&&(document.getElementById("countly-"+
144
+ t+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none");L=!0;b(c.DEBUG,"present_feedback_widget, Loaded iframe.")};for(var Ha=document.getElementById("csbg");Ha;)Ha.remove(),Ha=document.getElementById("csbg"),b(c.DEBUG,"present_feedback_widget, Removing past overlay.");var ba=document.getElementsByClassName("countly-"+t+"-wrapper");for(h=0;h<ba.length;h++)ba[h].remove(),b(c.DEBUG,"present_feedback_widget, Removed a wrapper.");ba=document.createElement("div");
145
+ ba.className="countly-"+t+"-wrapper";ba.id="countly-"+t+"-wrapper-"+a._id;"survey"===a.type&&(ba.className=ba.className+" "+a.appearance.position);var gb=document.body;h=!1;d&&(document.getElementById(d)?(gb=document.getElementById(d),h=!0):b(c.ERROR,"present_feedback_widget, Provided ID not found."));h||e&&(document.getElementsByClassName(e)[0]?gb=document.getElementsByClassName(e)[0]:b(c.ERROR,"present_feedback_widget, Provided class not found."));gb.insertAdjacentHTML("beforeend",'<div id="csbg"></div>');
146
+ gb.appendChild(ba);if("rating"===a.type){var Cb=document.createElement("div");Cb.className="countly-ratings-overlay";Cb.id="countly-ratings-overlay-"+a._id;ba.appendChild(Cb);b(c.DEBUG,"present_feedback_widget, appended the rating overlay to wrapper");B(document.getElementById("countly-ratings-overlay-"+a._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+a._id).style.display="none"})}ba.appendChild(N);b(c.DEBUG,"present_feedback_widget, Appended the iframe");B(window,"message",
147
+ function(C){var Q={};try{Q=JSON.parse(C.data),b(c.DEBUG,"present_feedback_widget, Parsed response message "+Q)}catch(dc){b(c.ERROR,"present_feedback_widget, Error while parsing message body "+dc)}Q.close?(document.getElementById("countly-"+t+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none"):b(c.DEBUG,"present_feedback_widget, Closing signal not sent yet")});if("survey"===a.type){var T=!1;switch(a.showPolicy){case "afterPageLoad":"complete"===document.readyState?
148
+ T||(T=!0,n(a)):B(document,"readystatechange",function(C){"complete"!==C.target.readyState||T||(T=!0,n(a))});break;case "afterConstantDelay":setTimeout(function(){T||(T=!0,n(a))},1E4);break;case "onAbandon":"complete"===document.readyState?B(document,"mouseleave",function(){T||(T=!0,n(a))}):B(document,"readystatechange",function(C){"complete"===C.target.readyState&&B(document,"mouseleave",function(){T||(T=!0,n(a))})});break;case "onScrollHalfwayDown":B(window,"scroll",function(){if(!T){var C=Math.max(window.scrollY,
149
+ document.body.scrollTop,document.documentElement.scrollTop),Q=Ta();C>=Q/2&&(T=!0,n(a))}});break;default:T||(T=!0,n(a))}}else if("nps"===a.type)document.getElementById("countly-"+t+"-wrapper-"+a._id).style.display="block",document.getElementById("csbg").style.display="block";else if("rating"===a.type){var hb=!1;"complete"===document.readyState?hb||(hb=!0,g(a)):B(document,"readystatechange",function(C){"complete"!==C.target.readyState||hb||(hb=!0,g(a))})}}catch(C){b(c.ERROR,"present_feedback_widget, Something went wrong while presenting the widget: "+
150
+ C)}}}else b(c.WARNING,"present_feedback_widget, window object is not available. Not presenting feedback widget.")};this.recordError=function(a,d,e){b(c.INFO,"recordError, Recording error");if(this.check_consent("crashes")&&a){e=e||xb;var h="";"object"===U(a)?"undefined"!==typeof a.stack?h=a.stack:("undefined"!==typeof a.name&&(h+=a.name+":"),"undefined"!==typeof a.message&&(h+=a.message+"\n"),"undefined"!==typeof a.fileName&&(h+="in "+a.fileName+"\n"),"undefined"!==typeof a.lineNumber&&(h+="on "+
151
+ a.lineNumber),"undefined"!==typeof a.columnNumber&&(h+=":"+a.columnNumber)):h=a+"";if(h.length>f.maxStackTraceLineLength*f.maxStackTraceLinesPerThread){b(c.DEBUG,"record_error, Error stack is too long will be truncated");a=h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var n=a.length;h<n;h++)a[h].length>f.maxStackTraceLineLength&&(a[h]=a[h].substring(0,f.maxStackTraceLineLength));h=a.join("\n")}d=!!d;a=Wa();h={_resolution:a._resolution,
152
+ _error:h,_app_version:a._app_version,_run:G()-Vb,_not_os_specific:!0,_javascript:!0};if(n=navigator.battery||navigator.webkitBattery||navigator.mozBattery||navigator.msBattery)h._bat=Math.floor(100*n.level);"undefined"!==typeof navigator.onLine&&(h._online=!!navigator.onLine);y&&(h._background=!document.hasFocus());0<va.length&&(h._logs=va.join("\n"));va=[];h._nonfatal=d;h._view=this.getViewName();"undefined"!==typeof e&&(e=ca(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"record_error",
153
+ b),h._custom=e);try{var g=document.createElement("canvas").getContext("experimental-webgl");h._opengl=g.getParameter(g.VERSION)}catch(p){b(c.ERROR,"Could not get the experimental-webgl context: "+p)}d={};d.crash=JSON.stringify(h);d.metrics=JSON.stringify({_ua:a._ua});P(d)}};this.onStorageChange=function(a,d){b(c.DEBUG,"onStorageChange, Applying storage changes for key:",a);b(c.DEBUG,"onStorageChange, Applying storage changes for value:",d);switch(a){case "cly_queue":I=f.deserialize(d||"[]");break;
154
+ case "cly_event":K=f.deserialize(d||"[]");break;case "cly_remote_configs":S=f.deserialize(d||"{}");break;case "cly_ignore":f.ignore_visitor=f.deserialize(d);break;case "cly_id":f.device_id=d;break;case "cly_id_type":E=f.deserialize(d)}};this._internals={store:x,getDocWidth:pb,getDocHeight:Ta,getViewportHeight:Ib,get_page_coord:ob,get_event_target:Sa,add_event_listener:B,createNewObjectFromProperties:Ca,truncateObject:ca,truncateSingleValue:A,stripTrailingSlash:wa,prepareParams:mb,sendXmlHttpRequest:Qb,
155
+ isResponseValid:vb,getInternalDeviceIdType:function(){return E},getMsTimestamp:kb,getTimestamp:G,isResponseValidBroad:ub,secureRandom:ib,log:b,checkIfLoggingIsOn:Fa,getMetrics:Wa,getUA:Pb,prepareRequest:Ga,generateUUID:jb,sendEventsForced:R,isUUID:function(a){return/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-4[0-9a-fA-F]{3}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(a)},calculateChecksum:Fb,isReferrerUsable:tb,getId:sb,heartBeat:Za,toRequestQueue:P,reportViewDuration:qa,loadJS:Kb,loadCSS:Ua,getLastView:function(){return Z},
156
+ setToken:Tb,getToken:function(){var a=z("cly_token");V("cly_token");return a},showLoader:Lb,hideLoader:Mb,setValueInStorage:x,getValueFromStorage:z,removeValueFromStorage:V,add_cly_events:w,processScrollView:wb,processScroll:Sb,currentUserAgentString:xa,currentUserAgentDataString:nb,userAgentDeviceDetection:Gb,userAgentSearchBotDetection:Hb,getRequestQueue:function(){return I},getEventQueue:function(){return K},sendFetchRequest:Rb,processAsyncQueue:za,makeNetworkRequest:da,clearQueue:function(){I=
157
+ [];x("cly_queue",[]);K=[];x("cly_event",[])},getLocalQueues:function(){return{eventQ:K,requestQ:I}}};var na={sendInstantHCRequest:function(){if(J)b(c.DEBUG,"sendInstantHCRequest, Offline mode is active. Not sending health check request."),Ab=!0;else{var a=A(f.hcErrorMessage,1E3,"healthCheck",b);""!==a&&(a=JSON.stringify(a));a={hc:JSON.stringify({el:f.hcErrorCount,wl:f.hcWarningCount,sc:f.hcStatusCode,em:a}),metrics:JSON.stringify({_app_version:f.app_version})};Ga(a);da("[healthCheck]",f.url+rb,a,
158
+ function(d){d||na.resetAndSaveCounters()},!0)}},resetAndSaveCounters:function(){na.resetCounters();x(W.errorCount,f.hcErrorCount);x(W.warningCount,f.hcWarningCount);x(W.statusCode,f.hcStatusCode);x(W.errorMessage,f.hcErrorMessage)},incrementErrorCount:function(){f.hcErrorCount++},incrementWarningCount:function(){f.hcWarningCount++},resetCounters:function(){f.hcErrorCount=0;f.hcWarningCount=0;f.hcStatusCode=-1;f.hcErrorMessage=""},saveRequestCounters:function(a,d){f.hcStatusCode=a;f.hcErrorMessage=
159
+ d;x(W.statusCode,f.hcStatusCode);x(W.errorMessage,f.hcErrorMessage)}};this.initialize()}),Yb=!0;q.features="apm attribution clicks crashes events feedback forms location remote-config scrolls sessions star-rating users views".split(" ");q.q=q.q||[];q.onload=q.onload||[];q.CountlyClass=Xb;q.init=function(k){k=k||{};if(q.loadAPMScriptsAsync&&Yb)Yb=!1,ac(k);else{var r=k.app_key||q.app_key;if(!q.i||!q.i[r]){k=new Xb(k);if(!q.i){q.i={};for(var w in k)q[w]=k[w]}q.i[r]=k}return q.i[r]}};q.serialize=function(k){"object"===
160
+ U(k)&&(k=JSON.stringify(k));return k};q.deserialize=function(k){if(""===k)return k;try{k=JSON.parse(k)}catch(r){Fa()&&console.warn("[WARNING] [Countly] deserialize, Could not parse the file:["+k+"], error: "+r)}return k};q.getViewName=function(){return y?window.location.pathname:"web_worker"};q.getViewUrl=function(){return y?window.location.pathname:"web_worker"};q.getSearchQuery=function(){if(y)return window.location.search};q.DeviceIdType={DEVELOPER_SUPPLIED:0,SDK_GENERATED:1,TEMPORARY_ID:2};y&&
161
+ window.addEventListener("storage",function(k){var r=(k.key+"").split("/"),w=r.pop();r=r.pop();if(q.i&&q.i[r])q.i[r].onStorageChange(w,k.newValue)});pa.default=q;Object.defineProperty(pa,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "default": "./lib/index.cjs"
14
14
  }
15
15
  },
16
- "version": "0.1.1",
16
+ "version": "0.1.3",
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.0.0",
19
19
  "rimraf": "6.0.1",
@@ -26,7 +26,7 @@
26
26
  "clean": "rimraf lib"
27
27
  },
28
28
  "dependencies": {
29
- "countly-sdk-web": "24.4.1"
29
+ "countly-sdk-web": "24.11.0"
30
30
  },
31
- "gitHead": "7862afda8fdede133cd336663173223a7dbc887a"
31
+ "gitHead": "90e6d034cf6597348e7b03db0f3e29f0b989db19"
32
32
  }