countly-sdk-web 22.2.1 → 22.2.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 22.02.2
2
+ - Fixed a bug where the minified version had issues with the heatmap feature
3
+
1
4
  ## 22.02.1
2
5
  - Fixed a bug where heatmap files were not loading
3
6
 
package/README.md CHANGED
@@ -30,7 +30,7 @@ or
30
30
 
31
31
  Countly web SDK is available on CDNJS. Use either
32
32
 
33
- [https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.02.1/countly.min.js](https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.02.1/countly.min.js)
33
+ [https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.02.2/countly.min.js](https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.02.2/countly.min.js)
34
34
 
35
35
  or
36
36
 
Binary file
package/lib/countly.js CHANGED
@@ -157,7 +157,7 @@
157
157
  */
158
158
  Countly.onload = Countly.onload || [];
159
159
 
160
- var SDK_VERSION = "22.02.1";
160
+ var SDK_VERSION = "22.02.2";
161
161
  var SDK_NAME = "javascript_native_web";
162
162
 
163
163
  var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
@@ -4265,8 +4265,8 @@
4265
4265
  loaded = true;
4266
4266
  };
4267
4267
  if (callback) {
4268
- fileRef.onreadystatechange = callbackFunction();
4269
- fileRef.onload = callbackFunction();
4268
+ fileRef.onreadystatechange = callbackFunction;
4269
+ fileRef.onload = callbackFunction;
4270
4270
  }
4271
4271
  document.getElementsByTagName("head")[0].appendChild(fileRef);
4272
4272
  }
@@ -1,27 +1,27 @@
1
1
  (function(n,ea){"function"===typeof define&&define.amd?define([],function(){return ea(n.Countly)}):"object"===typeof module&&module.exports?module.exports=ea(n.Countly):n.Countly=ea(n.Countly)})("undefined"!==typeof window?window:this,function(n){function ea(h){var r=[];if("undefined"!==typeof h.options)for(var t=0;t<h.options.length;t++)h.options[t].selected&&r.push(h.options[t].value);return r.join(", ")}function Pa(){var h=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
2
2
  function(r){var t=(h+16*Math.random())%16|0;h=Math.floor(h/16);return("x"===r?t:t&3|8).toString(16)})}function C(){return Math.floor((new Date).getTime()/1E3)}function Ba(){var h=(new Date).getTime();pa>=h?pa++:pa=h;return pa}function v(h,r,t){if(r&&Object.keys(r).length){if("undefined"!==typeof r[h])return r[h]}else if("undefined"!==typeof n[h])return n[h];return t}function Ca(h,r,t){for(var z in n.i)n.i[z].tracking_crashes&&n.i[z].recordError(h,r,t)}function Qa(h){var r=[],t;for(t in h)r.push(t+
3
- "="+encodeURIComponent(h[t]));return r.join("&")}function Da(h){return"/"===h.substr(h.length-1)?h.substr(0,h.length-1):h}function ja(h,r){for(var t={},z,I=0;I<r.length;I++)z=r[I],"undefined"!==typeof h[z]&&(t[z]=h[z]);return t}function P(h,r,t,z,I,Q){var W={};if(h){if(Object.keys(h).length>z){var X={},F=0,U;for(U in h)F<z&&(X[U]=h[U],F++);h=X}for(var fa in h)z=w(fa,r,I,Q),X=w(h[fa],t,I,Q),W[z]=X}return W}function w(h,r,t,z){var I=h;"number"===typeof h&&(h=h.toString());"string"===typeof h&&h.length>
3
+ "="+encodeURIComponent(h[t]));return r.join("&")}function Da(h){return"/"===h.substr(h.length-1)?h.substr(0,h.length-1):h}function ja(h,r){for(var t={},z,I=0;I<r.length;I++)z=r[I],"undefined"!==typeof h[z]&&(t[z]=h[z]);return t}function P(h,r,t,z,I,Q){var U={};if(h){if(Object.keys(h).length>z){var X={},F=0,V;for(V in h)F<z&&(X[V]=h[V],F++);h=X}for(var fa in h)z=w(fa,r,I,Q),X=w(h[fa],t,I,Q),U[z]=X}return U}function w(h,r,t,z){var I=h;"number"===typeof h&&(h=h.toString());"string"===typeof h&&h.length>
4
4
  r&&(I=h.substring(0,r),z(g.DEBUG,t+", Key: [ "+h+" ] is longer than accepted length. It will be truncated."));return I}function Ea(h){"undefined"===typeof h.pageY&&"number"===typeof h.clientX&&document.documentElement&&(h.pageX=h.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,h.pageY=h.clientY+document.body.scrollTop+document.documentElement.scrollTop);return h}function qa(){var h=document;return Math.max(Math.max(h.body.scrollHeight,h.documentElement.scrollHeight),Math.max(h.body.offsetHeight,
5
5
  h.documentElement.offsetHeight),Math.max(h.body.clientHeight,h.documentElement.clientHeight))}function Fa(){var h=document;return Math.max(Math.max(h.body.scrollWidth,h.documentElement.scrollWidth),Math.max(h.body.offsetWidth,h.documentElement.offsetWidth),Math.max(h.body.clientWidth,h.documentElement.clientWidth))}function Ra(){var h=document;return Math.min(Math.min(h.body.clientHeight,h.documentElement.clientHeight),Math.min(h.body.offsetHeight,h.documentElement.offsetHeight),window.innerHeight)}
6
- function Sa(h,r,t,z,I,Q){h=document.createElement(h);var W;h.setAttribute(r,t);h.setAttribute(z,I);Q&&(W||Q(),h.onreadystatechange=void 0,h.onload=void 0);document.getElementsByTagName("head")[0].appendChild(h)}function Ta(h,r){Sa("script","type","text/javascript","src",h,r)}function ra(h,r){Sa("link","rel","stylesheet","href",h,r)}function Ua(){var h=document.getElementById("cly-loader");if(!h){var r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type=
7
- "text/css";t.styleSheet?t.styleSheet.cssText="#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}":
6
+ function Sa(h,r,t,z,I,Q){h=document.createElement(h);var U;h.setAttribute(r,t);h.setAttribute(z,I);r=function(){U||Q();U=!0};Q&&(h.onreadystatechange=r,h.onload=r);document.getElementsByTagName("head")[0].appendChild(h)}function Ta(h,r){Sa("script","type","text/javascript","src",h,r)}function ra(h,r){Sa("link","rel","stylesheet","href",h,r)}function Ua(){var h=document.getElementById("cly-loader");if(!h){var r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");
7
+ t.type="text/css";t.styleSheet?t.styleSheet.cssText="#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}":
8
8
  t.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%;}}"));
9
9
  r.appendChild(t);h=document.createElement("div");h.setAttribute("id","cly-loader");document.body.onload=function(){if(!n.showLoaderProtection)try{document.body.appendChild(h)}catch(z){}}}h.style.display="block"}function Va(){n.showLoaderProtection=!0;var h=document.getElementById("cly-loader");h&&(h.style.display="none")}if("undefined"===typeof window)console.error("Not running in browser");else{n=n||{};n.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");
10
10
  var g={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "};n.q=n.q||[];n.onload=n.onload||[];var Wa=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,hb=/(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)/;
11
11
  n.CountlyClass=function(h){function r(a){if(f.ignore_visitor)c(g.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);a.key=w(a.key,f.maxKeyLength,"add_cly_event",c);a.segmentation=P(a.segmentation,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"add_cly_event",c);var b=ja(a,["key","count","sum","dur","segmentation"]);b.timestamp=Ba();var d=new Date;b.hour=d.getHours();b.dow=d.getDay();H.push(b);m("cly_event",H);c(g.INFO,"Successfully adding event: ",
12
12
  a)}else c(g.ERROR,"Adding event failed. Event must have a key property")}function t(){f.ignore_prefetch&&"undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState&&(f.ignore_visitor=!0);f.ignore_bots&&hb.test(navigator.userAgent)&&(f.ignore_visitor=!0)}function z(a,b){if(document.getElementById("countly-feedback-sticker-"+a._id))c(g.ERROR,"Widget with same ID exists");else try{var d=document.createElement("div");d.className="countly-iframe-wrapper";d.id="countly-iframe-wrapper-"+
13
- a._id;var k=document.createElement("span");k.className="countly-feedback-close-icon";k.id="countly-feedback-close-icon-"+a._id;k.innerText="x";var l=document.createElement("iframe");l.name="countly-feedback-iframe";l.id="countly-feedback-iframe";l.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+f.device_id+"&sdk_version=22.02.1";document.body.appendChild(d);d.appendChild(k);d.appendChild(l);x(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+
13
+ a._id;var k=document.createElement("span");k.className="countly-feedback-close-icon";k.id="countly-feedback-close-icon-"+a._id;k.innerText="x";var l=document.createElement("iframe");l.name="countly-feedback-iframe";l.id="countly-feedback-iframe";l.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+f.device_id+"&sdk_version=22.02.2";document.body.appendChild(d);d.appendChild(k);d.appendChild(l);x(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+
14
14
  a._id).style.display="none";document.getElementById("cfbg").style.display="none"});if(b){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.id="feedback-sticker-svg";e.setAttribute("aria-hidden","true");e.setAttribute("data-prefix","far");e.setAttribute("data-icon","grin");e.setAttribute("class","svg-inline--fa fa-grin fa-w-16");e.setAttribute("role","img");e.setAttribute("xmlns","http://www.w3.org/2000/svg");e.setAttribute("viewBox","0 0 496 512");var p=document.createElementNS("http://www.w3.org/2000/svg",
15
15
  "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");
16
16
  var q=document.createElement("span");q.innerText=a.trigger_button_text;var u=document.createElement("div");u.style.color=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;u.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;u.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;u.id="countly-feedback-sticker-"+a._id;e.appendChild(p);u.appendChild(e);u.appendChild(q);document.body.appendChild(u);var A=document.getElementById("smileyPathInStickerSvg");
17
17
  A&&(A.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);x(document.getElementById("countly-feedback-sticker-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block";document.getElementById("cfbg").style.display="block"})}else document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block",document.getElementById("cfbg").style.display="block"}catch(N){c(g.ERROR,"Somethings went wrong while element injecting process: "+
18
- N)}}function I(){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 Q(){if(Y){var a={name:Y};f.check_consent("views")&&r({key:"[CLY]_view",dur:Z?C()-ka:la,segmentation:a});Y=null}}function W(){if(ma){var a=m("cly_session");if(!a||parseInt(a)<=C())R=!1,f.begin_session(!na);m("cly_session",C()+60*Ga)}}function X(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name="javascript_native_web";
19
- a.sdk_version="22.02.1";a.t=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=Ba();var b=new Date;a.hour=b.getHours();a.dow=b.getDay()}function F(a){f.ignore_visitor?c(g.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(X(a),E.length>Xa&&E.shift(),E.push(a),m("cly_queue",E,!0)):c(g.ERROR,"app_key or device_id is missing ",f.app_key,f.device_id)}
20
- function U(){I();if(f.test_mode||f.ignore_visitor)sa=!1,c(g.WARNING,"User opt_out, no heartbeat");else{sa=!0;var a=0;if(ta&&"undefined"!==typeof n.q&&0<n.q.length){var b=n.q;n.q=[];for(a=0;a<b.length;a++){var d=b[a];c(g.DEBUG,"Processing queued call",d);if("function"===typeof d)d();else if(Array.isArray(d)&&0<d.length){var k=f,l=0;n.i[d[l]]&&(k=n.i[d[l]],l++);if("function"===typeof k[d[l]])k[d[l]].apply(k,d.slice(l+1));else if(0===d[l].indexOf("userData.")){var e=d[l].replace("userData.","");"function"===
18
+ N)}}function I(){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 Q(){if(Y){var a={name:Y};f.check_consent("views")&&r({key:"[CLY]_view",dur:Z?C()-ka:la,segmentation:a});Y=null}}function U(){if(ma){var a=m("cly_session");if(!a||parseInt(a)<=C())R=!1,f.begin_session(!na);m("cly_session",C()+60*Ga)}}function X(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name="javascript_native_web";
19
+ a.sdk_version="22.02.2";a.t=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=Ba();var b=new Date;a.hour=b.getHours();a.dow=b.getDay()}function F(a){f.ignore_visitor?c(g.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(X(a),E.length>Xa&&E.shift(),E.push(a),m("cly_queue",E,!0)):c(g.ERROR,"app_key or device_id is missing ",f.app_key,f.device_id)}
20
+ function V(){I();if(f.test_mode||f.ignore_visitor)sa=!1,c(g.WARNING,"User opt_out, no heartbeat");else{sa=!0;var a=0;if(ta&&"undefined"!==typeof n.q&&0<n.q.length){var b=n.q;n.q=[];for(a=0;a<b.length;a++){var d=b[a];c(g.DEBUG,"Processing queued call",d);if("function"===typeof d)d();else if(Array.isArray(d)&&0<d.length){var k=f,l=0;n.i[d[l]]&&(k=n.i[d[l]],l++);if("function"===typeof k[d[l]])k[d[l]].apply(k,d.slice(l+1));else if(0===d[l].indexOf("userData.")){var e=d[l].replace("userData.","");"function"===
21
21
  typeof k.userData[e]&&k.userData[e].apply(k,d.slice(l+1))}else"function"===typeof n[d[l]]&&n[d[l]].apply(n,d.slice(l+1))}}}R&&na&&Z&&(a=C(),a-aa>Ya&&(f.session_duration(a-aa),aa=a));0<H.length&&(H.length<=Ha?(F({events:JSON.stringify(H)}),H=[]):(a=H.splice(0,Ha),F({events:JSON.stringify(a)})),m("cly_event",H));!K&&0<E.length&&ua&&C()>Ia&&(ua=!1,a=E[0],c(g.DEBUG,"Processing request",a),m("cly_queue",E,!0),f.tests||ha("send_request_queue",f.url+Za,a,function(p,q){c(g.DEBUG,"Request Finished",q,p);p?
22
- (Ia=C()+$a,c(g.ERROR,"Request error: ",p)):E.shift();m("cly_queue",E,!0);ua=!0},!1));setTimeout(U,ab)}}function fa(){var a=m("cly_id");return a?(D=m("cly_id_type"),a):Pa()}function va(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=a._app_version||f.app_version;a._ua=a._ua||navigator.userAgent;if(screen.width){var b=screen.width?parseInt(screen.width):0,d=screen.height?parseInt(screen.height):0;if(0!==b&&0!==d){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&window.devicePixelRatio)b=
22
+ (Ia=C()+$a,c(g.ERROR,"Request error: ",p)):E.shift();m("cly_queue",E,!0);ua=!0},!1));setTimeout(V,ab)}}function fa(){var a=m("cly_id");return a?(D=m("cly_id_type"),a):Pa()}function va(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=a._app_version||f.app_version;a._ua=a._ua||navigator.userAgent;if(screen.width){var b=screen.width?parseInt(screen.width):0,d=screen.height?parseInt(screen.height):0;if(0!==b&&0!==d){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&window.devicePixelRatio)b=
23
23
  Math.round(b*window.devicePixelRatio),d=Math.round(d*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var k=b;b=d;d=k}a._resolution=a._resolution||""+b+"x"+d}}window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);b=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof b&&(a._locale=a._locale||b);if("undefined"!==typeof document.referrer&&document.referrer.length&&(b=Wa.exec(document.referrer))&&b[11]&&
24
- b[11]!==window.location.hostname){b=!1;if(V&&V.length)for(d=0;d<V.length;d++)try{if((new RegExp(V[d])).test(document.referrer)){c(g.DEBUG,"Ignored: "+document.referrer);b=!0;break}}catch(l){c(g.ERROR,"Problem with ignoring: "+V[d],", error: "+l)}b||(a._store=a._store||document.referrer)}c(g.DEBUG,"Got metrics",a);return a}function c(a,b){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===typeof arguments[2]&&(arguments[2]=JSON.stringify(arguments[2]));ta||(b="["+f.app_key+"] "+b);
24
+ b[11]!==window.location.hostname){b=!1;if(W&&W.length)for(d=0;d<W.length;d++)try{if((new RegExp(W[d])).test(document.referrer)){c(g.DEBUG,"Ignored: "+document.referrer);b=!0;break}}catch(l){c(g.ERROR,"Problem with ignoring: "+W[d],", error: "+l)}b||(a._store=a._store||document.referrer)}c(g.DEBUG,"Got metrics",a);return a}function c(a,b){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===typeof arguments[2]&&(arguments[2]=JSON.stringify(arguments[2]));ta||(b="["+f.app_key+"] "+b);
25
25
  a||(a=g.DEBUG);for(var d="",k=2;k<arguments.length;k++)d+=arguments[k];d=a+b+d;a===g.ERROR?console.error(d):a===g.WARNING?console.warn(d):a===g.INFO?console.info(d):a===g.VERBOSE?console.log(d):console.debug(d)}}function ha(a,b,d,k,l){l=l||!1;try{c(g.DEBUG,"Sending XML HTTP request");var e=null;window.XMLHttpRequest?e=new window.XMLHttpRequest:window.ActiveXObject&&(e=new window.ActiveXObject("Microsoft.XMLHTTP"));d=d||{};var p=Qa(d),q="GET";if(f.force_post||2E3<=p.length)q="POST";"GET"===q?e.open("GET",
26
26
  b+"?"+p,!0):(e.open("POST",b,!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"));for(var u in f.headers)e.setRequestHeader(u,f.headers[u]);e.onreadystatechange=function(){4===this.readyState&&(c(g.DEBUG,a+" HTTP request completed ["+this.status+"]["+this.responseText+"]"),(l?bb(this.status,this.responseText):cb(this.status,this.responseText))?"function"===typeof k&&k(!1,d,this.responseText):(c(g.ERROR,a+" Failed Server XML HTTP request, ",this.status),"function"===typeof k&&
27
27
  k(!0,d)))};"GET"===q?e.send():e.send(p)}catch(A){c(g.ERROR,a+" Failed XML HTTP request: "+A),"function"===typeof k&&k(!0,d)}}function cb(a,b){if(!(200<=a&&300>a))return c(g.ERROR,"Http response status code is not within the expected range: "+a),!1;try{var d=JSON.parse(b);return"[object Object]"!==Object.prototype.toString.call(d)?(c(g.ERROR,"Http response is not JSON Object"),!1):!!d.result}catch(k){return c(g.ERROR,"Http response is not JSON: "+k),!1}}function bb(a,b){if(!(200<=a&&300>a))return c(g.ERROR,
@@ -29,18 +29,18 @@ k(!0,d)))};"GET"===q?e.send():e.send(p)}catch(A){c(g.ERROR,a+" Failed XML HTTP r
29
29
  "=";for(var u=document.cookie.split(";"),A=0,N=u.length;A<N;A++){for(var G=u[A];" "===G.charAt(0);)G=G.substring(1,G.length);if(0===G.indexOf(q))return G.substring(q.length,G.length)}return null}if("none"===f.storage)c(g.WARNING,"Storage is disabled. Value with key: "+a+" won't be stored or retrieved");else{k||(a=f.app_key+"/"+a,f.namespace&&(a=Da(f.namespace)+"/"+a));d=d||"localstorage"===f.storage;var p;"undefined"!==typeof b&&null!==b&&(b=f.serialize(b),ba?localStorage.setItem(a,b):d||l(a,b,30));
30
30
  if("undefined"===typeof b)return ba?p=localStorage.getItem(a):d||(p=e(a)),f.deserialize(p);null===b&&(ba?localStorage.removeItem(a):d||l(a,"",-1))}}function ib(){if(m(f.namespace+"cly_id",void 0,!1,!0)){m("cly_id",m(f.namespace+"cly_id",void 0,!1,!0));m("cly_id_type",m(f.namespace+"cly_id_type",void 0,!1,!0));m("cly_event",m(f.namespace+"cly_event",void 0,!1,!0));m("cly_session",m(f.namespace+"cly_session",void 0,!1,!0));var a=m(f.namespace+"cly_queue",void 0,!1,!0);Array.isArray(a)&&(a=a.filter(function(b){return b.app_key===
31
31
  f.app_key}),m("cly_queue",a));m(f.namespace+"cly_cmp_id",void 0,!1,!0)&&(m("cly_cmp_id",m(f.namespace+"cly_cmp_id",void 0,!1,!0)),m("cly_cmp_uid",m(f.namespace+"cly_cmp_uid",void 0,!1,!0)));m(f.namespace+"cly_ignore",void 0,!1,!0)&&m("cly_ignore",m(f.namespace+"cly_ignore",void 0,!1,!0));m("cly_id",null,!1,!0);m("cly_id_type",null,!1,!0);m("cly_event",null,!1,!0);m("cly_session",null,!1,!0);m("cly_queue",null,!1,!0);m("cly_cmp_id",null,!1,!0);m("cly_cmp_uid",null,!1,!0);m("cly_ignore",null,!1,!0)}}
32
- var f=this,ta=!n.i,R=!1,Za="/i",Ja="/o/sdk",ab=v("interval",h,500),Xa=v("queue_size",h,1E3),E=[],H=[],L={},ca=[],da={},V=v("ignore_referrers",h,[]),Ka=null,na=!0,aa,La=0,Y=null,ka=0,la=0,Ia=0,$a=v("fail_timeout",h,60),Ma=v("inactivity_time",h,20),oa=0,Ya=v("session_update",h,60),Ha=v("max_events",h,100),wa=v("max_logs",h,null),ma=v("use_session_cookie",h,!0),Ga=v("session_cookie_timeout",h,30),ua=!0,sa=!1,K=v("offline_mode",h,!1),S={},Z=!0,eb=C(),ba=!0,ia=null,D=1;try{localStorage.setItem("cly_testLocal",
32
+ var f=this,ta=!n.i,R=!1,Za="/i",Ja="/o/sdk",ab=v("interval",h,500),Xa=v("queue_size",h,1E3),E=[],H=[],L={},ca=[],da={},W=v("ignore_referrers",h,[]),Ka=null,na=!0,aa,La=0,Y=null,ka=0,la=0,Ia=0,$a=v("fail_timeout",h,60),Ma=v("inactivity_time",h,20),oa=0,Ya=v("session_update",h,60),Ha=v("max_events",h,100),wa=v("max_logs",h,null),ma=v("use_session_cookie",h,!0),Ga=v("session_cookie_timeout",h,30),ua=!0,sa=!1,K=v("offline_mode",h,!1),S={},Z=!0,eb=C(),ba=!0,ia=null,D=1;try{localStorage.setItem("cly_testLocal",
33
33
  !0),localStorage.removeItem("cly_testLocal")}catch(a){c(g.ERROR,"Local storage test failed, Halting local storage support: "+a),ba=!1}for(var B={},Na=0;Na<n.features.length;Na++)B[n.features[Na]]={};this.initialize=function(){this.serialize=h.serialize||n.serialize;this.deserialize=h.deserialize||n.deserialize;this.getViewName=h.getViewName||n.getViewName;this.getViewUrl=h.getViewUrl||n.getViewUrl;this.getSearchQuery=h.getSearchQuery||n.getSearchQuery;this.DeviceIdType=n.DeviceIdType;this.namespace=
34
34
  v("namespace",h,"");this.clearStoredId=v("clear_stored_id",h,!1);this.app_key=v("app_key",h,null);this.onload=v("onload",h,[]);this.utm=v("utm",h,{source:!0,medium:!0,campaign:!0,term:!0,content:!0});this.ignore_prefetch=v("ignore_prefetch",h,!0);this.debug=v("debug",h,!1);this.test_mode=v("test_mode",h,!1);this.tests=v("tests",h,!1);this.metrics=v("metrics",h,{});this.headers=v("headers",h,{});this.url=Da(v("url",h,""));this.app_version=v("app_version",h,"0.0");this.country_code=v("country_code",
35
35
  h,null);this.city=v("city",h,null);this.ip_address=v("ip_address",h,null);this.ignore_bots=v("ignore_bots",h,!0);this.force_post=v("force_post",h,!1);this.remote_config=v("remote_config",h,!1);this.ignore_visitor=v("ignore_visitor",h,!1);this.require_consent=v("require_consent",h,!1);this.track_domains=v("track_domains",h,!0);this.storage=v("storage",h,"default");this.enableOrientationTracking=v("enable_orientation_tracking",h,!0);this.maxKeyLength=v("max_key_length",h,128);this.maxValueSize=v("max_value_size",
36
36
  h,256);this.maxSegmentationValues=v("max_segmentation_values",h,30);this.maxBreadcrumbCount=v("max_breadcrumb_count",h,null);this.maxStackTraceLinesPerThread=v("max_stack_trace_lines_per_thread",h,30);this.maxStackTraceLineLength=v("max_stack_trace_line_length",h,200);wa&&!this.maxBreadcrumbCount?(this.maxBreadcrumbCount=wa,c(g.WARNING,"initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!")):wa||this.maxBreadcrumbCount||(this.maxBreadcrumbCount=100);"cookie"===this.storage&&
37
- (ba=!1);Array.isArray(V)||(V=[]);""===this.url&&(c(g.ERROR,"initialize, Please provide server URL"),this.ignore_visitor=!0);m("cly_ignore")&&(this.ignore_visitor=!0);ib();this.clearStoredId&&(c(g.INFO,"initialize, Clearing the device ID storage"),localStorage.removeItem(this.app_key+"/cly_id"),localStorage.removeItem(this.app_key+"/cly_id_type"));E=m("cly_queue")||[];H=m("cly_event")||[];L=m("cly_remote_configs")||{};t();if(window.name&&0===window.name.indexOf("cly:"))try{this.passed_data=JSON.parse(window.name.replace("cly:",
37
+ (ba=!1);Array.isArray(W)||(W=[]);""===this.url&&(c(g.ERROR,"initialize, Please provide server URL"),this.ignore_visitor=!0);m("cly_ignore")&&(this.ignore_visitor=!0);ib();this.clearStoredId&&(c(g.INFO,"initialize, Clearing the device ID storage"),localStorage.removeItem(this.app_key+"/cly_id"),localStorage.removeItem(this.app_key+"/cly_id_type"));E=m("cly_queue")||[];H=m("cly_event")||[];L=m("cly_remote_configs")||{};t();if(window.name&&0===window.name.indexOf("cly:"))try{this.passed_data=JSON.parse(window.name.replace("cly:",
38
38
  ""))}catch(q){c(g.ERROR,"initialize, Could not parse name: "+window.name+", error: "+q)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{this.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(q){c(g.ERROR,"initialize, Could not parse hash: "+location.hash+", error: "+q)}(this.passed_data&&this.passed_data.app_key&&this.passed_data.app_key===this.app_key||this.passed_data&&!this.passed_data.app_key&&ta)&&this.passed_data.token&&this.passed_data.purpose&&(this.passed_data.token!==
39
39
  m("cly_old_token")&&(db(this.passed_data.token),m("cly_old_token",this.passed_data.token)),this.passed_data.url=this.passed_data.url||this.url,"heatmap"===this.passed_data.purpose&&(this.ignore_visitor=!0,Ua(),Ta(this.passed_data.url+"/views/heatmap.js",Va)));if(this.ignore_visitor)c(g.WARNING,"initialize, Ignoring this visitor");else{var a=null;c(g.INFO,"initialize, Countly initialized");var b=f.getSearchQuery(),d=!1,k={};if(b){b=b.substring(1).split("&");for(var l=0;l<b.length;l++){var e=b[l].split("=");
40
40
  "cly_id"===e[0]?m("cly_cmp_id",e[1]):"cly_uid"===e[0]?m("cly_cmp_uid",e[1]):"cly_device_id"===e[0]?a=e[1]:0===(e[0]+"").indexOf("utm_")&&this.utm[e[0].replace("utm_","")]&&(k[e[0].replace("utm_","")]=e[1],d=!0)}}b="[CLY]_temp_id"===m("cly_id");l=v("device_id",h,void 0);m("cly_id")&&!b?(this.device_id=m("cly_id"),c(g.INFO,"initialize, Set the stored device ID"),D=m("cly_id_type"),D||(c(g.INFO,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"),D=0)):
41
41
  null!==a?(c(g.INFO,"initialize, Device ID set by URL"),this.device_id=a,D=3):l?(c(g.INFO,"initialize, Device ID set by developer"),this.device_id=l,h&&Object.keys(h).length?void 0!==h.device_id&&(D=0):void 0!==n.device_id&&(D=0)):K||b?(this.device_id="[CLY]_temp_id",D=2,K&&b?c(g.INFO,"initialize, Temp ID set, continuing offline mode from previous app session"):K&&!b?c(g.INFO,"initialize, Temp ID set, entering offline mode"):(K=!0,c(g.INFO,"initialize, Temp ID set, enabling offline mode"))):(c(g.INFO,
42
- "initialize, Generating the device ID"),this.device_id=v("device_id",h,fa()),h&&Object.keys(h).length?void 0!==h.device_id&&(D=0):void 0!==n.device_id&&(D=0));m("cly_id",this.device_id);m("cly_id_type",D);if(d){for(var p in this.utm)k[p]?this.userData.set("utm_"+p,k[p]):this.userData.unset("utm_"+p);this.userData.save()}I();setTimeout(function(){U();f.remote_config&&f.fetch_remote_config(f.remote_config)},1);document.documentElement.setAttribute("data-countly-useragent",navigator.userAgent)}};this.halt=
43
- function(){c(g.WARNING,"halt, Resetting Countly");n.i=void 0;ta=!n.i;R=!1;Za="/i";Ja="/o/sdk";ab=500;Xa=1E3;E=[];H=[];L={};ca=[];da={};V=[];Ka=null;na=!0;La=0;Y=null;Ia=la=ka=0;$a=60;Ma=20;oa=0;Ya=60;Ha=100;wa=null;ma=!0;Ga=30;ua=!0;K=sa=!1;S={};Z=!0;eb=C();ba=!0;ia=null;D=1;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(b){ba=!1}n.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");
42
+ "initialize, Generating the device ID"),this.device_id=v("device_id",h,fa()),h&&Object.keys(h).length?void 0!==h.device_id&&(D=0):void 0!==n.device_id&&(D=0));m("cly_id",this.device_id);m("cly_id_type",D);if(d){for(var p in this.utm)k[p]?this.userData.set("utm_"+p,k[p]):this.userData.unset("utm_"+p);this.userData.save()}I();setTimeout(function(){V();f.remote_config&&f.fetch_remote_config(f.remote_config)},1);document.documentElement.setAttribute("data-countly-useragent",navigator.userAgent)}};this.halt=
43
+ function(){c(g.WARNING,"halt, Resetting Countly");n.i=void 0;ta=!n.i;R=!1;Za="/i";Ja="/o/sdk";ab=500;Xa=1E3;E=[];H=[];L={};ca=[];da={};W=[];Ka=null;na=!0;La=0;Y=null;Ia=la=ka=0;$a=60;Ma=20;oa=0;Ya=60;Ha=100;wa=null;ma=!0;Ga=30;ua=!0;K=sa=!1;S={};Z=!0;eb=C();ba=!0;ia=null;D=1;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(b){ba=!1}n.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");
44
44
  B={};for(var a=0;a<n.features.length;a++)B[n.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.tests=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.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=
45
45
  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){c(g.INFO,"group_features, Grouping features");if(a)for(var b in a)B[b]?c(g.WARNING,"group_features, Feature name ["+b+"] is already reserved"):"string"===typeof a[b]?B[b]={features:[a[b]]}:a[b]&&Array.isArray(a[b])&&a[b].length?B[b]={features:a[b]}:c(g.ERROR,"group_features, Incorrect feature list for ["+
46
46
  b+"] value: ["+a[b]+"]");else c(g.ERROR,"group_features, Incorrect features:["+a+"]")};this.check_consent=function(a){c(g.INFO,"check_consent, Checking if consent is given for specific feature");if(!this.require_consent)return c(g.INFO,"check_consent, require_consent is off, no consent is necessary"),!0;if(B[a])return!(!B[a]||!B[a].optin);c(g.ERROR,"check_consent, No feature available for ["+a+"]");return!1};this.get_device_id_type=function(){c(g.INFO,"check_device_id_type, Retrieving the current device id type.["+
@@ -50,7 +50,7 @@ D+"]");switch(D){case 1:var a=f.DeviceIdType.SDK_GENERATED;break;case 3:case 0:a
50
50
  fb()):c(g.ERROR,"remove_consent, No feature available for ["+a+"]")};var xa,fb=function(){xa&&(clearTimeout(xa),xa=null);xa=setTimeout(function(){for(var a={},b=0;b<n.features.length;b++)a[n.features[b]]=!0===B[n.features[b]].optin?!0:!1;F({consent:JSON.stringify(a)});c(g.DEBUG,"Consent update request has been sent to the queue.")},1E3)};this.enable_offline_mode=function(){c(g.INFO,"enable_offline_mode, Enabling offline mode");this.remove_consent_internal(n.features,!1);K=!0;this.device_id="[CLY]_temp_id";
51
51
  D=2};this.disable_offline_mode=function(a){c(g.INFO,"disable_offline_mode, Disabling offline mode");K=!1;a&&this.device_id!==a?(this.device_id=a,D=0,m("cly_id",this.device_id),m("cly_id_type",0),c(g.INFO,"disable_offline_mode, Changing id to: "+this.device_id)):(this.device_id=fa(),this.device_id!==m("cly_id")&&(m("cly_id",this.device_id),m("cly_id_type",1)));a=!1;if(0<E.length)for(var b=0;b<E.length;b++)"[CLY]_temp_id"===E[b].device_id&&(E[b].device_id=this.device_id,a=!0);a&&m("cly_queue",E,!0)};
52
52
  this.begin_session=function(a,b){c(g.INFO,"begin_session, Starting the session");a&&c(g.INFO,"begin_session, Heartbeats are disabled");b&&c(g.INFO,"begin_session, Session starts irrespective of session cookie");if(this.check_consent("sessions")){if(!R){this.enableOrientationTracking&&(this.report_orientation(),x(window,"resize",function(){f.report_orientation()}));aa=C();R=!0;na=!a;var d=m("cly_session");if(b||!ma||!d||parseInt(d)<=C())c(g.INFO,"begin_session, Session started"),null===ia&&(ia=!0),
53
- d={begin_session:1},d.metrics=JSON.stringify(va()),F(d);m("cly_session",C()+60*Ga)}}else S.begin_session=arguments};this.session_duration=function(a){c(g.INFO,"session_duration, Reporting session duration");this.check_consent("sessions")&&R&&(c(g.INFO,"session_duration, Session extended",a),F({session_duration:a}),W())};this.end_session=function(a,b){c(g.INFO,"end_session, Ending the current session");this.check_consent("sessions")&&R&&(a=a||C()-aa,Q(),!ma||b?(c(g.INFO,"end_session, Session ended"),
53
+ d={begin_session:1},d.metrics=JSON.stringify(va()),F(d);m("cly_session",C()+60*Ga)}}else S.begin_session=arguments};this.session_duration=function(a){c(g.INFO,"session_duration, Reporting session duration");this.check_consent("sessions")&&R&&(c(g.INFO,"session_duration, Session extended",a),F({session_duration:a}),U())};this.end_session=function(a,b){c(g.INFO,"end_session, Ending the current session");this.check_consent("sessions")&&R&&(a=a||C()-aa,Q(),!ma||b?(c(g.INFO,"end_session, Session ended"),
54
54
  F({end_session:1,session_duration:a})):this.session_duration(a),R=!1)};this.change_id=function(a,b){c(g.INFO,"change_id, Changing the ID");b&&c(g.INFO,"change_id, Will merge the IDs");if(!a||"string"!==typeof a||0===a.length)c(g.ERROR,"change_id, The provided ID: ["+a+"] is not a valid ID");else if(K)c(g.WARNING,"change_id, Offline mode was on, initiating disabling sequence instead."),this.disable_offline_mode(a);else if(this.device_id!==a){b||(0<H.length&&(F({events:JSON.stringify(H)}),H=[],m("cly_event",
55
55
  H)),this.end_session(null,!0),da={},this.remove_consent_internal(n.features,!1));var d=this.device_id;this.device_id=a;D=0;m("cly_id",this.device_id);m("cly_id_type",0);c(g.INFO,"change_id, Changing ID");b?F({old_device_id:d}):this.begin_session(!na,!0);this.remote_config&&(L={},m("cly_remote_configs",L),this.fetch_remote_config(this.remote_config))}};this.add_event=function(a){c(g.INFO,"add_event, Adding event: ",a);switch(a.key){case "[CLY]_nps":var b=this.check_consent("feedback");break;case "[CLY]_survey":b=
56
56
  this.check_consent("feedback");break;case "[CLY]_star_rating":b=this.check_consent("star-rating");break;case "[CLY]_view":b=this.check_consent("views");break;case "[CLY]_orientation":b=this.check_consent("users");break;case "[CLY]_push_action":b=this.check_consent("push");break;case "[CLY]_action":b=this.check_consent("clicks")||this.check_consent("scroll");break;default:b=this.check_consent("events")}b&&r(a)};this.start_event=function(a){c(g.INFO,"start_event, Starting timed event with key: ["+a+
@@ -68,7 +68,7 @@ d=0;d<b.length;d++)if("apm_attr"!==b[d]&&"undefined"===typeof a[b[d]]){c(g.WARNI
68
68
  A)}Ca(p,!1)}},window.addEventListener("unhandledrejection",function(d){Ca(Error("Unhandled rejection (reason: "+(d.reason&&d.reason.stack?d.reason.stack:d.reason)+")."),!0)}))};this.log_error=function(a,b){c(g.INFO,"log_error, Logging errors");this.recordError(a,!0,b)};this.add_log=function(a){c(g.INFO,"add_log, Adding a new log of breadcrumbs: [ "+a+" ]");if(this.check_consent("crashes")){for(a=w(a,f.maxValueSize,"add_log",c);ca.length>=f.maxBreadcrumbCount;)ca.shift(),c(g.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one.");
69
69
  ca.push(a)}};this.fetch_remote_config=function(a,b,d){c(g.INFO,"fetch_remote_config, Fetching remote config");if(this.check_consent("remote-config")){var k={method:"fetch_remote_config"};this.check_consent("sessions")&&(k.metrics=JSON.stringify(va()));a&&(d||"function"!==typeof a?Array.isArray(a)&&a.length&&(c(g.INFO,"fetch_remote_config, Keys to fetch: [ "+a+" ]"),k.keys=JSON.stringify(a)):(d=a,a=null));b&&((c(g.INFO,"fetch_remote_config, Keys to omit: [ "+b+" ]"),d||"function"!==typeof b)?Array.isArray(b)&&
70
70
  b.length&&(k.omit_keys=JSON.stringify(b)):(d=b,b=null));X(k);ha("fetch_remote_config",this.url+Ja,k,function(l,e,p){if(l)c(g.ERROR,"fetch_remote_config, An error occurred: "+l);else{try{var q=JSON.parse(p);if(k.keys||k.omit_keys)for(var u in q)L[u]=q[u];else L=q;m("cly_remote_configs",L)}catch(A){c(g.ERROR,"fetch_remote_config, Had an issue while parsing the response: "+A)}"function"===typeof d&&(c(g.INFO,"fetch_remote_config, Callback function is provided"),d(l,L))}},!0)}else c(g.ERROR,"fetch_remote_config, Remote config requires explicit consent"),
71
- "function"===typeof d&&d(Error("Remote config requires explicit consent"),L)};this.get_remote_config=function(a){c(g.INFO,"get_remote_config, Getting remote config");return"undefined"!==typeof a?L[a]:L};this.stop_time=function(){c(g.INFO,"stop_time, Stopping tracking duration");Z&&(Z=!1,La=C()-aa,la=C()-ka)};this.start_time=function(){c(g.INFO,"start_time, Starting tracking duration");Z||(Z=!0,aa=C()-La,ka=C()-la,la=0,W())};this.track_sessions=function(){function a(){document[d]||!document.hasFocus()?
71
+ "function"===typeof d&&d(Error("Remote config requires explicit consent"),L)};this.get_remote_config=function(a){c(g.INFO,"get_remote_config, Getting remote config");return"undefined"!==typeof a?L[a]:L};this.stop_time=function(){c(g.INFO,"stop_time, Stopping tracking duration");Z&&(Z=!1,La=C()-aa,la=C()-ka)};this.start_time=function(){c(g.INFO,"start_time, Starting tracking duration");Z||(Z=!0,aa=C()-La,ka=C()-la,la=0,U())};this.track_sessions=function(){function a(){document[d]||!document.hasFocus()?
72
72
  f.stop_time():f.start_time()}function b(){oa>=Ma&&f.start_time();oa=0}c(g.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();x(window,"beforeunload",function(){f.end_session()});var d="hidden";x(window,"focus",a);x(window,"blur",a);x(window,"pageshow",a);x(window,"pagehide",a);"onfocusin"in document&&(x(window,"focusin",a),x(window,"focusout",a));d in document?document.addEventListener("visibilitychange",a):"mozHidden"in document?(d="mozHidden",document.addEventListener("mozvisibilitychange",
73
73
  a)):"webkitHidden"in document?(d="webkitHidden",document.addEventListener("webkitvisibilitychange",a)):"msHidden"in document&&(d="msHidden",document.addEventListener("msvisibilitychange",a));x(window,"mousemove",b);x(window,"click",b);x(window,"keydown",b);x(window,"scroll",b);setInterval(function(){oa++;oa>=Ma&&f.stop_time()},6E4)};this.track_pageview=function(a,b,d){c(g.INFO,"track_pageview, Starting to track page views");Q();a=w(a,f.maxKeyLength,"track_pageview",c);d=P(d,f.maxKeyLength,f.maxValueSize,
74
74
  f.maxSegmentationValues,"track_pageview",c);a&&Array.isArray(a)&&(b=a,a=null);a||(a=this.getViewName());if(void 0===a||""===a)c(g.ERROR,"track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked.");else if(null===a)c(g.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(b&&b.length)for(var k=0;k<b.length;k++)try{if((new RegExp(b[k])).test(a)){c(g.INFO,"track_pageview, Ignoring the page: "+a);return}}catch(p){c(g.ERROR,
@@ -86,7 +86,7 @@ e.type.toLowerCase()?e.checked&&(q=e.value):q=e.value:q=e.value:"textarea"===e.n
86
86
  -1!==e.id.toLowerCase().indexOf("phone")||-1!==e.id.toLowerCase().indexOf("number"))||e.id&&p[e.id]&&(-1!==p[e.id].toLowerCase().indexOf("tel")||-1!==p[e.id].toLowerCase().indexOf("phone")||-1!==p[e.id].toLowerCase().indexOf("number")))k.phone||(k.phone=q),l=!0;else if(e.name&&(-1!==e.name.toLowerCase().indexOf("org")||-1!==e.name.toLowerCase().indexOf("company"))||e.id&&(-1!==e.id.toLowerCase().indexOf("org")||-1!==e.id.toLowerCase().indexOf("company"))||e.id&&p[e.id]&&(-1!==p[e.id].toLowerCase().indexOf("org")||
87
87
  -1!==p[e.id].toLowerCase().indexOf("company")))k.organization||(k.organization=q),l=!0;else if(e.name&&-1!==e.name.toLowerCase().indexOf("name")||e.id&&-1!==e.id.toLowerCase().indexOf("name")||e.id&&p[e.id]&&-1!==p[e.id].toLowerCase().indexOf("name"))k.name||(k.name=""),k.name+=q+" ",l=!0}l&&(c(g.INFO,"collect_from_forms, Gathered user data",k),b?f.user_details({custom:k}):f.user_details(k))})};this.collect_from_facebook=function(a){c(g.INFO,"collect_from_facebook, Starting to collect possible user data");
88
88
  FB&&FB.api&&FB.api("/me",function(b){var d={};b.name&&(d.name=b.name);b.email&&(d.email=b.email);"male"===b.gender?d.gender="M":"female"===b.gender&&(d.gender="F");if(b.birthday){var k=b.birthday.split("/").pop();k&&4===k.length&&(d.byear=k)}b.work&&b.work[0]&&b.work[0].employer&&b.work[0].employer.name&&(d.organization=b.work[0].employer.name);if(a){d.custom={};for(var l in a){k=a[l].split(".");for(var e=b,p=0;p<k.length&&(e=e[k[p]],"undefined"!==typeof e);p++);"undefined"!==typeof e&&(d.custom[l]=
89
- e)}}f.user_details(d)})};this.opt_out=function(){c(g.INFO,"opt_out, Opting out the user");this.ignore_visitor=!0;m("cly_ignore",!0)};this.opt_in=function(){c(g.INFO,"opt_in, Opting in the user");m("cly_ignore",!1);this.ignore_visitor=!1;t();this.ignore_visitor||sa||U()};this.report_feedback=function(a){c(g.WARNING,"report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' in place of this call. Call will be redirected now!");this.recordRatingWidgetWithID(a)};this.recordRatingWidgetWithID=
89
+ e)}}f.user_details(d)})};this.opt_out=function(){c(g.INFO,"opt_out, Opting out the user");this.ignore_visitor=!0;m("cly_ignore",!0)};this.opt_in=function(){c(g.INFO,"opt_in, Opting in the user");m("cly_ignore",!1);this.ignore_visitor=!1;t();this.ignore_visitor||sa||V()};this.report_feedback=function(a){c(g.WARNING,"report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' in place of this call. Call will be redirected now!");this.recordRatingWidgetWithID(a)};this.recordRatingWidgetWithID=
90
90
  function(a){c(g.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 b={key:"[CLY]_star_rating",count:1,segmentation:{}};b.segmentation=ja(a,"widget_id contactMe platform app_version rating email comment".split(" "));b.segmentation.app_version||(b.segmentation.app_version=this.metrics._app_version||this.app_version);c(g.INFO,"recordRatingWidgetWithID, Reporting Rating Widget: ",b);r(b)}else c(g.ERROR,
91
91
  "recordRatingWidgetWithID, Rating Widget must contain rating property");else c(g.ERROR,"recordRatingWidgetWithID, Rating Widget must contain widget_id property")};this.show_feedback_popup=function(a){c(g.WARNING,"show_feedback_popup, Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!");this.presentRatingWidgetWithID(a)};this.presentRatingWidgetWithID=function(a){c(g.INFO,"presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ "+
92
92
  a+" ]");this.check_consent("star-rating")&&(K?c(g.ERROR,"presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"):ha("presentRatingWidgetWithID",this.url+"/o/feedback/widget",{widget_id:a},function(b,d,k){if(b)c(g.ERROR,"presentRatingWidgetWithID, An error occurred: "+b);else try{var l=JSON.parse(k);z(l,!1)}catch(e){c(g.ERROR,"presentRatingWidgetWithID, JSON parse failed: "+e)}},!0))};this.initialize_feedback_popups=function(a){c(g.WARNING,"initialize_feedback_popups, Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!");
@@ -99,7 +99,7 @@ e),a&&a(null,e)}},!1):a&&a(null,Error("Consent for feedback not provided."))};th
99
99
  "#"+y.appearance.text_color:y.appearance.text_color;M.style.backgroundColor=7>y.appearance.bg_color.length?"#"+y.appearance.bg_color:y.appearance.bg_color;M.className="countly-feedback-sticker "+y.appearance.position+"-"+y.appearance.size;M.id="countly-feedback-sticker-"+y._id;document.body.appendChild(M);x(document.getElementById("countly-feedback-sticker-"+y._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+y._id).style.display="flex";document.getElementById("csbg").style.display=
100
100
  "block"})}x(document.getElementById("countly-feedback-close-icon-"+y._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+y._id).style.display="none";document.getElementById("csbg").style.display="none"})}c(g.INFO,"present_feedback_widget, Presenting the feedback widget by appending to the element with ID: [ "+b+" ] and className: [ "+d+" ]");if(this.check_consent("feedback"))if(!a||"object"!==typeof a||Array.isArray(a))c(g.ERROR,"present_feedback_widget, Please provide at least one feedback widget object.");
101
101
  else try{var e=this.url;if("nps"===a.type)c(g.DEBUG,"present_feedback_widget, Widget type: nps."),e+="/feedback/nps";else if("survey"===a.type)c(g.DEBUG,"present_feedback_widget, Widget type: survey."),e+="/feedback/survey";else if("rating"===a.type)c(g.DEBUG,"present_feedback_widget, Widget type: rating."),e+="/feedback/rating";else{c(g.ERROR,"present_feedback_widget, Feedback widget only accepts nps, rating and survey types.");return}var p=window.origin||window.location.origin;if("rating"===a.type){c(g.DEBUG,
102
- "present_feedback_widget, Loading css for rating widget.");var q="ratings";ra(this.url+"/star-rating/stylesheets/countly-feedback-web.css")}else c(g.DEBUG,"present_feedback_widget, Loading css for survey or nps."),ra(this.url+"/surveys/stylesheets/countly-surveys.css"),q="surveys";e+="?widget_id="+a._id;e+="&app_key="+this.app_key;e+="&device_id="+this.device_id;e+="&sdk_name=javascript_native_web";e+="&platform="+this.platform;e+="&app_version="+this.app_version;e+="&sdk_version=22.02.1";e+="&origin="+
102
+ "present_feedback_widget, Loading css for rating widget.");var q="ratings";ra(this.url+"/star-rating/stylesheets/countly-feedback-web.css")}else c(g.DEBUG,"present_feedback_widget, Loading css for survey or nps."),ra(this.url+"/surveys/stylesheets/countly-surveys.css"),q="surveys";e+="?widget_id="+a._id;e+="&app_key="+this.app_key;e+="&device_id="+this.device_id;e+="&sdk_name=javascript_native_web";e+="&platform="+this.platform;e+="&app_version="+this.app_version;e+="&sdk_version=22.02.2";e+="&origin="+
103
103
  p;e+="&widget_v=web";var u=document.createElement("iframe");u.src=e;u.name="countly-"+q+"-iframe";u.id="countly-"+q+"-iframe";var A=!1;u.onload=function(){A&&(document.getElementById("countly-"+q+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none");A=!0;c(g.DEBUG,"present_feedback_widget, Loaded iframe.")};for(var N=document.getElementById("csbg");N;)N.remove(),N=document.getElementById("csbg"),c(g.DEBUG,"present_feedback_widget, Removing past overlay.");var G=
104
104
  document.getElementsByClassName("countly-"+q+"-wrapper");for(e=0;e<G.length;e++)G[e].remove(),c(g.DEBUG,"present_feedback_widget, Removed a wrapper.");G=document.createElement("div");G.className="countly-"+q+"-wrapper";G.id="countly-"+q+"-wrapper-"+a._id;"survey"===a.type&&(G.className=G.className+" "+a.appearance.position);var za=document.body;e=!1;b&&(document.getElementById(b)?(za=document.getElementById(b),e=!0):c(g.ERROR,"present_feedback_widget, Provided ID not found."));e||d&&(document.getElementsByClassName(d)[0]?
105
105
  za=document.getElementsByClassName(d)[0]:c(g.ERROR,"present_feedback_widget, Provided class not found."));za.insertAdjacentHTML("beforeend",'<div id="csbg"></div>');za.appendChild(G);if("rating"===a.type){var Oa=document.createElement("div");Oa.className="countly-ratings-overlay";Oa.id="countly-ratings-overlay-"+a._id;G.appendChild(Oa);c(g.DEBUG,"present_feedback_widget, appended the rating overlay to wrapper");x(document.getElementById("countly-ratings-overlay-"+a._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+
@@ -111,7 +111,7 @@ function(y){"complete"!==y.target.readyState||Aa||(Aa=!0,l(a))})}}catch(y){c(g.E
111
111
  (k[a]=k[a].substring(0,f.maxStackTraceLineLength));k=k.join("\n")}b=!!b;a=va();k={_resolution:a._resolution,_error:k,_app_version:a._app_version,_run:C()-eb,_not_os_specific:!0,_javascript:!0};if(a=navigator.battery||navigator.webkitBattery||navigator.mozBattery||navigator.msBattery)k._bat=Math.floor(100*a.level);"undefined"!==typeof navigator.onLine&&(k._online=!!navigator.onLine);k._background=!document.hasFocus();0<ca.length&&(k._logs=ca.join("\n"));ca=[];k._nonfatal=b;k._view=this.getViewName();
112
112
  "undefined"!==typeof d&&(k._custom=d);try{var e=document.createElement("canvas").getContext("experimental-webgl");k._opengl=e.getParameter(e.VERSION)}catch(p){c(g.ERROR,"Could not get the experimental-webgl context: "+p)}F({crash:JSON.stringify(k)})}};this.onStorageChange=function(a,b){c(g.INFO,"onStorageChange, Applying storage changes");switch(a){case "cly_queue":E=f.deserialize(b||"[]");break;case "cly_event":H=f.deserialize(b||"[]");break;case "cly_remote_configs":L=f.deserialize(b||"{}");break;
113
113
  case "cly_ignore":f.ignore_visitor=f.deserialize(b);break;case "cly_id":f.device_id=f.deserialize(b);break;case "cly_id_type":D=f.deserialize(b)}};this._internals={store:m,getDocWidth:Fa,getDocHeight:qa,getViewportHeight:Ra,get_page_coord:Ea,get_event_target:ya,add_event:x,getProperties:ja,truncateObject:P,truncateSingleValue:w,stripTrailingSlash:Da,prepareParams:Qa,sendXmlHttpRequest:ha,isResponseValid:cb,getInternalDeviceIdType:function(){return D},getMsTimestamp:Ba,getTimestamp:C,isResponseValidBroad:bb,
114
- log:c,getMetrics:va,generateUUID:Pa,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)},getId:fa,heartBeat:U,toRequestQueue:F,reportViewDuration:Q,loadJS:Ta,loadCSS:ra,getLastView:function(){return Y},setToken:db,getToken:function(){var a=m("cly_token");m("cly_token",null);return a},showLoader:Ua,hideLoader:Va,add_cly_events:r,detect_device:gb,getRequestQueue:function(){return E},getEventQueue:function(){return H},clearQueue:function(){E=
114
+ log:c,getMetrics:va,generateUUID:Pa,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)},getId:fa,heartBeat:V,toRequestQueue:F,reportViewDuration:Q,loadJS:Ta,loadCSS:ra,getLastView:function(){return Y},setToken:db,getToken:function(){var a=m("cly_token");m("cly_token",null);return a},showLoader:Ua,hideLoader:Va,add_cly_events:r,detect_device:gb,getRequestQueue:function(){return E},getEventQueue:function(){return H},clearQueue:function(){E=
115
115
  [];m("cly_queue",[]);H=[];m("cly_event",[])}};this.initialize()};n.init=function(h){h=h||{};var r=h.app_key||n.app_key;if(!n.i||!n.i[r]){h=new n.CountlyClass(h);if(!n.i){n.i={};for(var t in h)n[t]=h[t]}n.i[r]=h}return n.i[r]};var pa=0,x=function(h,r,t){"undefined"!==typeof h.addEventListener?h.addEventListener(r,t,!1):h.attachEvent("on"+r,t)},ya=function(h){return h?"undefined"!==typeof h.target?h.target:h.srcElement:window.event.srcElement},gb=function(){var h=navigator.userAgent.toLowerCase(),r=
116
116
  function(t){t&&(h=(t+"").toLowerCase());t=/(mobi|ipod|phone|blackberry|opera mini|fennec|minimo|symbian|psp|nintendo ds|archos|skyfire|puffin|blazer|bolt|gobrowser|iris|maemo|semc|teashark|uzard)/;var z="desktop";/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(h)?z="tablet":t.test(h)&&(z="phone");return z};return{device:r(),detect:r,isMobile:"desktop"!==r()?!0:!1,userAgent:h}}();window.addEventListener("storage",function(h){var r=
117
117
  (h.key+"").split("/"),t=r.pop();r=r.pop();if(n.i&&n.i[r])n.i[r].onStorageChange(t,h.newValue)});n.serialize=function(h){"object"===typeof h&&(h=JSON.stringify(h));return h};n.deserialize=function(h){try{h=JSON.parse(h)}catch(r){}return h};n.getViewName=function(){return window.location.pathname};n.getViewUrl=function(){return window.location.pathname};n.getSearchQuery=function(){return window.location.search};n.DeviceIdType={DEVELOPER_SUPPLIED:0,SDK_GENERATED:1,TEMPORARY_ID:2};return n}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "countly-sdk-web",
3
- "version": "22.02.1",
3
+ "version": "22.02.2",
4
4
  "description": "Countly Web SDK",
5
5
  "main": "lib/countly.js",
6
6
  "directories": {