From bc809e8edac81f7d8348d5e5520ac29f41f8c4d9 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:43:10 +0300 Subject: [PATCH] release_ready (#279) --- README.md | 2 +- lib/countly.js | 2 +- lib/countly.min.js | 259 +++++++++++++++++++++++---------------------- package.json | 2 +- 4 files changed, 137 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index b9b06bc9..208d98ae 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ or ### 3. Use a CDN (content delivery network) Countly web SDK is available on CDNJS. Use either -[https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.06.0/countly.min.js](https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.06.0/countly.min.js) +[https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.06.1/countly.min.js](https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/22.06.1/countly.min.js) or diff --git a/lib/countly.js b/lib/countly.js index fc74c568..fb1abe04 100644 --- a/lib/countly.js +++ b/lib/countly.js @@ -175,7 +175,7 @@ */ Countly.onload = Countly.onload || []; - var SDK_VERSION = "22.06.0"; + var SDK_VERSION = "22.06.1"; var SDK_NAME = "javascript_native_web"; var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/; diff --git a/lib/countly.min.js b/lib/countly.min.js index 485c6faa..fc2a5be9 100644 --- a/lib/countly.min.js +++ b/lib/countly.min.js @@ -1,125 +1,134 @@ -(function(n,fa){"function"===typeof define&&define.amd?define([],function(){return fa(n.Countly)}):"object"===typeof module&&module.exports?module.exports=fa(n.Countly):n.Countly=fa(n.Countly)})("undefined"!==typeof window?window:this,function(n){function fa(g){var q=[];if("undefined"!==typeof g.options)for(var v=0;v=g?wa++:wa=g;return wa}function u(g,q,v){if(q&&Object.keys(q).length){if("undefined"!==typeof q[g])return q[g]}else if("undefined"!==typeof n[g])return n[g];return v}function Ma(g,q,v){for(var C in n.i)n.i[C].tracking_crashes&&n.i[C].recordError(g,q,v)}function Za(g){var q=[],v;for(v in g)q.push(v+ -"="+encodeURIComponent(g[v]));return q.join("&")}function Na(g){return"/"===g.substr(g.length-1)?g.substr(0,g.length-1):g}function ka(g,q){for(var v={},C,I=0;IC){var X={},la=0,F;for(F in g)la -q&&(I=g.substring(0,q),C(d.DEBUG,v+", Key: [ "+g+" ] is longer than accepted length. It will be truncated."));return I}function ma(g){if(g)return g;g=navigator.userAgent;!g&&navigator.userAgentData&&(g=navigator.userAgentData.brands.map(function(q){return q.brand+":"+q.version}).join(),g+=navigator.userAgentData.mobile?" mobi ":" ",g+=navigator.userAgentData.platform);return g}function $a(g){if(!g){if(navigator.userAgentData.mobile)return"phone";g=ma()}g=g.toLowerCase();var q="desktop",v=/(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(g)?q="tablet":v.test(g)&&(q="phone");return q}function ab(g){return/(CountlySiteBot|nuhk|Googlebot|GoogleSecurityScanner|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver|bingbot|Google Web Preview|Mediapartners-Google|AdsBot-Google|Baiduspider|Ezooms|YahooSeeker|AltaVista|AVSearch|Mercator|Scooter|InfoSeek|Ultraseek|Lycos|Wget|YandexBot|Yandex|YaDirectFetcher|SiteBot|Exabot|AhrefsBot|MJ12bot|TurnitinBot|magpie-crawler|Nutch Crawler|CMS Crawler|rogerbot|Domnutch|ssearch_bot|XoviBot|netseer|digincore|fr-crawler|wesee|AliasIO|contxbot|PingdomBot|BingPreview|HeadlessChrome)/.test(g|| -ma())}function Oa(g){"undefined"===typeof g.pageY&&"number"===typeof g.clientX&&document.documentElement&&(g.pageX=g.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,g.pageY=g.clientY+document.body.scrollTop+document.documentElement.scrollTop);return g}function xa(){var g=document;return Math.max(Math.max(g.body.scrollHeight,g.documentElement.scrollHeight),Math.max(g.body.offsetHeight,g.documentElement.offsetHeight),Math.max(g.body.clientHeight,g.documentElement.clientHeight))} -function Pa(){var g=document;return Math.max(Math.max(g.body.scrollWidth,g.documentElement.scrollWidth),Math.max(g.body.offsetWidth,g.documentElement.offsetWidth),Math.max(g.body.clientWidth,g.documentElement.clientWidth))}function bb(){var g=document;return Math.min(Math.min(g.body.clientHeight,g.documentElement.clientHeight),Math.min(g.body.offsetHeight,g.documentElement.offsetHeight),window.innerHeight)}function cb(g,q,v,C,I,W){g=document.createElement(g);var S;g.setAttribute(q,v);g.setAttribute(C, -I);q=function(){S||W();S=!0};W&&(g.onreadystatechange=q,g.onload=q);document.getElementsByTagName("head")[0].appendChild(g)}function db(g,q){cb("script","type","text/javascript","src",g,q)}function ya(g,q){cb("link","rel","stylesheet","href",g,q)}function eb(){var g=document.getElementById("cly-loader");if(!g){var q=document.head||document.getElementsByTagName("head")[0],v=document.createElement("style");v.type="text/css";v.styleSheet?v.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%;}}": -v.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%;}}")); -q.appendChild(v);g=document.createElement("div");g.setAttribute("id","cly-loader");document.body.onload=function(){if(!n.showLoaderProtection)try{document.body.appendChild(g)}catch(C){}}}g.style.display="block"}function fb(){n.showLoaderProtection=!0;var g=document.getElementById("cly-loader");g&&(g.style.display="none")}if("undefined"!==typeof window){n=n||{};n.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" "); -var d={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "};n.q=n.q||[];n.onload=n.onload||[];var gb=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;n.CountlyClass=function(g){function q(a){if(h.ignore_visitor)c(d.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);a.key=w(a.key,h.maxKeyLength, -"add_cly_event",c);a.segmentation=R(a.segmentation,h.maxKeyLength,h.maxValueSize,h.maxSegmentationValues,"add_cly_event",c);var b=ka(a,["key","count","sum","dur","segmentation"]);b.timestamp=La();var e=new Date;b.hour=e.getHours();b.dow=e.getDay();H.push(b);m("cly_event",H);c(d.INFO,"Successfully adding event: ",a)}else c(d.ERROR,"Adding event failed. Event must have a key property")}function v(){h.ignore_prefetch&&"undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState&& -(h.ignore_visitor=!0);h.ignore_bots&&ab()&&(h.ignore_visitor=!0)}function C(){0a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;t.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;t.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;t.id="countly-feedback-sticker-"+a._id;f.appendChild(p);t.appendChild(f);t.appendChild(r);document.body.appendChild(t);var z=document.getElementById("smileyPathInStickerSvg"); -z&&(z.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(L){c(d.ERROR,"Somethings went wrong while element injecting process: "+ -L)}}function W(){var a;if("undefined"!==typeof h.onload&&0za&&G.shift(),G.push(a),m("cly_queue",G,!0)):c(d.ERROR,"app_key or device_id is missing ",h.app_key,h.device_id)} -function Y(){W();if(h.ignore_visitor)Aa=!1,c(d.WARNING,"User opt_out, no heartbeat");else{Aa=!0;var a=0;if(Ba&&"undefined"!==typeof n.q&&0Ca&&(h.session_duration(a-ba),ba=a));0Qa&&(Da=!1,a=G[0],c(d.DEBUG,"Processing request",a),m("cly_queue",G,!0),h.test_mode||ha("send_request_queue",h.url+hb,a,function(p,r){c(d.DEBUG,"Request Finished",r,p);p?(Qa=B()+Ea,c(d.ERROR, -"Request error: ",p)):G.shift();m("cly_queue",G,!0);Da=!0},!1));setTimeout(Y,Fa)}}function Ra(){var a=m("cly_id");return a?(D=m("cly_id_type"),a):Ya()}function Ga(){var a=JSON.parse(JSON.stringify(h.metrics||{}));a._app_version=a._app_version||h.app_version;a._ua=a._ua||ma();if(screen.width){var b=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==b&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&window.devicePixelRatio)b=Math.round(b* -window.devicePixelRatio),e=Math.round(e*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var k=b;b=e;e=k}a._resolution=a._resolution||""+b+"x"+e}}window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);b=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof b&&(a._locale=a._locale||b);if("undefined"!==typeof document.referrer&&document.referrer.length&&(b=gb.exec(document.referrer))&&b[11]&&b[11]!== -window.location.hostname){b=!1;if(P&&P.length)for(e=0;ea))return c(d.ERROR,"Http response status code is not within the expected range:["+a+"]"),!1;try{var e=JSON.parse(b);return"[object Object]"!==Object.prototype.toString.call(e)?(c(d.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(k){return c(d.ERROR,"Http response is not JSON: "+k),!1}}function ib(a,b){if(!(200<=a&&300>a))return c(d.ERROR, -"Http response status code is not within the expected range: "+a),!1;try{var e=JSON.parse(b);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(c(d.ERROR,"Http response is not JSON Object nor JSON Array"),!1)}catch(k){return c(d.ERROR,"Http response is not JSON: "+k),!1}}function kb(){sa=Math.max(sa,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop)}function Sa(){if(ta){ta=!1;var a=xa(),b=Pa(),e=bb();h.check_consent("scrolls")&&(a={type:"scroll", -y:sa+e,width:b,height:a,view:h.getViewUrl()},a=R(a,h.maxKeyLength,h.maxValueSize,h.maxSegmentationValues,"processScrollView",c),h.track_domains&&(a.domain=window.location.hostname),q({key:"[CLY]_action",segmentation:a}))}}function lb(a){m("cly_token",a)}function m(a,b,e,k){function l(r,t,z){var L=new Date;L.setTime(L.getTime()+864E5*z);z="; expires="+L.toGMTString();document.cookie=r+"="+t+z+"; path=/"}function f(r){r+="=";for(var t=document.cookie.split(";"),z=0,L=t.length;zwindow.innerHeight?"landscape":"portrait")}})};this.report_conversion=function(a,b){c(d.WARNING,"report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!");this.recordDirectAttribution(a,b)};this.recordDirectAttribution=function(a,b){c(d.INFO,"recordDirectAttribution, Recording the attribution for campaign ID: ["+ -a+"] and the user ID: ["+b+"]");this.check_consent("attribution")&&(a=a||m("cly_cmp_id")||"cly_organic",(b=b||m("cly_cmp_uid"))?F({campaign_id:a,campaign_user:b}):F({campaign_id:a}))};this.user_details=function(a){c(d.INFO,"user_details, Trying to add user details: ",a);this.check_consent("users")&&(a.name=w(a.name,h.maxValueSize,"user_details",c),a.username=w(a.username,h.maxValueSize,"user_details",c),a.email=w(a.email,h.maxValueSize,"user_details",c),a.organization=w(a.organization,h.maxValueSize, -"user_details",c),a.phone=w(a.phone,h.maxValueSize,"user_details",c),a.picture=w(a.picture,4096,"user_details",c),a.gender=w(a.gender,h.maxValueSize,"user_details",c),a.byear=w(a.byear,h.maxValueSize,"user_details",c),a.custom=R(a.custom,h.maxKeyLength,h.maxValueSize,h.maxSegmentationValues,"user_details",c),F({user_details:JSON.stringify(ka(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var Q={},V=function(a,b,e){h.check_consent("users")&&(Q[a]||(Q[a]={}), -"$push"===e||"$pull"===e||"$addToSet"===e?(Q[a][e]||(Q[a][e]=[]),Q[a][e].push(b)):Q[a][e]=b)};this.userData={set:function(a,b){c(d.INFO,"set, Setting user's custom property value: ["+b+"] under the key: ["+a+"]");a=w(a,h.maxKeyLength,"userData set",c);b=w(b,h.maxValueSize,"userData set",c);Q[a]=b},unset:function(a){c(d.INFO,"unset, Resetting user's custom property with key: ["+a+"] ");Q[a]=""},set_once:function(a,b){c(d.INFO,"set_once, Setting user's unique custom property value: ["+b+"] under the key: ["+ -a+"] ");a=w(a,h.maxKeyLength,"userData set_once",c);b=w(b,h.maxValueSize,"userData set_once",c);V(a,b,"$setOnce")},increment:function(a){c(d.INFO,"increment, Increasing user's custom property value under the key: ["+a+"] by one");a=w(a,h.maxKeyLength,"userData increment",c);V(a,1,"$inc")},increment_by:function(a,b){c(d.INFO,"increment_by, Increasing user's custom property value under the key: ["+a+"] by: ["+b+"]");a=w(a,h.maxKeyLength,"userData increment_by",c);b=w(b,h.maxValueSize,"userData increment_by", -c);V(a,b,"$inc")},multiply:function(a,b){c(d.INFO,"multiply, Multiplying user's custom property value under the key: ["+a+"] by: ["+b+"]");a=w(a,h.maxKeyLength,"userData multiply",c);b=w(b,h.maxValueSize,"userData multiply",c);V(a,b,"$mul")},max:function(a,b){c(d.INFO,"max, Saving user's maximum custom property value compared to the value: ["+b+"] under the key: ["+a+"]");a=w(a,h.maxKeyLength,"userData max",c);b=w(b,h.maxValueSize,"userData max",c);V(a,b,"$max")},min:function(a,b){c(d.INFO,"min, Saving user's minimum custom property value compared to the value: ["+ -b+"] under the key: ["+a+"]");a=w(a,h.maxKeyLength,"userData min",c);b=w(b,h.maxValueSize,"userData min",c);V(a,b,"$min")},push:function(a,b){c(d.INFO,"push, Pushing a value: ["+b+"] under the key: ["+a+"] to user's custom property array");a=w(a,h.maxKeyLength,"userData push",c);b=w(b,h.maxValueSize,"userData push",c);V(a,b,"$push")},push_unique:function(a,b){c(d.INFO,"push_unique, Pushing a unique value: ["+b+"] under the key: ["+a+"] to user's custom property array");a=w(a,h.maxKeyLength,"userData push_unique", -c);b=w(b,h.maxValueSize,"userData push_unique",c);V(a,b,"$addToSet")},pull:function(a,b){c(d.INFO,"pull, Removing the value: ["+b+"] under the key: ["+a+"] from user's custom property array");V(a,b,"$pull")},save:function(){c(d.INFO,"save, Saving changes to user's custom property");h.check_consent("users")&&F({user_details:JSON.stringify({custom:Q})});Q={}}};this.report_trace=function(a){c(d.INFO,"report_trace, Reporting performance trace");if(this.check_consent("apm")){for(var b="type name stz etz apm_metrics apm_attr".split(" "), -e=0;e=h.maxBreadcrumbCount;)da.shift(),c(d.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one."); -da.push(a)}};this.fetch_remote_config=function(a,b,e){c(d.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(Ga()));a&&(e||"function"!==typeof a?Array.isArray(a)&&a.length&&(c(d.INFO,"fetch_remote_config, Keys to fetch: [ "+a+" ]"),k.keys=JSON.stringify(a)):(e=a,a=null));b&&((c(d.INFO,"fetch_remote_config, Keys to omit: [ "+b+" ]"),e||"function"!==typeof b)?Array.isArray(b)&& -b.length&&(k.omit_keys=JSON.stringify(b)):(e=b,b=null));la(k);ha("fetch_remote_config",this.url+Ta,k,function(l,f,p){if(l)c(d.ERROR,"fetch_remote_config, An error occurred: "+l);else{try{var r=JSON.parse(p);if(k.keys||k.omit_keys)for(var t in r)M[t]=r[t];else M=r;m("cly_remote_configs",M)}catch(z){c(d.ERROR,"fetch_remote_config, Had an issue while parsing the response: "+z)}"function"===typeof e&&(c(d.INFO,"fetch_remote_config, Callback function is provided"),e(l,M))}},!0)}else c(d.ERROR,"fetch_remote_config, Remote config requires explicit consent"), -"function"===typeof e&&e(Error("Remote config requires explicit consent"),M)};this.get_remote_config=function(a){c(d.INFO,"get_remote_config, Getting remote config");return"undefined"!==typeof a?M[a]:M};this.stop_time=function(){c(d.INFO,"stop_time, Stopping tracking duration");Z&&(Z=!1,Va=B()-ba,oa=B()-na)};this.start_time=function(){c(d.INFO,"start_time, Starting tracking duration");Z||(Z=!0,ba=B()-Va,na=B()-oa,oa=0,X())};this.track_sessions=function(){function a(){document[e]||!document.hasFocus()? -h.stop_time():h.start_time()}function b(){va>=ua&&h.start_time();va=0}c(d.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();x(window,"beforeunload",function(){C();h.end_session()});var e="hidden";x(window,"focus",a);x(window,"blur",a);x(window,"pageshow",a);x(window,"pagehide",a);"onfocusin"in document&&(x(window,"focusin",a),x(window,"focusout",a));e in document?document.addEventListener("visibilitychange",a):"mozHidden"in document?(e="mozHidden",document.addEventListener("mozvisibilitychange", -a)):"webkitHidden"in document?(e="webkitHidden",document.addEventListener("webkitvisibilitychange",a)):"msHidden"in document&&(e="msHidden",document.addEventListener("msvisibilitychange",a));x(window,"mousemove",b);x(window,"click",b);x(window,"keydown",b);x(window,"scroll",b);setInterval(function(){va++;va>=ua&&h.stop_time()},6E4)};this.track_pageview=function(a,b,e){c(d.INFO,"track_pageview, Tracking page views");c(d.VERBOSE,"track_pageview, last view is:["+O+"]");O&&(c(d.DEBUG,"track_pageview, Scroll registry triggered"), -Sa(),ta=!0,sa=0);S();(a=w(a,h.maxKeyLength,"track_pageview",c))&&Array.isArray(a)&&(b=a,a=null);a||(a=this.getViewName());if(void 0===a||""===a)c(d.ERROR,"track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked.");else if(null===a)c(d.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(b&&b.length)for(var k=0;k