UNPKG

zipyai-sprinto

Version:

SDK for zipy

1 lines 87.7 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("zipy-rrweb"),require("uuid"),require("fflate")):"function"==typeof define&&define.amd?define(["exports","zipy-rrweb","uuid","fflate"],t):t((e||self).zipyaiSprinto={},e.zipyRrweb,e.uuid,e.fflate)}(this,function(e,t,n,r){var o,i,s;!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"}(o||(o={})),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"}(i||(i={})),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"}(s||(s={}));var a,c,u,d="zipy",l="rrweb";!function(e){e[e.POSTENDUSERINFOANDGETUSERCONFIG=0]="POSTENDUSERINFOANDGETUSERCONFIG",e[e.POSTENDUSERINFO=1]="POSTENDUSERINFO",e[e.GETUSERCONFIG=2]="GETUSERCONFIG"}(a||(a={})),function(e){e[e.ANONYMS=0]="ANONYMS",e[e.IDENTIFIED=1]="IDENTIFIED"}(c||(c={})),function(e){e[e.NORECORDING=0]="NORECORDING",e[e.RECORDINGPENDING=1]="RECORDINGPENDING",e[e.RECORDINGSUCCESSFUL=2]="RECORDINGSUCCESSFUL"}(u||(u={}));var f,p,v,g,y="logEvent",m="exceptionEvent",w="errorEvent",h=1024,E="startIframeRecording",S="stopIframeRecording",z="iframeContentLoaded";(g=f||(f={})).DEBUG="1",g.WARNING="2",g.ERROR="3",g.LOG="4",function(e){e[e.BLOCKING=0]="BLOCKING",e[e.NON_BLOCKING=1]="NON_BLOCKING"}(p||(p={})),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"}(v||(v={}));var I,b=/^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$/,C=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"}(I||(I={}));var k={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},O=!1;function T(e){O&&console.info(d,e)}function N(e){O&&console.debug(d,e)}function R(e){O&&console.log(d,e)}function P(e){O&&console.error(d,e)}function D(){return D=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},D.apply(this,arguments)}function U(e,t){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},U(e,t)}function x(e,t,n){return x=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&&U(o,n.prototype),o},x.apply(null,arguments)}function L(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 _(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 L(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)?L(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 A(){return Date.now()}function F(e,t,n){var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}function q(){var e=Math.floor(Date.now()/1e3);return n.v4()+"-"+e}function M(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 G={attributes:!0,childList:!0,characterData:!0,subtree:!0},B={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 J(e){return D({},e,{timestamp:A()})}function j(){try{return window.sdkConfig?window.sdkConfig:B}catch(e){return P("Failed to parse end user Info data"),B}}function Z(e){try{var t=j();return t&&t.hasOwnProperty&&t.hasOwnProperty(e)?t[e]:null}catch(e){return P(e.message?JSON.stringify(e):e),null}}var W=function(e,t,n){return e&&e.constructor===String&&n.indexOf(e)===t},H=function(e){return e&&e.constructor===String&&e.trim()};function V(){var e=Z("headersToSanitize");return e&&e.length?e.split(","):[]}function K(e){if(!Array.isArray(e))return[];for(var t,n=[],r=_(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 X=[];try{X=Z("scrubbingKey")||[]}catch(e){P("Error in obtaining scrubbing keys"),X=B.scrubbingKey}function Y(e){try{var t=new URL(e);if(e){var n=new URLSearchParams(new URL(e).search);n.forEach(function(e,t){X.includes(t.toLowerCase())&&n.set(t,"xxx")}),t.search=n.toString()}return t.toString()}catch(t){return P("updateQueryStringFromRequestUrl: ERROR WHILE HIDING QUERY PARAM VALUE: "+t),e}}function $(e,t,n){n++;try{e&&"object"==typeof e&&n<=2&&Object.keys(e).forEach(function(r){X.includes(r.toLowerCase())&&(e[r]="xxx"),t.push(r);var o=e[r];"object"==typeof o&&$(o,t,n)})}catch(e){P("error while hiding the sensitive information: "+e)}return JSON.stringify(e)}function Q(e,t,n,r){var o=r?e.request:e.response,i=Z(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){P("error while converting xhr data to string"+e)}};if(i){var a=Z("responseCapSize")||1e6,c=Z("requestCapSize")||1e6,u=r?c:a,d=Z("sizeExceededMessage");"string"==typeof o&&o.length>0?(n=n||o.length)<=u?function(){try{s($(JSON.parse(o),[],t))}catch(t){var e=X.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($(o,[],t)):n>0&&s(d):o&&o.length>0&&((n=n||o.length)<=u?s($(o,[],t)):n>0&&s(JSON.stringify(d)))}else r?e.request="":e.response="";return e}function ee(e){if(!e)return!1;var t=e.toLowerCase(),n=Z("ignoreError")||[];try{if(n.some(function(e){return t.includes(e.toLowerCase())}))return N("Ignoring error for data: "+e),!0}catch(e){P("Error in ignore errors. Error - "+e.message)}return!1}function te(){try{return window.self!==window.top}catch(e){return!0}}function ne(e,t){if(e&&null!=e)try{var n="";n="string"!=typeof e?JSON.stringify(e):e;for(var r=o.RangeError;r<=o.EvalError;r++)if(-1!=n.search(o[r]))return r}catch(e){P(e)}return t}function re(e){switch(e){case"link":case"css":return o.Link;case"img":case"image":return o.Image;case"script":return o.Js;case"fetch":case"beacon":case"xmlhttprequest":return o.XHR;case"other":return o.OtherNetworkCall;default:return 0}}var oe=["img","script","css","link","image","script"];function ie(e,t,n){try{var r,o=Z("isIgnoreUrlError"),i=Z("ignoreUrl"),s=Z("ignoreUrlErrorCodes"),a=Z("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=_(t);!(n=r()).done;)e=e.replace(n.value,"/{id}/")}catch(e){P("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){P("Error in url decoding for url : "+e+" Error is - "+t)}return!1}function se(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 ae(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 ce(){var e=window.navigator.userAgent;return/Mobi|Android/i.test(e)?"Mobile":/Tablet|iPad/i.test(e)?"Tablet":"Web"}function ue(e){if("online"!=(navigator.onLine?"online":"offline")){if(!window.iszInternetDisconnected)return window.iszInternetDisconnected=!0,N("handleConnectionChange :: send internet disconnected"),e(J({eventType:o.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,N("handleConnectionChange :: send internet connected"),e(J({eventType:o.Online,data:{status:"Online",type:""},isError:!1}))),clearInterval(t)}).catch(function(){window.iszInternetDisconnected||(window.iszInternetDisconnected=!0,N("handleConnectionChange :: send internet disconnected"),e(J({eventType:o.Offline,data:{status:"Offline",type:""},isError:!1})))})},5e3)}var de,le=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){P("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){P("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)}},fe=new Map;function pe(e){try{var t=window.localStorage.getItem(e);return T("inside zLocalStorageGetItem for key :"+e+" and value :"+t),!t&&(T("fetched value from hashmap :"+(t=fe.get(e))),t)?(T("Going to update local storage:"),function(){try{T("inside localStorageUpdate function");for(var e,t=_(fe.entries());!(e=t()).done;){var n=e.value;window.localStorage.getItem(n[0])||(T("Going inside localStorageUpdate-2 for key :"+n[0]+" and value :"+n[1]),ve(n[0],n[1]))}}catch(e){P("inside updateLocalStorage catch block ${e.message}")}}(),t):t}catch(e){return void P("inside zLocalStorageGetItem catch block ${e.message}")}}function ve(e,t){try{T("inside zLocalStorageSetItem for key :"+e+" and value :"+t),fe.set(e,t),window.localStorage.setItem(e,t)}catch(e){P("inside zLocalStorageSetItem catch block ${e.message}")}}function ge(e){try{T("inside zLocalStorageRemoveItem for key :"+e),fe.delete(e),window.localStorage.removeItem(e)}catch(e){P("inside zLocalStorageSetItem catch block ${e.message}")}}function ye(){var e=pe("zsdk-config");if(e)try{return JSON.parse(e)}catch(e){return void P("Failed to parse sdk Config Data")}}function me(e){if(e)try{T("Updating zsession-blocked-info"+JSON.stringify(e)),ve("zsession-blocked-info",JSON.stringify(e))}catch(e){P("Failed to stringify zsession-blocked-info ")}}function we(e){var t={isBlocked:!1,blockedEndTime:0,apiKey:e};try{window.zSessionBlockedInfo=t,T("Updating zsession-blocked-info"+JSON.stringify(t)),ve("zsession-blocked-info",JSON.stringify(t))}catch(e){P("Failed to stringify zsession-blocked-info ")}}function he(){var e=pe("zsession-blocked-info");if(e)try{var t=JSON.parse(e);return window.zSessionBlockedInfo=t,t}catch(e){return void P("Failed to parse zsession-blocked-info")}}function Ee(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}var Se=function e(t,n,r,o,i){void 0===n&&(n=5),void 0===i&&(i={});try{return Promise.resolve(Ee(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?(N("postDataOnServer :: Response status = "+s.status),Promise.resolve(s.json()).then(function(e){return N("postDataOnServer :: Response JSON = "+e),e})):404==s.status?(ve("is-api-key-valid","false"),Te(!1),!1):(N("Error :: Response status = "+s.status),n>0?e(t,n-1,r,o,i):(P("Not able to post enduser config after multiple retries"),!1))})},function(e){return P("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},ze=function e(t,n,r){try{return Promise.resolve(Ee(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?(N("Response status = "+o.status),!0):(N("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(P("Not able to send data after all retries"),!1))})},function(e){return P("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},Ie=function e(t,n,r){try{return Promise.resolve(Ee(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?(N("Response status = "+o.status),!0):(N("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(P("Not able to send data after all retries"),!1))})},function(e){return P("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(Ee(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?(N("Response status = "+o.status),!0):(N("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(P("Not able to send data after all retries"),!1))})},function(e){return P("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},Ce=function e(n){var r=n.divolteUrl,o=n.divolteJson,i=n.failureRetryCount;try{return Promise.resolve(Ee(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(j()&&j().splitSessionSize>0){var a=(new TextEncoder).encode(n).byteLength;R("Request size "+a),function(e){try{var n=pe("ztotal-data-sent")?pe("ztotal-data-sent"):"0",r=parseInt(n)+e;R("Current data size "+n),R("Merged data size "+r),r>j().splitSessionSize?(function(){try{R("Trigger checkout flow triggered"),t.record.takeFullSnapshot(!0)}catch(e){P("Error in checking full snapshot. Error is - "+e.message)}}(),ve("ztotal-data-sent","0"),R("Resetting data to size zero")):ve("ztotal-data-sent",JSON.stringify(r))}catch(e){P("Error in checking data size. Error is - "+e.message)}}(a)}return s.ok?(N("Response status = "+s.status),!0):(N("Error :: Response status = "+s.status),i>0?e({divolteUrl:r,divolteJson:o,failureRetryCount:i-1}):(P("Not able to send data after all retries"),!1))})},function(e){return P("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},ke=!0;function Oe(){return ke}function Te(e){ke=e}function Ne(){var e=pe("session-data");if(e)try{return JSON.parse(e)}catch(e){return void P("Failed to parse session data")}}function Re(e){if(window.iszSessionExpired)return N("Session is already expired"),!0;var t=(Ne()||{}).sessionId,n=Number(pe("last-activity-time"));return!t||n+e.sessionTimeout<=Date.now()?(T("Session is expired"),window.iszSessionExpired=!0,!0):!function(e){var t=Pe();return!(!t||t+e.sessionTimeout<=Date.now())}(e)}function Pe(){try{var e=window.zenduserLastActivityTime;if(!e){if(!(e=pe("zenduser-last-activity-time")))return 0;e=Number(e)}return e}catch(e){return P("inside getZendUserActivityTime catch block"),0}}function De(){var e=pe("pack");if(!e){var t=j();ve("pack",e=t.pack?t.pack.toString():(!1).toString())}return"true"===e}function Ue(e){var t=pe("zId");t||ve("zId",t=q());var n=q(),r="0:"+q().replace("-",":");!function(e){we(e)}(e);var o={sessionId:n,dSession:r,isNewSession:!0,sdkKey:e,isActive:!1};ve("is-api-key-valid","true"),Te(!0);try{T("Created new Session"+JSON.stringify(o)),ve("session-data",JSON.stringify(o)),ve("last-activity-time",Date.now().toString()),window.iszSessionExpired=!1}catch(e){P("Failed to stringify session data")}}function xe(){var e=Ne()||{};return!("isActive"in e)||e.isActive}function Le(e){var t=Ne();return!!t&&e!==(null==t?void 0:t.sdkKey)&&(T("Sdk key is chnaged going to create session data"),!0)}function _e(){var e=pe("zId");return e||(ve("zId",e=q()),e)}function Ae(){var e=pe("zenduser-info");if(e)try{return JSON.parse(e)}catch(e){return void P("Failed to parse end user Info data")}}function Fe(){var e=pe("zenduser-info-temp");if(e)try{return JSON.parse(e)}catch(e){return void P("Failed to parse end user Info data")}}function qe(e){_e(),Ae()||T("Creating new enduser-info"+JSON.stringify(e));try{T("Updating enduser-info"+JSON.stringify(e)),ve("zenduser-info",JSON.stringify(e))}catch(e){P("Failed to stringify enduser-info ")}}function Me(e){_e(),Ae()||T("Creating new enduser-info-temp"+JSON.stringify(e));try{T("Updating enduser-info-temp"+JSON.stringify(e)),ve("zenduser-info-temp",JSON.stringify(e))}catch(e){P("Failed to stringify enduser-info-temp ")}}function Ge(){Fe()?(T("Removing zenduser-info-temp"),ge("zenduser-info-temp")):T("zenduser temp Data dosen't exists")}function Be(){var e=Ae();return e?e.userType===c.IDENTIFIED:(T("zenduser-info doesn't exists"),!1)}function Je(e,t){e.euId=0,e.euZName="",e.isBlocked=!1,e.zAnonymsUserInfo={euId:0,euZName:"",zId:null!=t?t:""}}function je(e,t){var n,r,o=_e();(null==e||null==(n=e.zAnonymsUserInfo)?void 0:n.zId)===o?(T("ZId match"),e.euId=e.zAnonymsUserInfo.euId,e.euZName=e.zAnonymsUserInfo.euZName):(T("ZId dosen't match Zid : "+o+" and Anonyms user Zid: "+(null==e||null==(r=e.zAnonymsUserInfo)?void 0:r.zId)),Je(e,o)),t?Me(e):qe(e)}function Ze(){if(Fe())return T("Temp storage has some pending data to post"),!0;var e=Ae();if(!e)return T("zenduser Data dosen't exists"),!0;if(0===e.euId)return T("Euid value is 0, required to fetch data again"),!0;if(e.userType===c.ANONYMS){var t,n;if(null==e||null==(t=e.zExternalUserInfo)?void 0:t.externalId)return T("External User details exists, and userType is ANONYMS need to post data"),!0;var r=_e();if((null==(n=e.zAnonymsUserInfo)?void 0:n.zId)!==r)return T("ZId dosen't match Zid : "+r+" and Anonyms user Zid: "+e.zAnonymsUserInfo.zId),Je(e,r),qe(e),!0;T("ZId match No need to update for anonyms user")}return!1}var We=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(b).test(e))},e.getInstance=function(){return this.instance||(this.instance=new e),this.instance},e}();We.instance=void 0;var He=function(e,t,n){void 0===t&&(t=0);try{var r={v:k.sdkVersion,e:"Production",o:t,ns:n};if(t==a.POSTENDUSERINFOANDGETUSERCONFIG||t==a.GETUSERCONFIG){var o=ye();window.sdkConfig=o||B}var i=he();if(i&&i.isBlocked)return T("Not going to call post end user info as session is already blocked"),Promise.resolve(window.sdkConfig);window.iszHandshakeDone=!1,window.zpendingOp=t,N("config.sdkversion"+k.sdkVersion);var s=Fe()||{zAnonymsUserInfo:{}},u={},d=c.ANONYMS;if(s){var l,f=s.zExternalUserInfo||{};for(var p in f)u[M(p)]=f[p]?f[p]:"";u.enduser_zipy_id=null==(l=s.zAnonymsUserInfo)?void 0:l.zId,f.externalId&&(T("Get User info for user Type Identified "+f.externalId),d=c.IDENTIFIED)}return window.ztryForHandshake=!1,Promise.resolve(Se(k.streamMgrUrl+"/"+e,k.streamMgrRetryCount,r,u)).then(function(n){if(n)if((null==n?void 0:n.api_key)==e){var r=he(),o=Ne()||{},i=!(null==n||!n.is_blocked)&&(null==n?void 0:n.is_blocked);if(r&&(r.isBlocked||o.isActive||rt(n,e)),i)return window.sdkConfig;if(t==a.POSTENDUSERINFOANDGETUSERCONFIG||t==a.GETUSERCONFIG){var u=nt(n);window.iszHandshakeDone=!0,T("sdkConfigResp"+JSON.stringify(u)),u&&(window.sdkConfig=u)}if(t==a.POSTENDUSERINFOANDGETUSERCONFIG||t==a.POSTENDUSERINFO){var l=n.enduser_info||{};T("Response object received for End User from stream manager: "+JSON.stringify(l)),l&&(T("Going to add enduser info after data parsing"),s.userType=d,s.euId=l.id?l.id:0,s.euZName=l.zipy_eu_name?l.zipy_eu_name:"",s.isBlocked=!!l.is_blocked&&l.is_blocked,d==c.ANONYMS&&(s.zAnonymsUserInfo.euId=s.euId,s.zAnonymsUserInfo.euZName=s.euZName,s.zExternalUserInfo={}),qe(s),Ge())}}else P("Not able to get response from stream manager for sdk Key: "+e);else P("Not able to get response from stream manager ");return window.sdkConfig})}catch(e){return Promise.reject(e)}},Ve=function(e){try{var t,n=j(),r=window.zPagePerfData||[],i="";try{i=JSON.stringify(r)}catch(e){P("Failed to stringify zEvents")}var s=r.length,a=function(){if(2*i.length>=n.perfBufferSizeFrequency||window.pagePerfLastSynctime+n.perfTimeFrequency<=Date.now()&&s>0){var a,c,u=r.slice(0,s),d=Ne()||{},l=Ae()||{},f=pe("zId"),p=null!=(a=l.zExternalUserInfo)&&a.externalId?null==(c=l.zExternalUserInfo)?void 0:c.externalId:"",v=/\((.*)\)/.exec((new Date).toString())[1],g=De(),y={key:e,sdk_ver:k.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:ce()||"",userAgent:window.navigator.userAgent,timeZone:v,eventType:o.WebVitals,pack:g},m=n.pagePerfUrl+"/pageperf";return window.isDataSyncInProgress=!0,Oe()?Promise.resolve(ze(m,y,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=[]}(s),window.isDataSyncInProgress=!1,t=!0}):(t=1,!1)}}();return Promise.resolve(a&&a.then?a.then(function(e){return!t||e}):!t||a)}catch(e){return Promise.reject(e)}},Ke=function(e){try{var n,r=j(),o=window.zClickEventsData||[],i=We.getInstance(),s="";try{s=JSON.stringify(o)}catch(e){P("Failed to stringify zEvents")}var a=o.length,c=function(){if(2*s.length>=r.bufferSizeFrequency||window.clickLastSyncTime+r.timeFrequency<=Date.now()&&a>0){var c,u,d=o.slice(0,a),l=Ne()||{},f=Ae()||{},p=pe("zId"),v=null!=(c=f.zExternalUserInfo)&&c.externalId?null==(u=f.zExternalUserInfo)?void 0:u.externalId:"",g=/\((.*)\)/.exec((new Date).toString())[1],y=De(),m={key:e,sdk_ver:k.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:r.ip,deviceName:ce()||"",userAgent:window.navigator.userAgent,timeZone:g,eventType:t.MouseInteractions.Click,pack:y},w=r.heatMapUrl+"/heatmap";return window.isDataSyncInProgress=!0,Oe()?Promise.resolve(Ie(w,m,r.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,n=!0}):(n=1,!1)}}();return Promise.resolve(c&&c.then?c.then(function(e){return!n||e}):!n||c)}catch(e){return Promise.reject(e)}},Xe=function(e){try{var t,n=j(),r=We.getInstance();N("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=Ne()||{},d=Ae()||{},l=pe("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:k.sdkVersion,isNPM:k.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,Oe()?Promise.resolve(be(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)}},Ye=function(e){try{var t=j(),n=window.zEventsData||[],r=We.getInstance();N("Data Length for direct streaming ");var o="";try{o=JSON.stringify(n)}catch(e){P("Failed to stringify zEvents")}var i=null!=t&&t.eventCountCapInSingleChunk?t.eventCountCapInSingleChunk:0,s=i>0&&n.length>i?i:n.length;if(T("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=Ne()||{},l=Ae()||{},f=pe("zId"),p=null!=(a=l.zExternalUserInfo)&&a.externalId?null==(c=l.zExternalUserInfo)?void 0:c.externalId:"",v=/\((.*)\)/.exec((new Date).toString())[1],g=De(),y={key:e,sdk_ver:k.sdkVersion,isNPM:k.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},m="";try{m=JSON.stringify(y)}catch(e){P("Failed to stringify zipyDataJson")}var w={eventData:m};return Promise.resolve(function(e){try{Oe()&&"false"===pe("is-api-key-valid")&&Te(!1);var t=function(){if(!xe()&&Oe())return T("Going to register new session"),Promise.resolve(function(e){try{var t={v:k.sdkVersion},n=Ne(),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(Se(k.registerSessionUrl+"/"+e,k.streamMgrRetryCount,t,r)).then(function(t){return t?(function(){var e=Ne();if(!e)return!1;try{return T("Setting session as active"+JSON.stringify(e)),e.isActive=!0,ve("session-data",JSON.stringify(e)),!0}catch(e){return P("Failed to stringify session data"),!1}}(),rt(t,e),!0):(P("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(ot())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,Oe()?Promise.resolve(Ce({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,ve("last-activity-time",window.zlastActivityTime),ve("zenduser-last-activity-time",window.zenduserLastActivityTime),d.isNewSession){var t=Ne();if(t){t.isNewSession=!1;try{ve("session-data",JSON.stringify(t))}catch(e){P("Failed to set session-data in localstorage")}}}return!0}return!1}):(ve("last-activity-time",window.zlastActivityTime),ve("zenduser-last-activity-time",window.zenduserLastActivityTime),window.isDataSyncInProgress=!1,!1)})}return Promise.resolve(!1)}catch(e){return Promise.reject(e)}};function $e(e,n){void 0===e&&(e=B.inputMasking);var i=We.getInstance();N("Going to init rrweb Recorder"),window.zrrwebRecorderStatus=u.RECORDINGPENDING;var s,a=function(){};try{var c=j();a=t.record({emit:function(e,n){if(!te()||i.recordOnlyIframe){var s=-1;e.type!=t.EventType.IncrementalSnapshot?s=o.ReplayerEvent:(s=e.data.source?e.data.source:o.ReplayerEvent,(c.startCaptureWithoutUserActivity||s>=o.MouseInteraction&&s<=o.MediaInteraction)&&(window.zrrwebRecorderStatus=u.RECORDINGSUCCESSFUL,window.zenduserLastActivityTime=Date.now()));try{var a=!1;window.reinitializationInProgress||(a=De());var d={data:a?t.pack(e):JSON.stringify(e),time:e.timestamp,type:s,rrwebEvent:null==e?void 0:e.type,isError:!1,navigatedUrl:window.location.origin+window.location.pathname};if(n&&e.type==t.EventType.Meta?(R("Checkout flow is triggered. Meta event expected type - "+t.EventType.Meta+" actual event "+e.type),d.isCheckout=n):n&&R("Full snapshot event. Expected event type - "+t.EventType.FullSnapshot+" Event type "+e.type),et(d),t.EventType.IncrementalSnapshot&&s===o.MouseInteraction){var l=e.data;if(l.type&&l.type===t.MouseInteractions.Click){var f=function(e){T("Heatmap: Pack event");try{var t=JSON.stringify(e),n=r.strToU8(t),o=r.zlibSync(n);return r.strFromU8(o,!0)}catch(e){return T("Heatmap: Unable to pack the data"),""}}(l);!function(e){var t=j();window.zrecordingPaused||ot()&&!Re(t)||Oe()&&t.captureClickEvents&&window.zClickEventsData.push(e)}({data:f,time:e.timestamp,type:l.type,isError:!1})}}}catch(e){P("Failed to store rrweb recorder events")}}},recordCanvas:Z("canvasCapture"),blockClass:(s=Z("blockClasses"),s&&"string"==typeof s?new RegExp(s):s instanceof RegExp?s:/zipy-block/),ignoreClass:"zipy-ignore",maskAllInputs:e,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:!i.recordOnlyIframe})}catch(e){P(e)}return a}function Qe(e){return N("Going to init zipy Recorder"),function(e){void 0===e&&(e={});var t=e.emit;if(!t)return P("emit function is required to record data from zipy-event-recorder"),function(){};de=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 i=function(n){var r=n.loadTime,i=n.navigationType,s=n.isRouteChange,a=n.navigationUrl,c=void 0===a?"":a;try{var u={navigatedUrl:c||window.location.href,loadTime:r,navigationType:i,isRouteChange:s};t!==c&&(e(J({eventType:o.NAVIGATION,data:u,isError:!1})),t=u.navigatedUrl)}catch(e){P("not able to capture the navigation url")}},s=function(){var e=0,t=0,n=null,r=1,o=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,G),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;N("Page Performance Observer: Page Load Time:"),i({loadTime:c,navigationType:"navigate",isRouteChange:!0,navigationUrl:o}),e=0,t=0,n=null,r=1}())},1e3))},a=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&&(N("Page Performance: Initial Page Load Time:"),i({loadTime:r,navigationType:t.type,isRouteChange:!1,navigationUrl:n}))}});return a.observe({type:"navigation",buffered:window.buffered}),window.addEventListener("locationchange",s,!1),window.addEventListener("popstate",s),window.addEventListener("hashchange",s),function(){history.pushState=n,history.replaceState=r,window.removeEventListener("locationchange",s),window.removeEventListener("popstate",s),window.removeEventListener("hashchange",s),a.disconnect()}}return function(){}}(de));var r=j();return T("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(d)||-1!=t.search(l))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=_(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 i=t==o.ConsoleError,s=i?function(e){if(!Array.isArray(e))return{hasErrorObj:!1};for(var t,n=_(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){P("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=j();try{n=t?o.isIgnoreConsoleError:o.ignoreConsole}catch(e){P(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,i))return;if(i&&s.hasErrorObj){var a={message:r,error:s.errObj.stack,filename:"",colno:0,lineno:0};e(J({eventType:ne(r,o.Error),data:a,isError:!0}))}else e(J({eventType:t,data:{arguments:r,argumentsObj:K(Array.from(n))},isError:i}))}catch(e){return void P("Error in parsing console log. Error is: "+e.message)}}try{var r,i,s,a,c;c=j().consoleLogLevel.split(",");try{c.includes(f.ERROR)&&(r=console.error.bind(console),console.error=function(){t(arguments[0])||n(o.ConsoleError,arguments),r.apply(console,arguments)})}catch(e){P("Error in parsing console error. Error is: "+e.message)}try{c.includes(f.LOG)&&(i=console.log.bind(console),console.log=function(){t(arguments[0])||n(o.ConsoleInfo,arguments),i.apply(console,arguments)})}catch(e){P("Error in parsing console log. Error is: "+e.message)}try{c.includes(f.WARNING)&&(s=console.warn.bind(console),console.warn=function(){t(arguments[0])||n(o.ConsoleWarning,arguments),s.apply(console,arguments)})}catch(e){P("Error in parsing console warning. Error is: "+e.message)}try{c.includes(f.DEBUG)&&(a=console.debug.bind(console),console.debug=function(){t(arguments[0])||n(o.ConsoleDebug,arguments),a.apply(console,arguments)})}catch(e){P("Error in parsing console debug. Error is: "+e.message)}return function(){r&&(console.error=r),i&&(console.log=i),s&&(console.warn=s),a&&(console.debug=a)}}catch(e){return P("Error while getting console log level from sdk config. Error is: "+e.message),function(){}}}(de)),r.stackTraceCapture&&n.push(function(e){var t=[F("error",function(t){!function(e,t){var n=e.message,r=e.filename,i=e.lineno,s=e.colno;if(ee(n)||ee(r))N("Ignoring error from error callback "+n);else if(e.error){var a,c,u;if(ee(null==(a=e.error)?void 0:a.stack))return void N("Ignoring error from error callback "+(null==(u=e.error)?void 0:u.stack));var d,l=null==(c=e.error)?void 0:c.stack;try{d="string"!=typeof l?JSON.stringify(l):l}catch(e){P("Failed to stringfy errorMsg inside error callback with exception"+e)}var f={message:n,filename:r,lineno:i,colno:s,error:d};t(J({eventType:ne(n,o.Error),data:f,isError:!0}))}else{if((null==n||""==n)&&k.ignoreEmptyErros)return void N("Ignored empty error");var p={message:n,filename:r,lineno:i,colno:s,error:""};t(J({eventType:ne(n,o.Error),data:p,isError:!0}))}}(t,e)},window)];return t.push(F("unhandledrejection",function(t){var n,r="reason"in t?null==t?void 0:t.reason:t,i=null!=t&&t.reason.stack?t.reason.stack:t;try{n="string"!=typeof i?JSON.stringify(i):i}catch(t){P("Failed to stringfy errorMsg inside unhandledrejection callback with exception"+t)}var s={message:""+r,error:n,filename:"",colno:0,lineno:0};if(null!=r&&""!=r||""!=s.error&&null!=s.error||!k.ignoreEmptyErros){var a="";try{a=JSON.stringify(s.error)}catch(t){P("Failed to stringfy exception")}ee(s.message)||ee(a)?N("Ignoring error from unhandled "+r):e(J({eventType:ne(r,o.UnhandledRejection),data:s,isError:!0}))}else N("Ignoring empty errors")},window)),function(){t.forEach(function(e){return e()})}}(de)),r.networkCapture&&(n.push(function(e){var t=0;function n(e,n){if(Z("networkCapture")&&!window.stopRecording&&!ie(n.requestUrl,n.status,n.status>=400)){n.requestUrl=Y(n.requestUrl);var r=j();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){P("error while parsing api payload: "+e)}return""}(n.request,o[0].identifierName))}T("Pushing fetch Data when performance is enabled "+(n=Q(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 T("Going to ignore response text for url "+e),!0}catch(e){return!1}return!1}if(null!=window.zxhrInit||1==window.zxhrInit)return T("Network in already initialized"),function(){};var i=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,s,c={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(){c.requestStartTime=Date.now(),c.request=arguments[0]?arguments[0]:"",c=Q(c,0,0,!0),u.apply(this,arguments)};var d=this.setRequestHeader;this.setRequestHeader=function(){var e,t;2!==arguments.length||(e=arguments[0],(t=V()).length>0&&t.indexOf(e)>-1)||(c.headers[arguments[0]]=arguments[1]),d.apply(this,arguments)},this.addEventListener("load",function(){try{var i=this;if(t=Date.now(),!r(e,c.requestMethod))try{var a,u=i.getAllResponseHeaders().split("\n"),d=0;u.forEach(function(e){if(""!==e){var t=e.split(":");c.responseHeaders[t[0]]=t[1].trim(),!d&&t[0]&&"content-length"==t[0].toLowerCase()&&(d=t[1].trim())}}),"blob"===(null==i?void 0:i.responseType)?(d=d||(null==i||null==(a=i.response)?void 0:a.size),s=null==i?void 0:i.response):(s=null!=i&&i.responseText?i.responseText:"",d=d||s.length),c.responseByteSize=d,c.response=s}catch(e){N("Error while capturing response text")}return c.status=i.status,c.duration=t-c.requestStartTime,n(o.XHR,c),Promise.resolve()}catch(e){return Promise.reject(e)}}),this.addEventListener("error",function(){if(t=Date.now(),!r(e,c.requestMethod))try{var i,a=this.getAllResponseHeaders().split("\n"),u=0;a.forEach(function(e){if(""!==e){var t=e.split(":");c.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==(i=this.response)?void 0:i.size),s=null==this?void 0:this.response):(s=null!=this&&this.responseText?this.responseText:"",u=u||s.length),c.responseByteSize=u,c.response=s}catch(e){N("Error while capturing response text")}c.status=this.status?this.status:404,c.duration=t-c.requestStartTime,n(o.XHR,c)}),this.addEventListener("abort",function(){T("Request got aborted in fetch"),a(c,e,this)}),this.addEventListener("timeout",function(){T("Request got timeout"),a(c,e,this)}),i.apply(this,arguments)};var s=window.fetch;return window.fetch=function(){var e,t,i,a,c="",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]&&(c="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){P("error while capturing data length")}try{arguments[1]&&arguments[1].headers&&(t=D({},arguments[1].headers))}catch(e){P("header is not present in the call")}u=Q(u={sourceLibrary:"fetch",requestUrl:c||"",requestMethod:arguments[1]&&arguments[1].method?arguments[1].method:"GET",headers:t?(i=t,a=V(),a.length>0?(a.forEach(function(e){return delete i[e]}),i):i):"",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=s.apply(window,arguments);return new Promise(function(e,t){var i={status:400},s=0;l.then(function(t){i={status:t.status};for(var a,d=_(t.headers);!(a=d()).done;){var l=a.value;l&&(u.responseHeaders[l[0]]=l[1],!s&&l[0]&&"content-length"==l[0].toLowerCase()&&(s=l[1]))}e(t.clone());var f=Date.now(),p=Z("xhrRespPayloadCapture");(!r(c,u.requestMethod)&&i.status>=400||p)&&(u.response=t,u.responseByteSize=s),u.duration=f-u.requestStartTime,u.status=i.status,n(o.XHR,u)}).catch(function(r){var i=j();if("AbortError"===r.name&&i.captureCancelledRequest){var s=Date.now();u.status=C,u.duration=s-u.requestStartTime,n(o.XHR,u),e(r)}P("Error in fetch response: "+r.message),t(r)})})},window.zxhrInit=!0,function(){};function a(e,t,i){var s,a;if(j().captureCancelledRequest){if(!r(t,e.requestMethod))try{s=Date.now();var c,u=i.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==i?void 0:i.responseType)?(d=d||(null==i||null==(c=i.response)?void 0:c.size),a=null==i?void 0:i.response):(a=null!=i&&i.responseText?i.responseText:"",d=d||a.length),e.responseByteSize=d,e.response=a}catch(e){N("Error while capturing response text")}e.duration=s-e.requestStartTime,e.status=null!=i&&i.status?null==i?void 0:i.status:C,n(o.XHR,e)}}}()),n.push(function(e){var t=[F("online",function(t){ue(e)},window)];return t.push(F("offline",function(t){ue(e)},window)),function(){t.forEach(function(e){return e()})}}(de))),n.push(function(e){var t=[];return t.push(F(y,function(t){try{var n=null==t?void 0:t.detail,r=n.message,i=n.options,s=void 0===i?{}:i;N("Capturing log message for message : "+r+" options: "+JSON.stringify(s)),r&&s&&s.constructor===Object?e(J({eventType:o.ZipyLogMessage,data:{message:r.length<h?r:r.substring(0,h),options:s},isError:!1})):T("Didn't capture log message for message :