zipyai-sprinto
Version:
SDK for zipy
1 lines • 87.4 kB
JavaScript
import{record as e,EventType as t,pack as n,MouseInteractions as r}from"zipy-rrweb";import{v4 as o}from"uuid";import{strToU8 as i,zlibSync as s,strFromU8 as a}from"fflate";var c,u,d;!function(e){e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.ReplayerEvent=11]="ReplayerEvent",e[e.ConsoleInfo=50]="ConsoleInfo",e[e.ConsoleError=51]="ConsoleError",e[e.ConsoleWarning=52]="ConsoleWarning",e[e.ConsoleDebug=53]="ConsoleDebug",e[e.Error=70]="Error",e[e.RangeError=71]="RangeError",e[e.ReferenceError=72]="ReferenceError",e[e.TypeError=73]="TypeError",e[e.SyntaxError=74]="SyntaxError",e[e.URIError=75]="URIError",e[e.EvalError=76]="EvalError",e[e.UnhandledRejection=77]="UnhandledRejection",e[e.BROWSERDATA=100]="BROWSERDATA",e[e.NAVIGATION=101]="NAVIGATION",e[e.Online=102]="Online",e[e.Offline=103]="Offline",e[e.XHR=104]="XHR",e[e.WSOPEN=105]="WSOPEN",e[e.WSCLOSE=106]="WSCLOSE",e[e.WSMESSAGE=107]="WSMESSAGE",e[e.WSERROR=108]="WSERROR",e[e.Fonts=109]="Fonts",e[e.Link=110]="Link",e[e.Css=111]="Css",e[e.Image=112]="Image",e[e.Js=113]="Js",e[e.Media=114]="Media",e[e.ZipyLogMessage=115]="ZipyLogMessage",e[e.ZipyLogException=116]="ZipyLogException",e[e.ZipyLogFrontendError=117]="ZipyLogFrontendError",e[e.ZipyLogNetworkError=118]="ZipyLogNetworkError",e[e.Performance=119]="Performance",e[e.PerfNavigation=120]="PerfNavigation",e[e.OtherNetworkCall=121]="OtherNetworkCall",e[e.WebVitals=122]="WebVitals"}(c||(c={})),function(e){e[e.MESSAGESEND=0]="MESSAGESEND",e[e.MESSAGERECEIVED=1]="MESSAGERECEIVED",e[e.SOCKETCLOSE=2]="SOCKETCLOSE",e[e.SOCKETERROR=3]="SOCKETERROR",e[e.SOCKETOPEN=4]="SOCKETOPEN"}(u||(u={})),function(e){e[e.ELEMENT=0]="ELEMENT",e[e.EVENT=1]="EVENT",e[e.FIRST_INPUT=2]="FIRST_INPUT",e[e.LARGEST_CONTENTFUL_PAINT=3]="LARGEST_CONTENTFUL_PAINT",e[e.LAYOUT_SHIFT=4]="LAYOUT_SHIFT",e[e.LONGTASK=5]="LONGTASK",e[e.MARK=6]="MARK",e[e.MEASURE=7]="MEASURE",e[e.NAVIGATION=8]="NAVIGATION",e[e.PAINT=9]="PAINT",e[e.RESOURCE=10]="RESOURCE"}(d||(d={}));var l,f,p,v="zipy",g="rrweb";!function(e){e[e.POSTENDUSERINFOANDGETUSERCONFIG=0]="POSTENDUSERINFOANDGETUSERCONFIG",e[e.POSTENDUSERINFO=1]="POSTENDUSERINFO",e[e.GETUSERCONFIG=2]="GETUSERCONFIG"}(l||(l={})),function(e){e[e.ANONYMS=0]="ANONYMS",e[e.IDENTIFIED=1]="IDENTIFIED"}(f||(f={})),function(e){e[e.NORECORDING=0]="NORECORDING",e[e.RECORDINGPENDING=1]="RECORDINGPENDING",e[e.RECORDINGSUCCESSFUL=2]="RECORDINGSUCCESSFUL"}(p||(p={}));var m,y,w,h,E="logEvent",S="exceptionEvent",z="errorEvent",I=1024,C="startIframeRecording",k="stopIframeRecording",b="iframeContentLoaded";(h=m||(m={})).DEBUG="1",h.WARNING="2",h.ERROR="3",h.LOG="4",function(e){e[e.BLOCKING=0]="BLOCKING",e[e.NON_BLOCKING=1]="NON_BLOCKING"}(y||(y={})),function(e){e.session_data="_zsession-data",e.total_data_sent="_ztotal-data-sent",e.enduser_last_activity_time="_zenduser-last-activity-time",e.last_activity_time="_zlast-activity-time"}(w||(w={}));var O,T=/^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$/,N=499;!function(e){e[e.FCP=0]="FCP",e[e.FP=1]="FP",e[e.FID=2]="FID",e[e.CLS=3]="CLS",e[e.LCP=4]="LCP"}(O||(O={}));var R={streamMgrUrl:"https://services.zipy.ai/sdk-session-manager/v2/enduser-info",registerSessionUrl:"https://services.zipy.ai/sdk-session-manager/v1/register-sdk-session",sdkVersion:"1.0.18",errorUrl:"divolte.collector",streamMgrRetryCount:5,zipyDeploymentEnviornment:"Production",sdkLoopTime:1e3,perfLoopTime:5e3,ignoreEmptyErros:!0,ignoreLargeResponse:!0,debugLogs:!1,sessionLinkUrl:"https://app.zipy.ai",isNPM:!0},P=!1;function D(e){P&&console.info(v,e)}function U(e){P&&console.debug(v,e)}function x(e){P&&console.log(v,e)}function L(e){P&&console.error(v,e)}function _(){return _=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_.apply(this,arguments)}function A(e,t){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},A(e,t)}function F(e,t,n){return F=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&A(o,n.prototype),o},F.apply(null,arguments)}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?q(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function G(){return Date.now()}function B(e,t,n){var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}function J(){var e=Math.floor(Date.now()/1e3);return o()+"-"+e}function j(e){var t={externalId:"enduser_external_id",firstName:"eu_first_name",lastName:"eu_last_name",email:"eu_email",age:"eu_age",customerName:"eu_customer_name",avatar:"eu_avatar",phone:"eu_phone"};return e in t?t[e]:e}var Z={attributes:!0,childList:!0,characterData:!0,subtree:!0},W={domCapture:!0,consoleCapture:!0,networkCapture:!0,stackTraceCapture:!0,webSocketsCapture:!1,ipCapture:!0,inputMasking:!0,textMasking:!0,paid:!1,apiKey:"",streamUrl:"https://collector.zipy.ai",perfUrl:"https://perfcollector.zipy.ai",heatMapUrl:"https://heatmapcollector.zipy.ai",pagePerfUrl:"https://pageperfcollector.zipy.ai",maxBufferSize:5e6,compression:!0,compressionType:"gzip",timeFrequency:1e3,perfTimeFrequency:5e3,clickTimeFrequency:1e3,encodingType:"",sessionTimeout:18e5,failureRetryCount:5,bufferSizeFrequency:1048576,perfBufferSizeFrequency:1024,clickBufferSizeFrequency:1024,ignoreUrl:["google.com","zipy.ai","mixpanel","extreme-ip-lookup.com","hotjar","smartlook.com","newrelic.com","bugsnag","fullstory","sentry.io","google-analytics.com","bam.nr-data.net","wistia.com","amplitude.com","segment.io","pendo.io","raygun","smartlook.cloud","segment.com","visualstudio.com","stats.g.doubleclick.net","pagead2.googlesyndication.com","r.lr-in.com","clarity.ms","appcues.net","datadoghq.com"],ignoreError:["rrweb","zipy","Script error","pagead2.googlesyndication.com","adsbygoogle"],ignoreConsole:["{}"],isIgnoreUrlError:["google.com","zipy.ai","mixpanel","extreme-ip-lookup.com","hotjar","smartlook.com","newrelic.com","bugsnag","fullstory","sentry.io","google-analytics.com","bam.nr-data.net","wistia.com","amplitude.com","segment.io","pendo.io","raygun","smartlook.cloud","segment.com","visualstudio.com","stats.g.doubleclick.net","pagead2.googlesyndication.com","r.lr-in.com","clarity.ms","appcues.net","datadoghq.com"],isIgnoreConsoleError:["{}"],ip:"",pack:!0,blockClasses:"zipy-block",xhrReqPayloadCapture:!1,xhrRespPayloadCapture:!1,canvasCapture:!1,scrubbingKey:["password","secret","passwd","api_key","apikey","access_token","auth","credentials","mysql_pwd","stripetoken","cardnumber"],requestCapSize:1e6,responseCapSize:1e6,sizeExceededMessage:{message:"size too large",source:"zipy"},eventCountCapInSingleChunk:0,captureCustomZipyLogMessage:!1,captureCustomZipyLogError:!1,captureCustomZipyLogException:!1,startCaptureWithoutUserActivity:!1,consoleLogLevel:"3",recordCrossOriginIframes:!0,splitSessionSize:0,capturePerformance:!1,capturePagePerf:!1,captureClickEvents:!1,isApiIdentifierEnable:!1,apiUniqueIdentifier:[],ignoreUrlErrorCodes:{},ignoreUrlCodes:{},sessionStitching:!1,captureCancelledRequest:!1,clsEventCount:5,clsTimeout:3e4,xhrEventsTimeout:3e4};function H(e){return _({},e,{timestamp:G()})}function V(){try{return window.sdkConfig?window.sdkConfig:W}catch(e){return L("Failed to parse end user Info data"),W}}function K(e){try{var t=V();return t&&t.hasOwnProperty&&t.hasOwnProperty(e)?t[e]:null}catch(e){return L(e.message?JSON.stringify(e):e),null}}var X=function(e,t,n){return e&&e.constructor===String&&n.indexOf(e)===t},Y=function(e){return e&&e.constructor===String&&e.trim()};function $(){var e=K("headersToSanitize");return e&&e.length?e.split(","):[]}function Q(e){if(!Array.isArray(e))return[];for(var t,n=[],r=M(e);!(t=r()).done;){var o=t.value;try{o&&"object"==typeof o&&JSON.stringify(o)?o.constructor.name.toLowerCase().includes("error")?n.push({message:o.message,name:o.name,stack:o.stack}):n.push(o):n.push(String(o))}catch(e){n.push("[console log value cannot be serialized]")}}return n}var ee=[];try{ee=K("scrubbingKey")||[]}catch(e){L("Error in obtaining scrubbing keys"),ee=W.scrubbingKey}function te(e){try{var t=new URL(e);if(e){var n=new URLSearchParams(new URL(e).search);n.forEach(function(e,t){ee.includes(t.toLowerCase())&&n.set(t,"xxx")}),t.search=n.toString()}return t.toString()}catch(t){return L("updateQueryStringFromRequestUrl: ERROR WHILE HIDING QUERY PARAM VALUE: "+t),e}}function ne(e,t,n){n++;try{e&&"object"==typeof e&&n<=2&&Object.keys(e).forEach(function(r){ee.includes(r.toLowerCase())&&(e[r]="xxx"),t.push(r);var o=e[r];"object"==typeof o&&ne(o,t,n)})}catch(e){L("error while hiding the sensitive information: "+e)}return JSON.stringify(e)}function re(e,t,n,r){var o=r?e.request:e.response,i=K(r?"xhrReqPayloadCapture":"xhrRespPayloadCapture"),s=function(t){try{r?(e.request=t,""!=e.request&&(e.requestByteSize=n)):(e.response=t,""!=e.response&&(e.responseByteSize=n))}catch(e){L("error while converting xhr data to string"+e)}};if(i){var a=K("responseCapSize")||1e6,c=K("requestCapSize")||1e6,u=r?c:a,d=K("sizeExceededMessage");"string"==typeof o&&o.length>0?(n=n||o.length)<=u?function(){try{s(ne(JSON.parse(o),[],t))}catch(t){var e=ee.some(function(e){return o.indexOf(e)>=0});s(o=r?e?"No request payload captured for this request as you may have some sensitive information in the payload.":o:e?"No response captured for this request as you may have some sensitive information in the payload.":o)}}():n>0&&s(JSON.stringify(d)):"object"==typeof o?(n=n||JSON.stringify(o,null,4).length)<=u?s(ne(o,[],t)):n>0&&s(d):o&&o.length>0&&((n=n||o.length)<=u?s(ne(o,[],t)):n>0&&s(JSON.stringify(d)))}else r?e.request="":e.response="";return e}function oe(e){if(!e)return!1;var t=e.toLowerCase(),n=K("ignoreError")||[];try{if(n.some(function(e){return t.includes(e.toLowerCase())}))return U("Ignoring error for data: "+e),!0}catch(e){L("Error in ignore errors. Error - "+e.message)}return!1}function ie(){try{return window.self!==window.top}catch(e){return!0}}function se(e,t){if(e&&null!=e)try{var n="";n="string"!=typeof e?JSON.stringify(e):e;for(var r=c.RangeError;r<=c.EvalError;r++)if(-1!=n.search(c[r]))return r}catch(e){L(e)}return t}function ae(e){switch(e){case"link":case"css":return c.Link;case"img":case"image":return c.Image;case"script":return c.Js;case"fetch":case"beacon":case"xmlhttprequest":return c.XHR;case"other":return c.OtherNetworkCall;default:return 0}}var ce=["img","script","css","link","image","script"];function ue(e,t,n){try{var r,o=K("isIgnoreUrlError"),i=K("ignoreUrl"),s=K("ignoreUrlErrorCodes"),a=K("ignoreUrlCodes"),c={};n?(r=o,c=s||{}):(r=i,c=a||{});var u=e.indexOf("?");u>0&&(e=e.substr(0,u));var d=function(e,n){return!!e.includes(n.toLowerCase())&&function(e){return!c.hasOwnProperty(e)||c[e].includes(t)}(n)},l=e.toLowerCase(),f=function(e){try{var t=e.match(/\/\d+\//g);if(t)for(var n,r=M(t);!(n=r()).done;)e=e.replace(n.value,"/{id}/")}catch(e){L("Error while masking numeric value.")}return e}(e.toLowerCase());if(r.some(function(e){return e.includes("{id}")?d(f,e):d(l,e)}))return!0}catch(t){L("Error in url decoding for url : "+e+" Error is - "+t)}return!1}function de(e){return{initiatorType:e.initiatorType,nextHopProtocol:e.nextHopProtocol,workerStart:e.workerStart,redirectStart:e.redirectStart,redirectEnd:e.redirectEnd,fetchStart:e.fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,secureConnectionStart:e.secureConnectionStart,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,responseStatus:e.responseStatus,renderBlockingStatus:e.renderBlockingStatus,duration:e.duration,entryType:e.entryType,name:e.name,startTime:e.startTime}}function le(e,t){if(!(e.indexOf("http://")>-1||e.indexOf("https://")>-1)){var n=new URL(t);return n.pathname+n.search===e}return!1}function fe(){var e=window.navigator.userAgent;return/Mobi|Android/i.test(e)?"Mobile":/Tablet|iPad/i.test(e)?"Tablet":"Web"}function pe(e){if("online"!=(navigator.onLine?"online":"offline")){if(!window.iszInternetDisconnected)return window.iszInternetDisconnected=!0,U("handleConnectionChange :: send internet disconnected"),e(H({eventType:c.Offline,data:{status:"Offline",type:""},isError:!1}))}else var t=setInterval(function(){fetch("//google.com",{mode:"no-cors"}).then(function(){return window.iszInternetDisconnected&&(window.iszInternetDisconnected=!1,U("handleConnectionChange :: send internet connected"),e(H({eventType:c.Online,data:{status:"Online",type:""},isError:!1}))),clearInterval(t)}).catch(function(){window.iszInternetDisconnected||(window.iszInternetDisconnected=!0,U("handleConnectionChange :: send internet disconnected"),e(H({eventType:c.Offline,data:{status:"Offline",type:""},isError:!1})))})},5e3)}var ve,ge=function(e){try{var t,n=function(n,r){try{var o="string"==typeof e.data.response?(t=1,e):"xmlHttpClient"===e.data.sourceLibrary&&"Blob"===(null==(i=e.data.response)||null==(i=i.constructor)?void 0:i.name)?Promise.resolve(new Response(e.data.response).text()).then(function(t){e.data.response=t}):function(){if("fetch"===e.data.sourceLibrary&&((t=e.data.response)instanceof Response||"object"==typeof t&&"function"==typeof t.json))return Promise.resolve(function(e){try{return Promise.resolve(new Promise(function(t,n){try{var r=function(e){t(o)},o="",i=function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(function(){var t;if(!e||"Response"!==(null==e||null==(t=e.constructor)?void 0:t.name))throw new Error("No valid Response object to process!");return Promise.resolve(null==e?void 0:e.text()).then(function(e){(o=e)&&o.length&&(o=JSON.parse(o))})},function(e){L("Error while getting json of response: "+e.message)});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}}(e.data.response)).then(function(t){e.data.response=t});throw new Error("Unsupported response type: "+typeof e.data.response);var t}()}catch(e){return r(e)}var i;return o&&o.then?o.then(void 0,r):o}(0,function(t){L("Error in resolving response. Error is - "+t.message),e.data.response=""});return Promise.resolve(n&&n.then?n.then(function(n){return t?n:e}):t?n:e)}catch(e){return Promise.reject(e)}},me=new Map;function ye(e){try{var t=window.localStorage.getItem(e);return D("inside zLocalStorageGetItem for key :"+e+" and value :"+t),!t&&(D("fetched value from hashmap :"+(t=me.get(e))),t)?(D("Going to update local storage:"),function(){try{D("inside localStorageUpdate function");for(var e,t=M(me.entries());!(e=t()).done;){var n=e.value;window.localStorage.getItem(n[0])||(D("Going inside localStorageUpdate-2 for key :"+n[0]+" and value :"+n[1]),we(n[0],n[1]))}}catch(e){L("inside updateLocalStorage catch block ${e.message}")}}(),t):t}catch(e){return void L("inside zLocalStorageGetItem catch block ${e.message}")}}function we(e,t){try{D("inside zLocalStorageSetItem for key :"+e+" and value :"+t),me.set(e,t),window.localStorage.setItem(e,t)}catch(e){L("inside zLocalStorageSetItem catch block ${e.message}")}}function he(e){try{D("inside zLocalStorageRemoveItem for key :"+e),me.delete(e),window.localStorage.removeItem(e)}catch(e){L("inside zLocalStorageSetItem catch block ${e.message}")}}function Ee(){var e=ye("zsdk-config");if(e)try{return JSON.parse(e)}catch(e){return void L("Failed to parse sdk Config Data")}}function Se(e){if(e)try{D("Updating zsession-blocked-info"+JSON.stringify(e)),we("zsession-blocked-info",JSON.stringify(e))}catch(e){L("Failed to stringify zsession-blocked-info ")}}function ze(e){var t={isBlocked:!1,blockedEndTime:0,apiKey:e};try{window.zSessionBlockedInfo=t,D("Updating zsession-blocked-info"+JSON.stringify(t)),we("zsession-blocked-info",JSON.stringify(t))}catch(e){L("Failed to stringify zsession-blocked-info ")}}function Ie(){var e=ye("zsession-blocked-info");if(e)try{var t=JSON.parse(e);return window.zSessionBlockedInfo=t,t}catch(e){return void L("Failed to parse zsession-blocked-info")}}function Ce(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}var ke=function e(t,n,r,o,i){void 0===n&&(n=5),void 0===i&&(i={});try{return Promise.resolve(Ce(function(){var s=new URL(t);return null!=r&&Object.keys(r).forEach(function(e){return s.searchParams.append(e,r[e])}),Promise.resolve(fetch(s.href,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).then(function(s){return s.ok?(U("postDataOnServer :: Response status = "+s.status),Promise.resolve(s.json()).then(function(e){return U("postDataOnServer :: Response JSON = "+e),e})):404==s.status?(we("is-api-key-valid","false"),De(!1),!1):(U("Error :: Response status = "+s.status),n>0?e(t,n-1,r,o,i):(L("Not able to post enduser config after multiple retries"),!1))})},function(e){return L("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},be=function e(t,n,r){try{return Promise.resolve(Ce(function(){return Promise.resolve(fetch(t,{method:"POST",headers:{"Content-Type":"application/json","Content-Encoding":"gzip"},body:JSON.stringify(n)})).then(function(o){return o.ok?(U("Response status = "+o.status),!0):(U("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(L("Not able to send data after all retries"),!1))})},function(e){return L("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},Oe=function e(t,n,r){try{return Promise.resolve(Ce(function(){return Promise.resolve(fetch(t,{method:"POST",headers:{"Content-Type":"application/json","Content-Encoding":"gzip"},body:JSON.stringify(n)})).then(function(o){return o.ok?(U("Response status = "+o.status),!0):(U("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(L("Not able to send data after all retries"),!1))})},function(e){return L("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},Te=function e(t,n,r){try{return Promise.resolve(Ce(function(){return Promise.resolve(fetch(t,{method:"POST",headers:{"Content-Type":"application/json","Content-Encoding":"gzip"},body:JSON.stringify(n)})).then(function(o){return o.ok?(U("Response status = "+o.status),!0):(U("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(L("Not able to send data after all retries"),!1))})},function(e){return L("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},Ne=function t(n){var r=n.divolteUrl,o=n.divolteJson,i=n.failureRetryCount;try{return Promise.resolve(Ce(function(){var n=JSON.stringify(o);return Promise.resolve(fetch(r,{method:"POST",headers:{"Content-Type":"application/json","Content-Encoding":"gzip"},body:n})).then(function(s){if(V()&&V().splitSessionSize>0){var a=(new TextEncoder).encode(n).byteLength;x("Request size "+a),function(t){try{var n=ye("ztotal-data-sent")?ye("ztotal-data-sent"):"0",r=parseInt(n)+t;x("Current data size "+n),x("Merged data size "+r),r>V().splitSessionSize?(function(){try{x("Trigger checkout flow triggered"),e.takeFullSnapshot(!0)}catch(e){L("Error in checking full snapshot. Error is - "+e.message)}}(),we("ztotal-data-sent","0"),x("Resetting data to size zero")):we("ztotal-data-sent",JSON.stringify(r))}catch(e){L("Error in checking data size. Error is - "+e.message)}}(a)}return s.ok?(U("Response status = "+s.status),!0):(U("Error :: Response status = "+s.status),i>0?t({divolteUrl:r,divolteJson:o,failureRetryCount:i-1}):(L("Not able to send data after all retries"),!1))})},function(e){return L("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},Re=!0;function Pe(){return Re}function De(e){Re=e}function Ue(){var e=ye("session-data");if(e)try{return JSON.parse(e)}catch(e){return void L("Failed to parse session data")}}function xe(e){if(window.iszSessionExpired)return U("Session is already expired"),!0;var t=(Ue()||{}).sessionId,n=Number(ye("last-activity-time"));return!t||n+e.sessionTimeout<=Date.now()?(D("Session is expired"),window.iszSessionExpired=!0,!0):!function(e){var t=Le();return!(!t||t+e.sessionTimeout<=Date.now())}(e)}function Le(){try{var e=window.zenduserLastActivityTime;if(!e){if(!(e=ye("zenduser-last-activity-time")))return 0;e=Number(e)}return e}catch(e){return L("inside getZendUserActivityTime catch block"),0}}function _e(){var e=ye("pack");if(!e){var t=V();we("pack",e=t.pack?t.pack.toString():(!1).toString())}return"true"===e}function Ae(e){var t=ye("zId");t||we("zId",t=J());var n=J(),r="0:"+J().replace("-",":");!function(e){ze(e)}(e);var o={sessionId:n,dSession:r,isNewSession:!0,sdkKey:e,isActive:!1};we("is-api-key-valid","true"),De(!0);try{D("Created new Session"+JSON.stringify(o)),we("session-data",JSON.stringify(o)),we("last-activity-time",Date.now().toString()),window.iszSessionExpired=!1}catch(e){L("Failed to stringify session data")}}function Fe(){var e=Ue()||{};return!("isActive"in e)||e.isActive}function qe(e){var t=Ue();return!!t&&e!==(null==t?void 0:t.sdkKey)&&(D("Sdk key is chnaged going to create session data"),!0)}function Me(){var e=ye("zId");return e||(we("zId",e=J()),e)}function Ge(){var e=ye("zenduser-info");if(e)try{return JSON.parse(e)}catch(e){return void L("Failed to parse end user Info data")}}function Be(){var e=ye("zenduser-info-temp");if(e)try{return JSON.parse(e)}catch(e){return void L("Failed to parse end user Info data")}}function Je(e){Me(),Ge()||D("Creating new enduser-info"+JSON.stringify(e));try{D("Updating enduser-info"+JSON.stringify(e)),we("zenduser-info",JSON.stringify(e))}catch(e){L("Failed to stringify enduser-info ")}}function je(e){Me(),Ge()||D("Creating new enduser-info-temp"+JSON.stringify(e));try{D("Updating enduser-info-temp"+JSON.stringify(e)),we("zenduser-info-temp",JSON.stringify(e))}catch(e){L("Failed to stringify enduser-info-temp ")}}function Ze(){Be()?(D("Removing zenduser-info-temp"),he("zenduser-info-temp")):D("zenduser temp Data dosen't exists")}function We(){var e=Ge();return e?e.userType===f.IDENTIFIED:(D("zenduser-info doesn't exists"),!1)}function He(e,t){e.euId=0,e.euZName="",e.isBlocked=!1,e.zAnonymsUserInfo={euId:0,euZName:"",zId:null!=t?t:""}}function Ve(e,t){var n,r,o=Me();(null==e||null==(n=e.zAnonymsUserInfo)?void 0:n.zId)===o?(D("ZId match"),e.euId=e.zAnonymsUserInfo.euId,e.euZName=e.zAnonymsUserInfo.euZName):(D("ZId dosen't match Zid : "+o+" and Anonyms user Zid: "+(null==e||null==(r=e.zAnonymsUserInfo)?void 0:r.zId)),He(e,o)),t?je(e):Je(e)}function Ke(){if(Be())return D("Temp storage has some pending data to post"),!0;var e=Ge();if(!e)return D("zenduser Data dosen't exists"),!0;if(0===e.euId)return D("Euid value is 0, required to fetch data again"),!0;if(e.userType===f.ANONYMS){var t,n;if(null==e||null==(t=e.zExternalUserInfo)?void 0:t.externalId)return D("External User details exists, and userType is ANONYMS need to post data"),!0;var r=Me();if((null==(n=e.zAnonymsUserInfo)?void 0:n.zId)!==r)return D("ZId dosen't match Zid : "+r+" and Anonyms user Zid: "+e.zAnonymsUserInfo.zId),He(e,r),Je(e),!0;D("ZId match No need to update for anonyms user")}return!1}var Xe=function(){function e(){this.rootDomain="",this.releaseVer="",this.recordOnlyIframe=!1,this.rootDomain="",this.releaseVer="",this.recordOnlyIframe=!1}var t=e.prototype;return t.saveOptions=function(e){this.releaseVer=e.releaseVer?e.releaseVer:this.releaseVer,this.rootDomain=this.isValidRootDomain(e.rootDomain)?e.rootDomain:this.rootDomain,this.recordOnlyIframe="boolean"==typeof e.recordOnlyIframe?e.recordOnlyIframe:this.recordOnlyIframe},t.isValidRootDomain=function(e){return!(!e||!new RegExp(T).test(e))},e.getInstance=function(){return this.instance||(this.instance=new e),this.instance},e}();Xe.instance=void 0;var Ye=function(e,t,n){void 0===t&&(t=0);try{var r={v:R.sdkVersion,e:"Production",o:t,ns:n};if(t==l.POSTENDUSERINFOANDGETUSERCONFIG||t==l.GETUSERCONFIG){var o=Ee();window.sdkConfig=o||W}var i=Ie();if(i&&i.isBlocked)return D("Not going to call post end user info as session is already blocked"),Promise.resolve(window.sdkConfig);window.iszHandshakeDone=!1,window.zpendingOp=t,U("config.sdkversion"+R.sdkVersion);var s=Be()||{zAnonymsUserInfo:{}},a={},c=f.ANONYMS;if(s){var u,d=s.zExternalUserInfo||{};for(var p in d)a[j(p)]=d[p]?d[p]:"";a.enduser_zipy_id=null==(u=s.zAnonymsUserInfo)?void 0:u.zId,d.externalId&&(D("Get User info for user Type Identified "+d.externalId),c=f.IDENTIFIED)}return window.ztryForHandshake=!1,Promise.resolve(ke(R.streamMgrUrl+"/"+e,R.streamMgrRetryCount,r,a)).then(function(n){if(n)if((null==n?void 0:n.api_key)==e){var r=Ie(),o=Ue()||{},i=!(null==n||!n.is_blocked)&&(null==n?void 0:n.is_blocked);if(r&&(r.isBlocked||o.isActive||at(n,e)),i)return window.sdkConfig;if(t==l.POSTENDUSERINFOANDGETUSERCONFIG||t==l.GETUSERCONFIG){var a=st(n);window.iszHandshakeDone=!0,D("sdkConfigResp"+JSON.stringify(a)),a&&(window.sdkConfig=a)}if(t==l.POSTENDUSERINFOANDGETUSERCONFIG||t==l.POSTENDUSERINFO){var u=n.enduser_info||{};D("Response object received for End User from stream manager: "+JSON.stringify(u)),u&&(D("Going to add enduser info after data parsing"),s.userType=c,s.euId=u.id?u.id:0,s.euZName=u.zipy_eu_name?u.zipy_eu_name:"",s.isBlocked=!!u.is_blocked&&u.is_blocked,c==f.ANONYMS&&(s.zAnonymsUserInfo.euId=s.euId,s.zAnonymsUserInfo.euZName=s.euZName,s.zExternalUserInfo={}),Je(s),Ze())}}else L("Not able to get response from stream manager for sdk Key: "+e);else L("Not able to get response from stream manager ");return window.sdkConfig})}catch(e){return Promise.reject(e)}},$e=function(e){try{var t,n=V(),r=window.zPagePerfData||[],o="";try{o=JSON.stringify(r)}catch(e){L("Failed to stringify zEvents")}var i=r.length,s=function(){if(2*o.length>=n.perfBufferSizeFrequency||window.pagePerfLastSynctime+n.perfTimeFrequency<=Date.now()&&i>0){var s,a,u=r.slice(0,i),d=Ue()||{},l=Ge()||{},f=ye("zId"),p=null!=(s=l.zExternalUserInfo)&&s.externalId?null==(a=l.zExternalUserInfo)?void 0:a.externalId:"",v=/\((.*)\)/.exec((new Date).toString())[1],g=_e(),m={key:e,sdk_ver:R.sdkVersion,src:"Frontend",s_id:d.sessionId,euz_id:f,eue_id:p,events:u,eu_info_id:l.euId,rel_ver:window.zRelVer,handshake_status:window.iszHandshakeDone,ip:n.ip,deviceName:fe()||"",userAgent:window.navigator.userAgent,timeZone:v,eventType:c.WebVitals,pack:g},y=n.pagePerfUrl+"/pageperf";return window.isDataSyncInProgress=!0,Pe()?Promise.resolve(be(y,m,n.failureRetryCount)).then(function(e){if(e)return window.pagePerfLastSynctime=Date.now(),function(e){window.zPagePerfData&&Array.isArray(window.zPagePerfData)?window.zPagePerfData.splice(0,e):window.zPagePerfData=[]}(i),window.isDataSyncInProgress=!1,t=!0}):(t=1,!1)}}();return Promise.resolve(s&&s.then?s.then(function(e){return!t||e}):!t||s)}catch(e){return Promise.reject(e)}},Qe=function(e){try{var t,n=V(),o=window.zClickEventsData||[],i=Xe.getInstance(),s="";try{s=JSON.stringify(o)}catch(e){L("Failed to stringify zEvents")}var a=o.length,c=function(){if(2*s.length>=n.bufferSizeFrequency||window.clickLastSyncTime+n.timeFrequency<=Date.now()&&a>0){var c,u,d=o.slice(0,a),l=Ue()||{},f=Ge()||{},p=ye("zId"),v=null!=(c=f.zExternalUserInfo)&&c.externalId?null==(u=f.zExternalUserInfo)?void 0:u.externalId:"",g=/\((.*)\)/.exec((new Date).toString())[1],m=_e(),y={key:e,sdk_ver:R.sdkVersion,src:"Frontend",s_id:l.sessionId,euz_id:p,eue_id:v,events:d,eu_info_id:f.euId,rel_ver:i.releaseVer,handshake_status:window.iszHandshakeDone,ip:n.ip,deviceName:fe()||"",userAgent:window.navigator.userAgent,timeZone:g,eventType:r.Click,pack:m},w=n.heatMapUrl+"/heatmap";return window.isDataSyncInProgress=!0,Pe()?Promise.resolve(Oe(w,y,n.failureRetryCount)).then(function(e){if(e)return window.clickLastSyncTime=Date.now(),function(e){window.zClickEventsData&&Array.isArray(window.zClickEventsData)?window.zClickEventsData.splice(0,e):window.zClickEventsData=[]}(a),window.isDataSyncInProgress=!1,t=!0}):(t=1,!1)}}();return Promise.resolve(c&&c.then?c.then(function(e){return!t||e}):!t||c)}catch(e){return Promise.reject(e)}},et=function(e){try{var t,n=V(),r=Xe.getInstance();U("Data Length for direct streaming ");var o=window.zEventsPerfData||[],i=o.length,s=function(){if(2*o.length>=n.perfBufferSizeFrequency||window.perfLastSyncTime+n.perfTimeFrequency<=Date.now()&&i>0){var s,a,c=o.slice(0,i),u=Ue()||{},d=Ge()||{},l=ye("zId"),f=null!=(s=d.zExternalUserInfo)&&s.externalId?null==(a=d.zExternalUserInfo)?void 0:a.externalId:"",p=/\((.*)\)/.exec((new Date).toString())[1],v={key:e,sdk_ver:R.sdkVersion,isNPM:R.isNPM,src:"Frontend",s_id:u.sessionId,euz_id:l,eue_id:f,events:c,eu_info_id:d.euId,rel_ver:r.releaseVer,handshake_status:window.iszHandshakeDone,ip:n.ip,deviceName:"",screenWidth:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,screenHeight:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,userAgent:window.navigator.userAgent,timeZone:p},g=n.perfUrl+"/perf";return window.isDataSyncInProgress=!0,Pe()?Promise.resolve(Te(g,v,n.failureRetryCount)).then(function(e){if(e)return window.perfLastSyncTime=Date.now(),n=i,window.zEventsPerfData&&Array.isArray(window.zEventsPerfData)?window.zEventsPerfData.splice(0,n):window.zEventsPerfData=[],window.isDataSyncInProgress=!1,t=!0;var n}):(t=1,!1)}}();return Promise.resolve(s&&s.then?s.then(function(e){return!t||e}):!t||s)}catch(e){return Promise.reject(e)}},tt=function(e){try{var t=V(),n=window.zEventsData||[],r=Xe.getInstance();U("Data Length for direct streaming ");var o="";try{o=JSON.stringify(n)}catch(e){L("Failed to stringify zEvents")}var i=null!=t&&t.eventCountCapInSingleChunk?t.eventCountCapInSingleChunk:0,s=i>0&&n.length>i?i:n.length;if(D("Going to send data with chunk "+s+" total events count "+n.length+" chunk size "+i),2*o.length>=t.bufferSizeFrequency||window.lastSyncTime+t.timeFrequency<=Date.now()&&s>0){var a,c,u=n.slice(0,s),d=Ue()||{},l=Ge()||{},f=ye("zId"),p=null!=(a=l.zExternalUserInfo)&&a.externalId?null==(c=l.zExternalUserInfo)?void 0:c.externalId:"",v=/\((.*)\)/.exec((new Date).toString())[1],g=_e(),m={key:e,sdk_ver:R.sdkVersion,isNPM:R.isNPM,src:"Frontend",s_id:d.sessionId,euz_id:f,eue_id:p,events:u,eu_info_id:l.euId,rel_ver:r.releaseVer,handshake_status:window.iszHandshakeDone,ip:t.ip,deviceName:"",screenWidth:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,screenHeight:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,userAgent:window.navigator.userAgent,timeZone:v,pack:g},y="";try{y=JSON.stringify(m)}catch(e){L("Failed to stringify zipyDataJson")}var w={eventData:y};return Promise.resolve(function(e){try{Pe()&&"false"===ye("is-api-key-valid")&&De(!1);var t=function(){if(!Fe()&&Pe())return D("Going to register new session"),Promise.resolve(function(e){try{var t={v:R.sdkVersion},n=Ue(),r={enduser_session_id:n.sessionId,user_agent:window.navigator.userAgent,ip_address:"",location:"",enduser_zipy_id:"",project_release_version:"",sdk_version:"",device_name:"",screen_width:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,screen_height:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth};return Promise.resolve(ke(R.registerSessionUrl+"/"+e,R.streamMgrRetryCount,t,r)).then(function(t){return t?(function(){var e=Ue();if(!e)return!1;try{return D("Setting session as active"+JSON.stringify(e)),e.isActive=!0,we("session-data",JSON.stringify(e)),!0}catch(e){return L("Failed to stringify session data"),!1}}(),at(t,e),!0):(L("Not able to register new session for session Id : "+n.sessionId),!1)})}catch(e){return Promise.reject(e)}}(e)).then(function(){})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}(e)).then(function(){if(ct())return function(){for(;window.zEventsData.length;)window.zEventsData.pop();window.zEventsData=[]}(),!0;var e={session_id:d.dSession,event_id:"AruZ~Em0WNlAnbyzVmwM~GR0cMb6Xl9r",is_new_party:d.isNewSession,is_new_session:d.isNewSession,client_timestamp_iso:(new Date).toISOString(),event_type:"MyEventRecord",parameters:w},n=t.streamUrl+"?p="+d.sessionId;return window.isDataSyncInProgress=!0,Pe()?Promise.resolve(Ne({divolteUrl:n,divolteJson:e,failureRetryCount:t.failureRetryCount})).then(function(e){if(e){if(window.lastSyncTime=Date.now(),function(e){window.zEventsData&&Array.isArray(window.zEventsData)?window.zEventsData.splice(0,e):window.zEventsData=[]}(s),window.isDataSyncInProgress=!1,we("last-activity-time",window.zlastActivityTime),we("zenduser-last-activity-time",window.zenduserLastActivityTime),d.isNewSession){var t=Ue();if(t){t.isNewSession=!1;try{we("session-data",JSON.stringify(t))}catch(e){L("Failed to set session-data in localstorage")}}}return!0}return!1}):(we("last-activity-time",window.zlastActivityTime),we("zenduser-last-activity-time",window.zenduserLastActivityTime),window.isDataSyncInProgress=!1,!1)})}return Promise.resolve(!1)}catch(e){return Promise.reject(e)}};function nt(o,u){void 0===o&&(o=W.inputMasking);var d=Xe.getInstance();U("Going to init rrweb Recorder"),window.zrrwebRecorderStatus=p.RECORDINGPENDING;var l,f=function(){};try{var v=V();f=e({emit:function(e,o){if(!ie()||d.recordOnlyIframe){var u=-1;e.type!=t.IncrementalSnapshot?u=c.ReplayerEvent:(u=e.data.source?e.data.source:c.ReplayerEvent,(v.startCaptureWithoutUserActivity||u>=c.MouseInteraction&&u<=c.MediaInteraction)&&(window.zrrwebRecorderStatus=p.RECORDINGSUCCESSFUL,window.zenduserLastActivityTime=Date.now()));try{var l=!1;window.reinitializationInProgress||(l=_e());var f={data:l?n(e):JSON.stringify(e),time:e.timestamp,type:u,rrwebEvent:null==e?void 0:e.type,isError:!1,navigatedUrl:window.location.origin+window.location.pathname};if(o&&e.type==t.Meta?(x("Checkout flow is triggered. Meta event expected type - "+t.Meta+" actual event "+e.type),f.isCheckout=o):o&&x("Full snapshot event. Expected event type - "+t.FullSnapshot+" Event type "+e.type),ot(f),t.IncrementalSnapshot&&u===c.MouseInteraction){var g=e.data;if(g.type&&g.type===r.Click){var m=function(e){D("Heatmap: Pack event");try{var t=JSON.stringify(e),n=i(t),r=s(n);return a(r,!0)}catch(e){return D("Heatmap: Unable to pack the data"),""}}(g);!function(e){var t=V();window.zrecordingPaused||ct()&&!xe(t)||Pe()&&t.captureClickEvents&&window.zClickEventsData.push(e)}({data:m,time:e.timestamp,type:g.type,isError:!1})}}}catch(e){L("Failed to store rrweb recorder events")}}},recordCanvas:K("canvasCapture"),blockClass:(l=K("blockClasses"),l&&"string"==typeof l?new RegExp(l):l instanceof RegExp?l:/zipy-block/),ignoreClass:"zipy-ignore",maskAllInputs:o,sampling:{mousemove:150,scroll:150,mouseInteraction:{MouseUp:!0,MouseDown:!0,Click:!0,ContextMenu:!1,DblClick:!0,Focus:!1,Blur:!1,TouchStart:!0,TouchEnd:!0}},userTriggeredOnInput:!0,blockSelector:"svg",recordCrossOriginIframes:!d.recordOnlyIframe})}catch(e){L(e)}return f}function rt(e){return U("Going to init zipy Recorder"),function(e){void 0===e&&(e={});var t=e.emit;if(!t)return L("emit function is required to record data from zipy-event-recorder"),function(){};ve=function(e){t(e)};try{var n=[];n.push(function(e){var t="",n=window.history.pushState,r=window.history.replaceState;if(window.history.pushState=function(){n.apply(window.history,arguments),window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange"))},window.history.replaceState=function(){r.apply(window.history,arguments),window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange"))},window.PerformanceObserver&&"function"==typeof window.PerformanceObserver){var o=function(n){var r=n.loadTime,o=n.navigationType,i=n.isRouteChange,s=n.navigationUrl,a=void 0===s?"":s;try{var u={navigatedUrl:a||window.location.href,loadTime:r,navigationType:o,isRouteChange:i};t!==a&&(e(H({eventType:c.NAVIGATION,data:u,isError:!1})),t=u.navigatedUrl)}catch(e){L("not able to capture the navigation url")}},i=function(){var e=0,t=0,n=null,r=1,i=window.location.href,s=new PerformanceObserver(function(e){e.getEntries().filter(function(e){return"fetch"!==e.initiatorType&&"xmlhttprequest"!==e.initiatorType}).forEach(function(e){t=performance.now()})}),a=new MutationObserver(function(){try{return t=performance.now(),Promise.resolve()}catch(e){return Promise.reject(e)}});e=performance.now(),t=performance.now(),s.observe({entryTypes:["resource"]}),a.observe(document,Z),r>0&&(r=0,n=setInterval(function(){performance.now()-t>100&&(clearInterval(n),function(){s.disconnect(),a.disconnect(),n&&clearInterval(n);var c=t-e;U("Page Performance Observer: Page Load Time:"),o({loadTime:c,navigationType:"navigate",isRouteChange:!0,navigationUrl:i}),e=0,t=0,n=null,r=1}())},1e3))},s=new PerformanceObserver(function(e){var t=e.getEntries().find(function(e){return"navigation"===e.entryType});if(t){var n=t.name,r=t.loadEventEnd-t.startTime;r>0&&(U("Page Performance: Initial Page Load Time:"),o({loadTime:r,navigationType:t.type,isRouteChange:!1,navigationUrl:n}))}});return s.observe({type:"navigation",buffered:window.buffered}),window.addEventListener("locationchange",i,!1),window.addEventListener("popstate",i),window.addEventListener("hashchange",i),function(){history.pushState=n,history.replaceState=r,window.removeEventListener("locationchange",i),window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i),s.disconnect()}}return function(){}}(ve));var r=V();return D("In zipy-event-record "+JSON.stringify(r)),r.consoleCapture&&n.push(function(e){function t(e){var t="";if("string"!=typeof e)try{t=JSON.stringify(e)}catch(e){}else t=e;try{if(-1!=t.search(v)||-1!=t.search(g))return!0}catch(e){return!0}return!1}function n(t,n){try{var r;r=function(e){if(!Array.isArray(e))return"";for(var t,n=[],r=M(e);!(t=r()).done;){var o=t.value;try{o&&"object"==typeof o&&o instanceof Error?n.push(String(o)):n.push(new Error(JSON.stringify(o)))}catch(e){n.push("[console log value cannot be serialized]")}}return n.join(" ")}(Array.from(n));var o=t==c.ConsoleError,i=o?function(e){if(!Array.isArray(e))return{hasErrorObj:!1};for(var t,n=M(e);!(t=n()).done;){var r=t.value;try{if(r&&"object"==typeof r&&(r.constructor.name.toLowerCase().includes("error")||(null==r?void 0:r.name).toLowerCase().includes("error")))return{hasErrorObj:!0,errObj:r}}catch(e){L("Error in checking error argument. Error is - "+e.message)}}return{hasErrorObj:!1}}(Array.from(n)):{hasErrorObj:!1};if(function(e,t){if(null==e)return!1;var n,r=e.toLowerCase(),o=V();try{n=t?o.isIgnoreConsoleError:o.ignoreConsole}catch(e){L(e)}try{if(n.some(function(e){return r.includes(e.toLowerCase())&&function(e){try{var t=JSON.parse(e.split("error:")[1]);return Object.keys(t).length<1||"{}"===t}catch(e){return!0}}(r)}))return!0}catch(e){return!1}return!1}(r,o))return;if(o&&i.hasErrorObj){var s={message:r,error:i.errObj.stack,filename:"",colno:0,lineno:0};e(H({eventType:se(r,c.Error),data:s,isError:!0}))}else e(H({eventType:t,data:{arguments:r,argumentsObj:Q(Array.from(n))},isError:o}))}catch(e){return void L("Error in parsing console log. Error is: "+e.message)}}try{var r,o,i,s,a;a=V().consoleLogLevel.split(",");try{a.includes(m.ERROR)&&(r=console.error.bind(console),console.error=function(){t(arguments[0])||n(c.ConsoleError,arguments),r.apply(console,arguments)})}catch(e){L("Error in parsing console error. Error is: "+e.message)}try{a.includes(m.LOG)&&(o=console.log.bind(console),console.log=function(){t(arguments[0])||n(c.ConsoleInfo,arguments),o.apply(console,arguments)})}catch(e){L("Error in parsing console log. Error is: "+e.message)}try{a.includes(m.WARNING)&&(i=console.warn.bind(console),console.warn=function(){t(arguments[0])||n(c.ConsoleWarning,arguments),i.apply(console,arguments)})}catch(e){L("Error in parsing console warning. Error is: "+e.message)}try{a.includes(m.DEBUG)&&(s=console.debug.bind(console),console.debug=function(){t(arguments[0])||n(c.ConsoleDebug,arguments),s.apply(console,arguments)})}catch(e){L("Error in parsing console debug. Error is: "+e.message)}return function(){r&&(console.error=r),o&&(console.log=o),i&&(console.warn=i),s&&(console.debug=s)}}catch(e){return L("Error while getting console log level from sdk config. Error is: "+e.message),function(){}}}(ve)),r.stackTraceCapture&&n.push(function(e){var t=[B("error",function(t){!function(e,t){var n=e.message,r=e.filename,o=e.lineno,i=e.colno;if(oe(n)||oe(r))U("Ignoring error from error callback "+n);else if(e.error){var s,a,u;if(oe(null==(s=e.error)?void 0:s.stack))return void U("Ignoring error from error callback "+(null==(u=e.error)?void 0:u.stack));var d,l=null==(a=e.error)?void 0:a.stack;try{d="string"!=typeof l?JSON.stringify(l):l}catch(e){L("Failed to stringfy errorMsg inside error callback with exception"+e)}var f={message:n,filename:r,lineno:o,colno:i,error:d};t(H({eventType:se(n,c.Error),data:f,isError:!0}))}else{if((null==n||""==n)&&R.ignoreEmptyErros)return void U("Ignored empty error");var p={message:n,filename:r,lineno:o,colno:i,error:""};t(H({eventType:se(n,c.Error),data:p,isError:!0}))}}(t,e)},window)];return t.push(B("unhandledrejection",function(t){var n,r="reason"in t?null==t?void 0:t.reason:t,o=null!=t&&t.reason.stack?t.reason.stack:t;try{n="string"!=typeof o?JSON.stringify(o):o}catch(t){L("Failed to stringfy errorMsg inside unhandledrejection callback with exception"+t)}var i={message:""+r,error:n,filename:"",colno:0,lineno:0};if(null!=r&&""!=r||""!=i.error&&null!=i.error||!R.ignoreEmptyErros){var s="";try{s=JSON.stringify(i.error)}catch(t){L("Failed to stringfy exception")}oe(i.message)||oe(s)?U("Ignoring error from unhandled "+r):e(H({eventType:se(r,c.UnhandledRejection),data:i,isError:!0}))}else U("Ignoring empty errors")},window)),function(){t.forEach(function(e){return e()})}}(ve)),r.networkCapture&&(n.push(function(e){var t=0;function n(e,n){if(K("networkCapture")&&!window.stopRecording&&!ue(n.requestUrl,n.status,n.status>=400)){n.requestUrl=te(n.requestUrl);var r=V();if(r&&r.isApiIdentifierEnable&&r.apiUniqueIdentifier.length>0){var o=r.apiUniqueIdentifier.filter(function(e){return e.apiUrl===n.requestUrl});o.length>0&&(n.apiIdentifier=function(e,t){try{var n=JSON.parse(e);if(n&&"object"==typeof n)for(var r=Object.keys(n),o=0,i=r;o<i.length;o++){var s=i[o];if(s===t)return"string"==typeof n[s]?n[s]:""}}catch(e){L("error while parsing api payload: "+e)}return""}(n.request,o[0].identifierName))}D("Pushing fetch Data when performance is enabled "+(n=re(n,t,n.requestByteSize||0,!0)).requestUrl),window.zFetchTempData.push({eventType:e,data:n,isError:n.status>=400})}}function r(e,t){if("GET"==t||"get"==t)try{var n=e.split("/"),r=n[n.length-1];if(""==r&&n.length>=2&&(r=n[n.length-2]),-1!=r.indexOf(".js")&&!r.indexOf(".json")||-1!=r.indexOf(".map")||-1!=r.indexOf(".html")||-1!=r.indexOf(".css"))return D("Going to ignore response text for url "+e),!0}catch(e){return!1}return!1}if(null!=window.zxhrInit||1==window.zxhrInit)return D("Network in already initialized"),function(){};var o=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(){var e="";null!=arguments[1]&&null!=arguments[1]&&("string"==typeof arguments[1]?e=arguments[1]:arguments[1]instanceof URL&&(e=arguments[1].href));var t,i,a={request:"",requestMethod:arguments[0]?arguments[0]:"",requestUrl:e,sourceLibrary:"xmlHttpClient",headers:{},response:"",responseHeaders:{},status:400,requestStartTime:0,duration:0,requestByteSize:0,responseByteSize:0},u=this.send;this.send=function(){a.requestStartTime=Date.now(),a.request=arguments[0]?arguments[0]:"",a=re(a,0,0,!0),u.apply(this,arguments)};var d=this.setRequestHeader;this.setRequestHeader=function(){var e,t;2!==arguments.length||(e=arguments[0],(t=$()).length>0&&t.indexOf(e)>-1)||(a.headers[arguments[0]]=arguments[1]),d.apply(this,arguments)},this.addEventListener("load",function(){try{var o=this;if(t=Date.now(),!r(e,a.requestMethod))try{var s,u=o.getAllResponseHeaders().split("\n"),d=0;u.forEach(function(e){if(""!==e){var t=e.split(":");a.responseHeaders[t[0]]=t[1].trim(),!d&&t[0]&&"content-length"==t[0].toLowerCase()&&(d=t[1].trim())}}),"blob"===(null==o?void 0:o.responseType)?(d=d||(null==o||null==(s=o.response)?void 0:s.size),i=null==o?void 0:o.response):(i=null!=o&&o.responseText?o.responseText:"",d=d||i.length),a.responseByteSize=d,a.response=i}catch(e){U("Error while capturing response text")}return a.status=o.status,a.duration=t-a.requestStartTime,n(c.XHR,a),Promise.resolve()}catch(e){return Promise.reject(e)}}),this.addEventListener("error",function(){if(t=Date.now(),!r(e,a.requestMethod))try{var o,s=this.getAllResponseHeaders().split("\n"),u=0;s.forEach(function(e){if(""!==e){var t=e.split(":");a.responseHeaders[t[0]]=t[1].trim(),!u&&t[0]&&"content-length"==t[0].toLowerCase()&&(u=t[1].trim())}}),"blob"===(null==this?void 0:this.responseType)?(u=u||(null==this||null==(o=this.response)?void 0:o.size),i=null==this?void 0:this.response):(i=null!=this&&this.responseText?this.responseText:"",u=u||i.length),a.responseByteSize=u,a.response=i}catch(e){U("Error while capturing response text")}a.status=this.status?this.status:404,a.duration=t-a.requestStartTime,n(c.XHR,a)}),this.addEventListener("abort",function(){D("Request got aborted in fetch"),s(a,e,this)}),this.addEventListener("timeout",function(){D("Request got timeout"),s(a,e,this)}),o.apply(this,arguments)};var i=window.fetch;return window.fetch=function(){var e,t,o,s,a="",u={sourceLibrary:"fetch",requestUrl:"",requestMethod:"",headers:"",request:"",response:"",responseHeaders:{},status:400,requestStartTime:0,duration:0,requestByteSize:0,responseByteSize:0};u.requestStartTime=Date.now(),null!=arguments[0]&&null!=arguments[0]&&(a="string"==typeof(e=arguments[0])?e:e?e instanceof URL?e.href:e instanceof Request?e.url:"":"");try{if(null!=arguments[1]&&null!=arguments[1]){var d=arguments[1].body;d&&(u.requestByteSize=JSON.stringify(d,null,4).length)}}catch(e){L("error while capturing data length")}try{arguments[1]&&arguments[1].headers&&(t=_({},arguments[1].headers))}catch(e){L("header is not present in the call")}u=re(u={sourceLibrary:"fetch",requestUrl:a||"",requestMethod:arguments[1]&&arguments[1].method?arguments[1].method:"GET",headers:t?(o=t,s=$(),s.length>0?(s.forEach(function(e){return delete o[e]}),o):o):"",request:arguments[1]&&arguments[1].body?arguments[1].body:"",response:"",responseHeaders:{},status:400,duration:0,requestByteSize:0,responseByteSize:0,requestStartTime:u.requestStartTime},0,0,!0);var l=i.apply(window,arguments);return new Promise(function(e,t){var o={status:400},i=0;l.then(function(t){o={status:t.status};for(var s,d=M(t.headers);!(s=d()).done;){var l=s.value;l&&(u.responseHeaders[l[0]]=l[1],!i&&l[0]&&"content-length"==l[0].toLowerCase()&&(i=l[1]))}e(t.clone());var f=Date.now(),p=K("xhrRespPayloadCapture");(!r(a,u.requestMethod)&&o.status>=400||p)&&(u.response=t,u.responseByteSize=i),u.duration=f-u.requestStartTime,u.status=o.status,n(c.XHR,u)}).catch(function(r){var o=V();if("AbortError"===r.name&&o.captureCancelledRequest){var i=Date.now();u.status=N,u.duration=i-u.requestStartTime,n(c.XHR,u),e(r)}L("Error in fetch response: "+r.message),t(r)})})},window.zxhrInit=!0,function(){};function s(e,t,o){var i,s;if(V().captureCancelledRequest){if(!r(t,e.requestMethod))try{i=Date.now();var a,u=o.getAllResponseHeaders().split("\n"),d=0;u.forEach(function(t){if(""!==t){var n=t.split(":");e.responseHeaders[n[0]]=n[1].trim(),!d&&n[0]&&"content-length"==n[0].toLowerCase()&&(d=n[1].trim())}}),"blob"===(null==o?void 0:o.responseType)?(d=d||(null==o||null==(a=o.response)?void 0:a.size),s=null==o?void 0:o.response):(s=null!=o&&o.responseText?o.responseText:"",d=d||s.length),e.responseByteSize=d,e.response=s}catch(e){U("Error while capturing response text")}e.duration=i-e.requestStartTime,e.status=null!=o&&o.status?null==o?void 0:o.status:N,n(c.XHR,e)}}}()),n.push(function(e){var t=[B("online",function(t){pe(e)},window)];return t.push(B("offline",function(t){pe(e)},window)),function(){t.forEach(function(e){return e()})}}(ve))),n.push(function(e){var t=[];return t.push(B(E,function(t){try{var n=null==t?void 0:t.detail,r=n.message,o=n.options,i=void 0===o?{}:o;U("Capturing log message for message : "+r+" options: "+JSON.stringify(i)),r&&i&&i.constructor===Object?e(H({eventType:c.ZipyLogMessage,data:{message:r.length<I?r:r.substring(0,I),options:i},isError:!1})):D("Didn't capture log message for message : "+r+" options: "+JSON.stringify(i))}catch(e){L("Error in capturing log message. Error is - "+e.message)}},window)),t.push(B(S,function(t){try{var n,r=(null==(n=t.detail)?void 0:n.error)||{},o=r.message,i=r.name,s=void 0===i?"":i,a=r.filename,u=void 0=