From 4cb7e1cdf9ab560da52429d91a9f05d1da1e6174 Mon Sep 17 00:00:00 2001
From: turtledreams <62231246+turtledreams@users.noreply.github.com>
Date: Wed, 11 Sep 2024 21:33:24 +0900
Subject: [PATCH] minification 4.1
---
lib/countly.min.js | 161 +++++++++++++++++++++++----------------------
1 file changed, 81 insertions(+), 80 deletions(-)
diff --git a/lib/countly.min.js b/lib/countly.min.js
index abdc1c04..38710243 100644
--- a/lib/countly.min.js
+++ b/lib/countly.min.js
@@ -44,7 +44,7 @@ h:f.deserialize(h)}}function w(a,d,e,h){"none"===f.storage||"object"!==L(f.stora
!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",
!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",
!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",
-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.0");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
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,"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,"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",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: ["+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: ["+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);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,"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);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="type name stz etz apm_metrics apm_attr".split(" "),e=0;e=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"),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,"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=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",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.")};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.");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;hd.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")};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=Math.round(e.rating);10e.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=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);5e.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,"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'),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")?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=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"===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)+"], 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;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-"+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:["+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.");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="+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(),Fa=document.getElementById("csbg"),b(c.DEBUG,"present_feedback_widget, Removing past overlay.");var aa=document.getElementsByClassName("countly-"+v+"-wrapper");for(h=0;h');
-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");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-"+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,"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="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")&&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=h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var m=a.length;hf.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&&(h._online=!!navigator.onLine);x&&(h._background=!document.hasFocus());0window.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,"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,
+"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",
+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: ["+
+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: ["+
+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);
+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,
+"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);
+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=
+"type name stz etz apm_metrics apm_attr".split(" "),e=0;e=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"),
+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,
+"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=
+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",
+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.")};
+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.");
+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;hd.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")};
+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=
+Math.round(e.rating);10e.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=
+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);5e.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,
+"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'),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")?
+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=
+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"===
+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)+
+"], 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;
+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-"+
+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:["+
+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.");
+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="+
+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(),
+Fa=document.getElementById("csbg"),b(c.DEBUG,"present_feedback_widget, Removing past overlay.");var aa=document.getElementsByClassName("countly-"+v+"-wrapper");for(h=0;h');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");
+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-"+
+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,
+"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=
+"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")&&
+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=
+h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var m=a.length;hf.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&&
+(h._online=!!navigator.onLine);x&&(h._background=!document.hasFocus());0