posthog-js 1.306.1 → 1.306.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var e="undefined"!=typeof window?window:void 0,r="undefined"!=typeof globalThis?globalThis:e;"undefined"==typeof self&&(r.self=r),"undefined"==typeof File&&(r.File=function(){});var t=Array.prototype.forEach,n=null==r?void 0:r.navigator,i=null==r?void 0:r.document,o=null==r?void 0:r.location;null==r||r.fetch,null!=r&&r.XMLHttpRequest&&"withCredentials"in new r.XMLHttpRequest&&r.XMLHttpRequest,null==r||r.AbortController;var a=null==n?void 0:n.userAgent,u=null!=e?e:{},l={LIB_VERSION:"1.306.1"};function s(){return s=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},s.apply(null,arguments)}function c(e,r){return-1!==e.indexOf(r)}var f=Array.isArray,v=Object.prototype,d=v.hasOwnProperty,h=v.toString,p=f||function(e){return"[object Array]"===h.call(e)},g=e=>e===Object(e)&&!p(e),_=e=>{if(g(e)){for(var r in e)if(d.call(e,r))return!1;return!0}return!1},m=e=>void 0===e,w=e=>null===e,b=e=>m(e)||w(e),y=e=>"[object Number]"==h.call(e),x=e=>e instanceof FormData;function E(e,r,t,n,i){return r>t&&(n.warn("min cannot be greater than max."),r=t),y(e)?e>t?(n.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e<r?(n.warn(" cannot be less than min: "+r+". Using min value instead."),r):e:(n.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+i),E(t,r,t,n))}class R{constructor(e){this.t={},this.i=e.i,this.o=E(e.bucketSize,0,100,e.u),this.l=E(e.refillRate,0,this.o,e.u),this.v=E(e.refillInterval,0,864e5,e.u)}h(e,r){var t=r-e.lastAccess,n=Math.floor(t/this.v);if(n>0){var i=n*this.l;e.tokens=Math.min(e.tokens+i,this.o),e.lastAccess=e.lastAccess+n*this.v}}consumeRateLimit(e){var r,t=Date.now(),n=String(e),i=this.t[n];return i?this.h(i,t):(i={tokens:this.o,lastAccess:t},this.t[n]=i),0===i.tokens||(i.tokens--,0===i.tokens&&(null==(r=this.i)||r.call(this,e)),0===i.tokens)}stop(){this.t={}}}var S=function(r,t){var{debugEnabled:n}=void 0===t?{}:t,i={p:function(t){if(e&&(u.POSTHOG_DEBUG||n)&&!m(e.console)&&e.console){for(var i=("__rrweb_original__"in e.console[t]?e.console[t].__rrweb_original__:e.console[t]),o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];i(r,...a)}},info:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i.p("log",...r)},warn:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i.p("warn",...r)},error:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i.p("error",...r)},critical:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.error(r,...t)},uninitializedWarning:e=>{i.error("You must initialize PostHog before calling "+e)},createLogger:(e,t)=>S(r+" "+e,t)};return i},M=S("[PostHog.js]"),k=M.createLogger,O={};function P(e,r,n){if(p(e))if(t&&e.forEach===t)e.forEach(r,n);else if("length"in e&&e.length===+e.length)for(var i=0,o=e.length;i<o;i++)if(i in e&&r.call(n,e[i],i)===O)return}function A(e,r,t){if(!b(e)){if(p(e))return P(e,r,t);if(x(e)){for(var n of e.entries())if(r.call(t,n[1],n[0])===O)return}else for(var i in e)if(d.call(e,i)&&r.call(t,e[i],i)===O)return}}var N=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return P(t,(function(r){for(var t in r)void 0!==r[t]&&(e[t]=r[t])})),e},B=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return P(t,(function(r){P(r,(function(r){e.push(r)}))})),e},I=function(e){var r={};return A(e,(function(e,t){var n;n=e,("[object String]"==h.call(n)&&e.length>0||y(e))&&(r[t]=e)})),r},U=e=>{var r=null==i?void 0:i.createElement("a");return m(r)?null:(r.href=e,r)},T=function(e,r){for(var t,n=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<n.length;i++){var o=n[i].split("=");if(o[0]===r){t=o;break}}if(!p(t)||t.length<2)return"";var a=t[1];try{a=decodeURIComponent(a)}catch(e){M.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},C=function(e,r,t){if(!e||!r||!r.length)return e;for(var n=e.split("#"),i=n[0]||"",o=n[1],a=i.split("?"),u=a[1],l=a[0],s=(u||"").split("&"),c=[],f=0;f<s.length;f++){var v=s[f].split("=");p(v)&&(r.includes(v[0])?c.push(v[0]+"="+t):c.push(s[f]))}var d=l;return null!=u&&(d+="?"+c.join("&")),null!=o&&(d+="#"+o),d},D="Mobile",F="iOS",z="Android",W="Tablet",j=z+" "+W,L="iPad",K="Apple",V=K+" Watch",G="Safari",H="BlackBerry",X="Samsung",q=X+"Browser",J=X+" Internet",Y="Chrome",Q=Y+" OS",Z=Y+" "+F,ee="Internet Explorer",re=ee+" "+D,te="Opera",ne=te+" Mini",ie="Edge",oe="Microsoft "+ie,ae="Firefox",ue=ae+" "+F,le="Nintendo",se="PlayStation",ce="Xbox",fe=z+" "+D,ve=D+" "+G,de="Windows",he=de+" Phone",pe="Nokia",ge="Ouya",_e="Generic",me=_e+" "+D.toLowerCase(),we=_e+" "+W.toLowerCase(),be="Konqueror",ye="(\\d+(\\.\\d+)?)",xe=new RegExp("Version/"+ye),Ee=new RegExp(ce,"i"),$e=new RegExp(se+" \\w+","i"),Re=new RegExp(le+" \\w+","i"),Se=new RegExp(H+"|PlayBook|BB10","i"),Me={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var ke=(e,r)=>r&&c(r,K)||function(e){return c(e,G)&&!c(e,Y)&&!c(e,z)}(e),Oe=function(e,r){return r=r||"",c(e," OPR/")&&c(e,"Mini")?ne:c(e," OPR/")?te:Se.test(e)?H:c(e,"IE"+D)||c(e,"WPDesktop")?re:c(e,q)?J:c(e,ie)||c(e,"Edg/")?oe:c(e,"FBIOS")?"Facebook "+D:c(e,"UCWEB")||c(e,"UCBrowser")?"UC Browser":c(e,"CriOS")?Z:c(e,"CrMo")||c(e,Y)?Y:c(e,z)&&c(e,G)?fe:c(e,"FxiOS")?ue:c(e.toLowerCase(),be.toLowerCase())?be:ke(e,r)?c(e,D)?ve:G:c(e,ae)?ae:c(e,"MSIE")||c(e,"Trident/")?ee:c(e,"Gecko")?ae:""},Pe={[re]:[new RegExp("rv:"+ye)],[oe]:[new RegExp(ie+"?\\/"+ye)],[Y]:[new RegExp("("+Y+"|CrMo)\\/"+ye)],[Z]:[new RegExp("CriOS\\/"+ye)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ye)],[G]:[xe],[ve]:[xe],[te]:[new RegExp("(Opera|OPR)\\/"+ye)],[ae]:[new RegExp(ae+"\\/"+ye)],[ue]:[new RegExp("FxiOS\\/"+ye)],[be]:[new RegExp("Konqueror[:/]?"+ye,"i")],[H]:[new RegExp(H+" "+ye),xe],[fe]:[new RegExp("android\\s"+ye,"i")],[J]:[new RegExp(q+"\\/"+ye)],[ee]:[new RegExp("(rv:|MSIE )"+ye)],Mozilla:[new RegExp("rv:"+ye)]},Ae=function(e,r){var t=Oe(e,r),n=Pe[t];if(m(n))return null;for(var i=0;i<n.length;i++){var o=n[i],a=e.match(o);if(a)return parseFloat(a[a.length-2])}return null},Ne=[[new RegExp(ce+"; "+ce+" (.*?)[);]","i"),e=>[ce,e&&e[1]||""]],[new RegExp(le,"i"),[le,""]],[new RegExp(se,"i"),[se,""]],[Se,[H,""]],[new RegExp(de,"i"),(e,r)=>{if(/Phone/.test(r)||/WPDesktop/.test(r))return[he,""];if(new RegExp(D).test(r)&&!/IEMobile\b/.test(r))return[de+" "+D,""];var t=/Windows NT ([0-9.]+)/i.exec(r);if(t&&t[1]){var n=t[1],i=Me[n]||"";return/arm/i.test(r)&&(i="RT"),[de,i]}return[de,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var r=[e[3],e[4],e[5]||"0"];return[F,r.join(".")]}return[F,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var r="";return e&&e.length>=3&&(r=m(e[2])?e[3]:e[2]),["watchOS",r]}],[new RegExp("("+z+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+z+")","i"),e=>{if(e&&e[2]){var r=[e[2],e[3],e[4]||"0"];return[z,r.join(".")]}return[z,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var r=["Mac OS X",""];if(e&&e[1]){var t=[e[1],e[2],e[3]||"0"];r[1]=t.join(".")}return r}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Q,""]],[/Linux|debian/i,["Linux",""]]],Be=function(e){return Re.test(e)?le:$e.test(e)?se:Ee.test(e)?ce:new RegExp(ge,"i").test(e)?ge:new RegExp("("+he+"|WPDesktop)","i").test(e)?he:/iPad/.test(e)?L:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?V:Se.test(e)?H:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(pe,"i").test(e)?pe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(D).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?z:j:z:new RegExp("(pda|"+D+")","i").test(e)?me:new RegExp(W,"i").test(e)&&!new RegExp(W+" pc","i").test(e)?we:""};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return y(e)&&isFinite(e)&&Math.floor(e)===e});var Ie="0123456789abcdef";class Ue{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,r,t,n){if(!Number.isInteger(e)||!Number.isInteger(r)||!Number.isInteger(t)||!Number.isInteger(n)||e<0||r<0||t<0||n<0||e>0xffffffffffff||r>4095||t>1073741823||n>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=e/Math.pow(2,40),i[1]=e/Math.pow(2,32),i[2]=e/Math.pow(2,24),i[3]=e/Math.pow(2,16),i[4]=e/Math.pow(2,8),i[5]=e,i[6]=112|r>>>8,i[7]=r,i[8]=128|t>>>24,i[9]=t>>>16,i[10]=t>>>8,i[11]=t,i[12]=n>>>24,i[13]=n>>>16,i[14]=n>>>8,i[15]=n,new Ue(i)}toString(){for(var e="",r=0;r<this.bytes.length;r++)e=e+Ie.charAt(this.bytes[r]>>>4)+Ie.charAt(15&this.bytes[r]),3!==r&&5!==r&&7!==r&&9!==r||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Ue(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var r=0;r<16;r++){var t=this.bytes[r]-e.bytes[r];if(0!==t)return Math.sign(t)}return 0}}class Te{constructor(){this.m=0,this.$=0,this.R=new Fe}generate(){var e=this.generateOrAbort();if(m(e)){this.m=0;var r=this.generateOrAbort();if(m(r))throw new Error("Could not generate UUID after timestamp reset");return r}return e}generateOrAbort(){var e=Date.now();if(e>this.m)this.m=e,this.S();else{if(!(e+1e4>this.m))return;this.$++,this.$>4398046511103&&(this.m++,this.S())}return Ue.fromFieldsV7(this.m,Math.trunc(this.$/Math.pow(2,30)),this.$&Math.pow(2,30)-1,this.R.nextUint32())}S(){this.$=1024*this.R.nextUint32()+(1023&this.R.nextUint32())}}var Ce,De=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var r=0;r<e.length;r++)e[r]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!m(e.crypto)&&crypto.getRandomValues&&(De=e=>crypto.getRandomValues(e));class Fe{constructor(){this.M=new Uint32Array(8),this.k=1/0}nextUint32(){return this.k>=this.M.length&&(De(this.M),this.k=0),this.M[this.k++]}}var ze=()=>We().toString(),We=()=>(Ce||(Ce=new Te)).generate(),je="";var Le=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ke(e,r){if(r){var t=function(e,r){if(void 0===r&&(r=i),je)return je;if(!r)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var t=e.split("."),n=Math.min(t.length,8),o="dmn_chk_"+ze();!je&&n--;){var a=t.slice(n).join("."),u=o+"=1;domain=."+a+";path=/";r.cookie=u+";max-age=3",r.cookie.includes(o)&&(r.cookie=u+";max-age=0",je=a)}return je}(e);if(!t){var n=(e=>{var r=e.match(Le);return r?r[0]:""})(e);n!==t&&M.info("Warning: cookie subdomain discovery mismatch",n,t),t=n}return t?"; domain=."+t:""}return""}var Ve={O:()=>!!i,P:function(e){M.error("cookieStore error: "+e)},A:function(e){if(i){try{for(var r=e+"=",t=i.cookie.split(";").filter((e=>e.length)),n=0;n<t.length;n++){for(var o=t[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(r))return decodeURIComponent(o.substring(r.length,o.length))}}catch(e){}return null}},N:function(e){var r;try{r=JSON.parse(Ve.A(e))||{}}catch(e){}return r},B:function(e,r,t,n,o){if(i)try{var a="",u="",l=Ke(i.location.hostname,n);if(t){var s=new Date;s.setTime(s.getTime()+24*t*60*60*1e3),a="; expires="+s.toUTCString()}o&&(u="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(r))+a+"; SameSite=Lax; path=/"+l+u;return c.length>3686.4&&M.warn("cookieStore warning: large cookie, len="+c.length),i.cookie=c,c}catch(e){return}},I:function(e,r){if(null!=i&&i.cookie)try{Ve.B(e,"",-1,r)}catch(e){return}}},Ge=null,He={O:function(){if(!w(Ge))return Ge;var r=!0;if(m(e))r=!1;else try{var t="__mplssupport__";He.B(t,"xyz"),'"xyz"'!==He.A(t)&&(r=!1),He.I(t)}catch(e){r=!1}return r||M.error("localStorage unsupported; falling back to cookie store"),Ge=r,r},P:function(e){M.error("localStorage error: "+e)},A:function(r){try{return null==e?void 0:e.localStorage.getItem(r)}catch(e){He.P(e)}return null},N:function(e){try{return JSON.parse(He.A(e))||{}}catch(e){}return null},B:function(r,t){try{null==e||e.localStorage.setItem(r,JSON.stringify(t))}catch(e){He.P(e)}},I:function(r){try{null==e||e.localStorage.removeItem(r)}catch(e){He.P(e)}}},Xe=["distinct_id","$sesid","$session_is_sampled","$epp","$initial_person_info"];s({},He,{N:function(e){try{var r={};try{r=Ve.N(e)||{}}catch(e){}var t=N(r,JSON.parse(He.A(e)||"{}"));return He.B(e,t),t}catch(e){}return null},B:function(e,r,t,n,i,o){try{He.B(e,r,void 0,void 0,o);var a={};Xe.forEach((e=>{r[e]&&(a[e]=r[e])})),Object.keys(a).length&&Ve.B(e,a,t,n,i,o)}catch(e){He.P(e)}},I:function(r,t){try{null==e||e.localStorage.removeItem(r),Ve.I(r,t)}catch(e){He.P(e)}}});var qe=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Je=B(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],qe),Ye=["$app_build","$app_name","$app_namespace","$app_version","$browser","$browser_version","$device_type","$current_url","$pathname","$os","$os_name","$os_version","$referring_domain","$referrer","$screen_height","$screen_width","$viewport_height","$viewport_width","$raw_user_agent"],Qe="<masked>",Ze=["li_fat_id"];function er(e,r,t){if(!i)return{};var n,o,a,u,l=r?B([],qe,t||[]):[],s=(n=C(i.URL,l,Qe),o=e,a=Je.concat(o||[]),u={},A(a,(function(e){var r=T(n,e);u[e]=r||null})),u),c=function(){var e={};return A(Ze,(function(r){var t=Ve.A(r);e[r]=t||null})),e}();return N(c,s)}function rr(){return navigator.language||navigator.userLanguage}function tr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function nr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function ir(r,t){if(!a)return{};var n,i,u,s=r?B([],qe,t||[]):[],[c,f]=function(e){for(var r=0;r<Ne.length;r++){var[t,n]=Ne[r],i=t.exec(e),o=i&&("function"==typeof n?n(i,e):n);if(o)return o}return["",""]}(a);return N(I({$os:c,$os_version:f,$browser:Oe(a,navigator.vendor),$device:Be(a),$device_type:(i=a,u=Be(i),u===L||u===j||"Kobo"===u||"Kindle Fire"===u||u===we?W:u===le||u===ce||u===se||u===ge?"Console":u===V?"Wearable":u?D:"Desktop"),$timezone:tr(),$timezone_offset:nr()}),{$current_url:C(null==o?void 0:o.href,s,Qe),$host:null==o?void 0:o.host,$pathname:null==o?void 0:o.pathname,$raw_user_agent:a.length>1e3?a.substring(0,997)+"...":a,$browser_version:Ae(a,navigator.vendor),$browser_language:rr(),$browser_language_prefix:(n=rr(),"string"==typeof n?n.split("-")[0]:void 0),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:"web",$lib_version:l.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}function or(e,r){return[...e||[],...p(r)?r:[r]]}function ar(e,r){return(m(e)?1:e)*r}function ur(e,r){return function(e){for(var r=0,t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return Math.abs(r)}(e)%100<E(100*r,0,100,M)}var lr=["type"];function sr(e){var{type:r,executionTimeMs:t}=e;return""+r+(b(t)?"":" ("+t.toFixed(2)+"ms)")}var cr=k("[PostHog Action RateLimiting]");function fr(e,r){console.log(e,r)}function vr(e,r,t){if(void 0===t&&(t=5),"object"!=typeof e||"object"!=typeof r)return{};if(e===r)return{};if(!e&&r)return r;if(!r||!e)return{};var n={},i=new Set([...Object.keys(e),...Object.keys(r)]);for(var o of i){var a=e[o],u=r[o];if(m(a))n[o]=u;else if(m(u))n[o]=a;else if(!(a===u||b(a)&&b(u)))if(g(a)&&g(u))if(t>1){var l=vr(a,u,t-1);_(l)||(n[o]=l)}else n[o]="max depth reached, checking for changed value";else n[o]=u}return n}var dr,hr,pr,gr=(dr=null,hr=0,pr=null,{info:e=>{pr!==e&&(hr=0,pr=e),hr++,dr&&clearTimeout(dr),dr=setTimeout((()=>{var r=hr;1===r?cr.info('action "'+e+'" has been rate limited'):cr.info('action "'+e+'" has been rate limited ('+r+" times)"),hr=0,dr=null}),1e3)}});function _r(e){void 0===e&&(e={});var{maskAction:r,maskState:t,titleFunction:n=sr,logger:i=fr,include:o={prevState:!0,nextState:!1,changedState:!0},rateLimiterRefillRate:a=1,rateLimiterBucketSize:u=10,__stateComparisonDepth:l}=e,s=new R({refillRate:a,bucketSize:u,refillInterval:1e3,u:cr});return e=>a=>u=>{var c=u,f=e.getState(),v=performance.now(),d=a(c),h=performance.now()-v,p=e.getState(),g=r?r(c):c;if(!g)return d;if(s.consumeRateLimit(c.type))gr.info(c.type);else try{var _=t?t(f,g):f,m=t?t(p,g):p,w=o.changedState?vr(_,m,null!=l?l:5):void 0,{type:b}=g,y={type:b,payload:function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(g,lr),timestamp:Date.now(),executionTimeMs:h,prevState:o.prevState?_:void 0,nextState:o.nextState?m:void 0,changedState:o.changedState?w:void 0},x=n(y);i(x,y)}catch(e){cr.error("Error logging state:",e)}return d}}var mr=Object.freeze({__proto__:null,browserConsoleLogger:fr,posthogKeaLogger:function(e){void 0===e&&(e={});var r=_r(e);return{name:"posthog-kea-logger",events:{beforeReduxStore(e){e.middleware.push(r)}}}},posthogReduxLogger:_r,printAndDropEverything:e=>(console.log("Would have sent event:",e),null),sampleByDistinctId:function(e){return r=>r&&ur(r.properties.distinct_id,e)?s({},r,{properties:s({},r.properties,{$sample_type:["sampleByDistinctId"],$sample_threshold:e})}):null},sampleByEvent:function(e,r){return t=>{var n,i,o;return t?c(e,t.event)?100*Math.random()<E(100*r,0,100,M)?s({},t,{properties:s({},t.properties,{$sample_type:or(null==(n=t.properties)?void 0:n.$sample_type,"sampleByEvent"),$sample_threshold:ar(null==(i=t.properties)?void 0:i.$sample_threshold,r),$sampled_events:or(null==(o=t.properties)?void 0:o.$sampled_events,e)})}):null:t:null}},sampleBySessionId:function(e){return r=>r&&ur(r.properties.$session_id,e)?s({},r,{properties:s({},r.properties,{$sample_type:or(r.properties.$sample_type,"sampleBySessionId"),$sample_threshold:ar(r.properties.$sample_threshold,e)})}):null},sessionRecordingLoggerForPostHogInstance:e=>(r,t)=>{var n;null==e||null==(n=e.sessionRecording)||n.tryAddCustomEvent("app-state",{title:r,stateEvent:t})},setAllPersonProfilePropertiesAsPersonPropertiesForFlags:e=>{var r,t=N({},ir(e.config.mask_personal_data_properties,e.config.custom_personal_data_properties),er(e.config.custom_campaign_params,e.config.mask_personal_data_properties,e.config.custom_personal_data_properties),{$referrer:(null==i?void 0:i.referrer)||"$direct",$referring_domain:null!=i&&i.referrer&&(null==(r=U(i.referrer))?void 0:r.host)||"$direct"}),n={};A(t,(function(e,r){(c(Je,r)||c(Ye,r))&&(n[r]=e)})),e.setPersonPropertiesForFlags(n)}});u.posthogCustomizations=mr}();
1
+ !function(){"use strict";var e="undefined"!=typeof window?window:void 0,r="undefined"!=typeof globalThis?globalThis:e;"undefined"==typeof self&&(r.self=r),"undefined"==typeof File&&(r.File=function(){});var t=Array.prototype.forEach,n=null==r?void 0:r.navigator,i=null==r?void 0:r.document,o=null==r?void 0:r.location;null==r||r.fetch,null!=r&&r.XMLHttpRequest&&"withCredentials"in new r.XMLHttpRequest&&r.XMLHttpRequest,null==r||r.AbortController;var a=null==n?void 0:n.userAgent,u=null!=e?e:{},l={LIB_VERSION:"1.306.2"};function s(){return s=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},s.apply(null,arguments)}function c(e,r){return-1!==e.indexOf(r)}var f=Array.isArray,v=Object.prototype,d=v.hasOwnProperty,h=v.toString,p=f||function(e){return"[object Array]"===h.call(e)},g=e=>e===Object(e)&&!p(e),_=e=>{if(g(e)){for(var r in e)if(d.call(e,r))return!1;return!0}return!1},m=e=>void 0===e,w=e=>null===e,b=e=>m(e)||w(e),y=e=>"[object Number]"==h.call(e),x=e=>e instanceof FormData;function E(e,r,t,n,i){return r>t&&(n.warn("min cannot be greater than max."),r=t),y(e)?e>t?(n.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e<r?(n.warn(" cannot be less than min: "+r+". Using min value instead."),r):e:(n.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+i),E(t,r,t,n))}class R{constructor(e){this.t={},this.i=e.i,this.o=E(e.bucketSize,0,100,e.u),this.l=E(e.refillRate,0,this.o,e.u),this.v=E(e.refillInterval,0,864e5,e.u)}h(e,r){var t=r-e.lastAccess,n=Math.floor(t/this.v);if(n>0){var i=n*this.l;e.tokens=Math.min(e.tokens+i,this.o),e.lastAccess=e.lastAccess+n*this.v}}consumeRateLimit(e){var r,t=Date.now(),n=String(e),i=this.t[n];return i?this.h(i,t):(i={tokens:this.o,lastAccess:t},this.t[n]=i),0===i.tokens||(i.tokens--,0===i.tokens&&(null==(r=this.i)||r.call(this,e)),0===i.tokens)}stop(){this.t={}}}var S=function(r,t){var{debugEnabled:n}=void 0===t?{}:t,i={p:function(t){if(e&&(u.POSTHOG_DEBUG||n)&&!m(e.console)&&e.console){for(var i=("__rrweb_original__"in e.console[t]?e.console[t].__rrweb_original__:e.console[t]),o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];i(r,...a)}},info:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i.p("log",...r)},warn:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i.p("warn",...r)},error:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];i.p("error",...r)},critical:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];console.error(r,...t)},uninitializedWarning:e=>{i.error("You must initialize PostHog before calling "+e)},createLogger:(e,t)=>S(r+" "+e,t)};return i},M=S("[PostHog.js]"),k=M.createLogger,O={};function P(e,r,n){if(p(e))if(t&&e.forEach===t)e.forEach(r,n);else if("length"in e&&e.length===+e.length)for(var i=0,o=e.length;i<o;i++)if(i in e&&r.call(n,e[i],i)===O)return}function A(e,r,t){if(!b(e)){if(p(e))return P(e,r,t);if(x(e)){for(var n of e.entries())if(r.call(t,n[1],n[0])===O)return}else for(var i in e)if(d.call(e,i)&&r.call(t,e[i],i)===O)return}}var N=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return P(t,(function(r){for(var t in r)void 0!==r[t]&&(e[t]=r[t])})),e},B=function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return P(t,(function(r){P(r,(function(r){e.push(r)}))})),e},I=function(e){var r={};return A(e,(function(e,t){var n;n=e,("[object String]"==h.call(n)&&e.length>0||y(e))&&(r[t]=e)})),r},U=e=>{var r=null==i?void 0:i.createElement("a");return m(r)?null:(r.href=e,r)},T=function(e,r){for(var t,n=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<n.length;i++){var o=n[i].split("=");if(o[0]===r){t=o;break}}if(!p(t)||t.length<2)return"";var a=t[1];try{a=decodeURIComponent(a)}catch(e){M.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},C=function(e,r,t){if(!e||!r||!r.length)return e;for(var n=e.split("#"),i=n[0]||"",o=n[1],a=i.split("?"),u=a[1],l=a[0],s=(u||"").split("&"),c=[],f=0;f<s.length;f++){var v=s[f].split("=");p(v)&&(r.includes(v[0])?c.push(v[0]+"="+t):c.push(s[f]))}var d=l;return null!=u&&(d+="?"+c.join("&")),null!=o&&(d+="#"+o),d},D="Mobile",F="iOS",z="Android",W="Tablet",j=z+" "+W,L="iPad",K="Apple",V=K+" Watch",G="Safari",H="BlackBerry",X="Samsung",q=X+"Browser",J=X+" Internet",Y="Chrome",Q=Y+" OS",Z=Y+" "+F,ee="Internet Explorer",re=ee+" "+D,te="Opera",ne=te+" Mini",ie="Edge",oe="Microsoft "+ie,ae="Firefox",ue=ae+" "+F,le="Nintendo",se="PlayStation",ce="Xbox",fe=z+" "+D,ve=D+" "+G,de="Windows",he=de+" Phone",pe="Nokia",ge="Ouya",_e="Generic",me=_e+" "+D.toLowerCase(),we=_e+" "+W.toLowerCase(),be="Konqueror",ye="(\\d+(\\.\\d+)?)",xe=new RegExp("Version/"+ye),Ee=new RegExp(ce,"i"),$e=new RegExp(se+" \\w+","i"),Re=new RegExp(le+" \\w+","i"),Se=new RegExp(H+"|PlayBook|BB10","i"),Me={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var ke=(e,r)=>r&&c(r,K)||function(e){return c(e,G)&&!c(e,Y)&&!c(e,z)}(e),Oe=function(e,r){return r=r||"",c(e," OPR/")&&c(e,"Mini")?ne:c(e," OPR/")?te:Se.test(e)?H:c(e,"IE"+D)||c(e,"WPDesktop")?re:c(e,q)?J:c(e,ie)||c(e,"Edg/")?oe:c(e,"FBIOS")?"Facebook "+D:c(e,"UCWEB")||c(e,"UCBrowser")?"UC Browser":c(e,"CriOS")?Z:c(e,"CrMo")||c(e,Y)?Y:c(e,z)&&c(e,G)?fe:c(e,"FxiOS")?ue:c(e.toLowerCase(),be.toLowerCase())?be:ke(e,r)?c(e,D)?ve:G:c(e,ae)?ae:c(e,"MSIE")||c(e,"Trident/")?ee:c(e,"Gecko")?ae:""},Pe={[re]:[new RegExp("rv:"+ye)],[oe]:[new RegExp(ie+"?\\/"+ye)],[Y]:[new RegExp("("+Y+"|CrMo)\\/"+ye)],[Z]:[new RegExp("CriOS\\/"+ye)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ye)],[G]:[xe],[ve]:[xe],[te]:[new RegExp("(Opera|OPR)\\/"+ye)],[ae]:[new RegExp(ae+"\\/"+ye)],[ue]:[new RegExp("FxiOS\\/"+ye)],[be]:[new RegExp("Konqueror[:/]?"+ye,"i")],[H]:[new RegExp(H+" "+ye),xe],[fe]:[new RegExp("android\\s"+ye,"i")],[J]:[new RegExp(q+"\\/"+ye)],[ee]:[new RegExp("(rv:|MSIE )"+ye)],Mozilla:[new RegExp("rv:"+ye)]},Ae=function(e,r){var t=Oe(e,r),n=Pe[t];if(m(n))return null;for(var i=0;i<n.length;i++){var o=n[i],a=e.match(o);if(a)return parseFloat(a[a.length-2])}return null},Ne=[[new RegExp(ce+"; "+ce+" (.*?)[);]","i"),e=>[ce,e&&e[1]||""]],[new RegExp(le,"i"),[le,""]],[new RegExp(se,"i"),[se,""]],[Se,[H,""]],[new RegExp(de,"i"),(e,r)=>{if(/Phone/.test(r)||/WPDesktop/.test(r))return[he,""];if(new RegExp(D).test(r)&&!/IEMobile\b/.test(r))return[de+" "+D,""];var t=/Windows NT ([0-9.]+)/i.exec(r);if(t&&t[1]){var n=t[1],i=Me[n]||"";return/arm/i.test(r)&&(i="RT"),[de,i]}return[de,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var r=[e[3],e[4],e[5]||"0"];return[F,r.join(".")]}return[F,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var r="";return e&&e.length>=3&&(r=m(e[2])?e[3]:e[2]),["watchOS",r]}],[new RegExp("("+z+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+z+")","i"),e=>{if(e&&e[2]){var r=[e[2],e[3],e[4]||"0"];return[z,r.join(".")]}return[z,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var r=["Mac OS X",""];if(e&&e[1]){var t=[e[1],e[2],e[3]||"0"];r[1]=t.join(".")}return r}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Q,""]],[/Linux|debian/i,["Linux",""]]],Be=function(e){return Re.test(e)?le:$e.test(e)?se:Ee.test(e)?ce:new RegExp(ge,"i").test(e)?ge:new RegExp("("+he+"|WPDesktop)","i").test(e)?he:/iPad/.test(e)?L:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?V:Se.test(e)?H:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(pe,"i").test(e)?pe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(D).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?z:j:z:new RegExp("(pda|"+D+")","i").test(e)?me:new RegExp(W,"i").test(e)&&!new RegExp(W+" pc","i").test(e)?we:""};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return y(e)&&isFinite(e)&&Math.floor(e)===e});var Ie="0123456789abcdef";class Ue{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,r,t,n){if(!Number.isInteger(e)||!Number.isInteger(r)||!Number.isInteger(t)||!Number.isInteger(n)||e<0||r<0||t<0||n<0||e>0xffffffffffff||r>4095||t>1073741823||n>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=e/Math.pow(2,40),i[1]=e/Math.pow(2,32),i[2]=e/Math.pow(2,24),i[3]=e/Math.pow(2,16),i[4]=e/Math.pow(2,8),i[5]=e,i[6]=112|r>>>8,i[7]=r,i[8]=128|t>>>24,i[9]=t>>>16,i[10]=t>>>8,i[11]=t,i[12]=n>>>24,i[13]=n>>>16,i[14]=n>>>8,i[15]=n,new Ue(i)}toString(){for(var e="",r=0;r<this.bytes.length;r++)e=e+Ie.charAt(this.bytes[r]>>>4)+Ie.charAt(15&this.bytes[r]),3!==r&&5!==r&&7!==r&&9!==r||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Ue(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var r=0;r<16;r++){var t=this.bytes[r]-e.bytes[r];if(0!==t)return Math.sign(t)}return 0}}class Te{constructor(){this.m=0,this.$=0,this.R=new Fe}generate(){var e=this.generateOrAbort();if(m(e)){this.m=0;var r=this.generateOrAbort();if(m(r))throw new Error("Could not generate UUID after timestamp reset");return r}return e}generateOrAbort(){var e=Date.now();if(e>this.m)this.m=e,this.S();else{if(!(e+1e4>this.m))return;this.$++,this.$>4398046511103&&(this.m++,this.S())}return Ue.fromFieldsV7(this.m,Math.trunc(this.$/Math.pow(2,30)),this.$&Math.pow(2,30)-1,this.R.nextUint32())}S(){this.$=1024*this.R.nextUint32()+(1023&this.R.nextUint32())}}var Ce,De=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var r=0;r<e.length;r++)e[r]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!m(e.crypto)&&crypto.getRandomValues&&(De=e=>crypto.getRandomValues(e));class Fe{constructor(){this.M=new Uint32Array(8),this.k=1/0}nextUint32(){return this.k>=this.M.length&&(De(this.M),this.k=0),this.M[this.k++]}}var ze=()=>We().toString(),We=()=>(Ce||(Ce=new Te)).generate(),je="";var Le=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ke(e,r){if(r){var t=function(e,r){if(void 0===r&&(r=i),je)return je;if(!r)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var t=e.split("."),n=Math.min(t.length,8),o="dmn_chk_"+ze();!je&&n--;){var a=t.slice(n).join("."),u=o+"=1;domain=."+a+";path=/";r.cookie=u+";max-age=3",r.cookie.includes(o)&&(r.cookie=u+";max-age=0",je=a)}return je}(e);if(!t){var n=(e=>{var r=e.match(Le);return r?r[0]:""})(e);n!==t&&M.info("Warning: cookie subdomain discovery mismatch",n,t),t=n}return t?"; domain=."+t:""}return""}var Ve={O:()=>!!i,P:function(e){M.error("cookieStore error: "+e)},A:function(e){if(i){try{for(var r=e+"=",t=i.cookie.split(";").filter((e=>e.length)),n=0;n<t.length;n++){for(var o=t[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(r))return decodeURIComponent(o.substring(r.length,o.length))}}catch(e){}return null}},N:function(e){var r;try{r=JSON.parse(Ve.A(e))||{}}catch(e){}return r},B:function(e,r,t,n,o){if(i)try{var a="",u="",l=Ke(i.location.hostname,n);if(t){var s=new Date;s.setTime(s.getTime()+24*t*60*60*1e3),a="; expires="+s.toUTCString()}o&&(u="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(r))+a+"; SameSite=Lax; path=/"+l+u;return c.length>3686.4&&M.warn("cookieStore warning: large cookie, len="+c.length),i.cookie=c,c}catch(e){return}},I:function(e,r){if(null!=i&&i.cookie)try{Ve.B(e,"",-1,r)}catch(e){return}}},Ge=null,He={O:function(){if(!w(Ge))return Ge;var r=!0;if(m(e))r=!1;else try{var t="__mplssupport__";He.B(t,"xyz"),'"xyz"'!==He.A(t)&&(r=!1),He.I(t)}catch(e){r=!1}return r||M.error("localStorage unsupported; falling back to cookie store"),Ge=r,r},P:function(e){M.error("localStorage error: "+e)},A:function(r){try{return null==e?void 0:e.localStorage.getItem(r)}catch(e){He.P(e)}return null},N:function(e){try{return JSON.parse(He.A(e))||{}}catch(e){}return null},B:function(r,t){try{null==e||e.localStorage.setItem(r,JSON.stringify(t))}catch(e){He.P(e)}},I:function(r){try{null==e||e.localStorage.removeItem(r)}catch(e){He.P(e)}}},Xe=["distinct_id","$sesid","$session_is_sampled","$epp","$initial_person_info"];s({},He,{N:function(e){try{var r={};try{r=Ve.N(e)||{}}catch(e){}var t=N(r,JSON.parse(He.A(e)||"{}"));return He.B(e,t),t}catch(e){}return null},B:function(e,r,t,n,i,o){try{He.B(e,r,void 0,void 0,o);var a={};Xe.forEach((e=>{r[e]&&(a[e]=r[e])})),Object.keys(a).length&&Ve.B(e,a,t,n,i,o)}catch(e){He.P(e)}},I:function(r,t){try{null==e||e.localStorage.removeItem(r),Ve.I(r,t)}catch(e){He.P(e)}}});var qe=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Je=B(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],qe),Ye=["$app_build","$app_name","$app_namespace","$app_version","$browser","$browser_version","$device_type","$current_url","$pathname","$os","$os_name","$os_version","$referring_domain","$referrer","$screen_height","$screen_width","$viewport_height","$viewport_width","$raw_user_agent"],Qe="<masked>",Ze=["li_fat_id"];function er(e,r,t){if(!i)return{};var n,o,a,u,l=r?B([],qe,t||[]):[],s=(n=C(i.URL,l,Qe),o=e,a=Je.concat(o||[]),u={},A(a,(function(e){var r=T(n,e);u[e]=r||null})),u),c=function(){var e={};return A(Ze,(function(r){var t=Ve.A(r);e[r]=t||null})),e}();return N(c,s)}function rr(){return navigator.language||navigator.userLanguage}function tr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function nr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function ir(r,t){if(!a)return{};var n,i,u,s=r?B([],qe,t||[]):[],[c,f]=function(e){for(var r=0;r<Ne.length;r++){var[t,n]=Ne[r],i=t.exec(e),o=i&&("function"==typeof n?n(i,e):n);if(o)return o}return["",""]}(a);return N(I({$os:c,$os_version:f,$browser:Oe(a,navigator.vendor),$device:Be(a),$device_type:(i=a,u=Be(i),u===L||u===j||"Kobo"===u||"Kindle Fire"===u||u===we?W:u===le||u===ce||u===se||u===ge?"Console":u===V?"Wearable":u?D:"Desktop"),$timezone:tr(),$timezone_offset:nr()}),{$current_url:C(null==o?void 0:o.href,s,Qe),$host:null==o?void 0:o.host,$pathname:null==o?void 0:o.pathname,$raw_user_agent:a.length>1e3?a.substring(0,997)+"...":a,$browser_version:Ae(a,navigator.vendor),$browser_language:rr(),$browser_language_prefix:(n=rr(),"string"==typeof n?n.split("-")[0]:void 0),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:"web",$lib_version:l.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}function or(e,r){return[...e||[],...p(r)?r:[r]]}function ar(e,r){return(m(e)?1:e)*r}function ur(e,r){return function(e){for(var r=0,t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return Math.abs(r)}(e)%100<E(100*r,0,100,M)}var lr=["type"];function sr(e){var{type:r,executionTimeMs:t}=e;return""+r+(b(t)?"":" ("+t.toFixed(2)+"ms)")}var cr=k("[PostHog Action RateLimiting]");function fr(e,r){console.log(e,r)}function vr(e,r,t){if(void 0===t&&(t=5),"object"!=typeof e||"object"!=typeof r)return{};if(e===r)return{};if(!e&&r)return r;if(!r||!e)return{};var n={},i=new Set([...Object.keys(e),...Object.keys(r)]);for(var o of i){var a=e[o],u=r[o];if(m(a))n[o]=u;else if(m(u))n[o]=a;else if(!(a===u||b(a)&&b(u)))if(g(a)&&g(u))if(t>1){var l=vr(a,u,t-1);_(l)||(n[o]=l)}else n[o]="max depth reached, checking for changed value";else n[o]=u}return n}var dr,hr,pr,gr=(dr=null,hr=0,pr=null,{info:e=>{pr!==e&&(hr=0,pr=e),hr++,dr&&clearTimeout(dr),dr=setTimeout((()=>{var r=hr;1===r?cr.info('action "'+e+'" has been rate limited'):cr.info('action "'+e+'" has been rate limited ('+r+" times)"),hr=0,dr=null}),1e3)}});function _r(e){void 0===e&&(e={});var{maskAction:r,maskState:t,titleFunction:n=sr,logger:i=fr,include:o={prevState:!0,nextState:!1,changedState:!0},rateLimiterRefillRate:a=1,rateLimiterBucketSize:u=10,__stateComparisonDepth:l}=e,s=new R({refillRate:a,bucketSize:u,refillInterval:1e3,u:cr});return e=>a=>u=>{var c=u,f=e.getState(),v=performance.now(),d=a(c),h=performance.now()-v,p=e.getState(),g=r?r(c):c;if(!g)return d;if(s.consumeRateLimit(c.type))gr.info(c.type);else try{var _=t?t(f,g):f,m=t?t(p,g):p,w=o.changedState?vr(_,m,null!=l?l:5):void 0,{type:b}=g,y={type:b,payload:function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(g,lr),timestamp:Date.now(),executionTimeMs:h,prevState:o.prevState?_:void 0,nextState:o.nextState?m:void 0,changedState:o.changedState?w:void 0},x=n(y);i(x,y)}catch(e){cr.error("Error logging state:",e)}return d}}var mr=Object.freeze({__proto__:null,browserConsoleLogger:fr,posthogKeaLogger:function(e){void 0===e&&(e={});var r=_r(e);return{name:"posthog-kea-logger",events:{beforeReduxStore(e){e.middleware.push(r)}}}},posthogReduxLogger:_r,printAndDropEverything:e=>(console.log("Would have sent event:",e),null),sampleByDistinctId:function(e){return r=>r&&ur(r.properties.distinct_id,e)?s({},r,{properties:s({},r.properties,{$sample_type:["sampleByDistinctId"],$sample_threshold:e})}):null},sampleByEvent:function(e,r){return t=>{var n,i,o;return t?c(e,t.event)?100*Math.random()<E(100*r,0,100,M)?s({},t,{properties:s({},t.properties,{$sample_type:or(null==(n=t.properties)?void 0:n.$sample_type,"sampleByEvent"),$sample_threshold:ar(null==(i=t.properties)?void 0:i.$sample_threshold,r),$sampled_events:or(null==(o=t.properties)?void 0:o.$sampled_events,e)})}):null:t:null}},sampleBySessionId:function(e){return r=>r&&ur(r.properties.$session_id,e)?s({},r,{properties:s({},r.properties,{$sample_type:or(r.properties.$sample_type,"sampleBySessionId"),$sample_threshold:ar(r.properties.$sample_threshold,e)})}):null},sessionRecordingLoggerForPostHogInstance:e=>(r,t)=>{var n;null==e||null==(n=e.sessionRecording)||n.tryAddCustomEvent("app-state",{title:r,stateEvent:t})},setAllPersonProfilePropertiesAsPersonPropertiesForFlags:e=>{var r,t=N({},ir(e.config.mask_personal_data_properties,e.config.custom_personal_data_properties),er(e.config.custom_campaign_params,e.config.mask_personal_data_properties,e.config.custom_personal_data_properties),{$referrer:(null==i?void 0:i.referrer)||"$direct",$referring_domain:null!=i&&i.referrer&&(null==(r=U(i.referrer))?void 0:r.host)||"$direct"}),n={};A(t,(function(e,r){(c(Je,r)||c(Ye,r))&&(n[r]=e)})),e.setPersonPropertiesForFlags(n)}});u.posthogCustomizations=mr}();
2
2
  //# sourceMappingURL=customizations.full.js.map
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var r="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:r;"undefined"==typeof self&&(e.self=e),"undefined"==typeof File&&(e.File=function(){});var n=null==e?void 0:e.navigator;null==e||e.document,null==e||e.location,null==e||e.fetch,null!=e&&e.XMLHttpRequest&&"withCredentials"in new e.XMLHttpRequest&&e.XMLHttpRequest,null==e||e.AbortController,null==n||n.userAgent;var t=null!=r?r:{};function a(r,e,n,t,a,i,o){try{var u=r[i](o),c=u.value}catch(r){return void n(r)}u.done?e(c):Promise.resolve(c).then(t,a)}function i(r){return function(){var e=this,n=arguments;return new Promise((function(t,i){var o=r.apply(e,n);function u(r){a(o,t,i,u,c,"next",r)}function c(r){a(o,t,i,u,c,"throw",r)}u(void 0)}))}}function o(){return o=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)({}).hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},o.apply(null,arguments)}var u=Array.isArray,c=Object.prototype.toString,l=u||function(r){return"[object Array]"===c.call(r)},v=r=>void 0===r,s=r=>"[object String]"==c.call(r);function f(r){return null===r||"object"!=typeof r}function d(r,e){return Object.prototype.toString.call(r)==="[object "+e+"]"}function h(r){return!v(Event)&&function(r,e){try{return r instanceof e}catch(r){return!1}}(r,Event)}var p,y,w;function g(r){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return w&&n.length===y?w:(y=n.length,w=n.reduce(((n,t)=>{p||(p={});var a=p[t];if(a)n[a[0]]=a[1];else for(var i=r(t),o=i.length-1;o>=0;o--){var u=i[o],c=null==u?void 0:u.filename,l=e[t];if(c&&l){n[c]=l,p[t]=[c,l];break}}return n}),{}))}}class b{constructor(r,e,n){void 0===n&&(n=[]),this.coercers=r,this.stackParser=e,this.modifiers=n}buildFromUnknown(r,e){void 0===e&&(e={});var n=e&&e.mechanism||{handled:!0,type:"generic"},t=this.buildCoercingContext(n,e,0).apply(r),a=this.buildParsingContext(),i=this.parseStacktrace(t,a);return{$exception_list:this.convertToExceptionList(i,n),$exception_level:"error"}}modifyFrames(r){var e=this;return i((function*(){for(var n of r)n.stacktrace&&n.stacktrace.frames&&l(n.stacktrace.frames)&&(n.stacktrace.frames=yield e.applyModifiers(n.stacktrace.frames));return r}))()}coerceFallback(r){var e;return{type:"Error",value:"Unknown error",stack:null==(e=r.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(r,e){var n,t;return null!=r.cause&&(n=this.parseStacktrace(r.cause,e)),""!=r.stack&&null!=r.stack&&(t=this.applyChunkIds(this.stackParser(r.stack,r.synthetic?1:0),e.chunkIdMap)),o({},r,{cause:n,stack:t})}applyChunkIds(r,e){return r.map((r=>(r.filename&&e&&(r.chunk_id=e[r.filename]),r)))}applyCoercers(r,e){for(var n of this.coercers)if(n.match(r))return n.coerce(r,e);return this.coerceFallback(e)}applyModifiers(r){var e=this;return i((function*(){var n=r;for(var t of e.modifiers)n=yield t(n);return n}))()}convertToExceptionList(r,e){var n,t,a,i={type:r.type,value:r.value,mechanism:{type:null!==(n=e.type)&&void 0!==n?n:"generic",handled:null===(t=e.handled)||void 0===t||t,synthetic:null!==(a=r.synthetic)&&void 0!==a&&a}};r.stack&&(i.stacktrace={type:"raw",frames:r.stack});var u=[i];return null!=r.cause&&u.push(...this.convertToExceptionList(r.cause,o({},e,{handled:!0}))),u}buildParsingContext(){return{chunkIdMap:g(this.stackParser)}}buildCoercingContext(r,e,n){void 0===n&&(n=0);var t=(n,t)=>{if(t<=4){var a=this.buildCoercingContext(r,e,t);return this.applyCoercers(n,a)}};return o({},e,{syntheticException:0==n?e.syntheticException:void 0,mechanism:r,apply:r=>t(r,n),next:r=>t(r,n+1)})}}var m="?";function E(r,e,n,t,a){var i={platform:r,filename:e,function:"<anonymous>"===n?m:n,in_app:!0};return v(t)||(i.lineno=t),v(a)||(i.colno=a),i}var j=(r,e)=>{var n=-1!==r.indexOf("safari-extension"),t=-1!==r.indexOf("safari-web-extension");return n||t?[-1!==r.indexOf("@")?r.split("@")[0]:m,n?"safari-extension:"+e:"safari-web-extension:"+e]:[r,e]},k=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,x=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,O=/\((\S*)(?::(\d+))(?::(\d+))\)/,S=(r,e)=>{var n=k.exec(r);if(n){var[,t,a,i]=n;return E(e,t,m,+a,+i)}var o=x.exec(r);if(o){if(o[2]&&0===o[2].indexOf("eval")){var u=O.exec(o[2]);u&&(o[2]=u[1],o[3]=u[2],o[4]=u[3])}var[c,l]=j(o[1]||m,o[2]);return E(e,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},A=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,M=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,R=(r,e)=>{var n=A.exec(r);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var t=M.exec(n[3]);t&&(n[1]=n[1]||"eval",n[3]=t[1],n[4]=t[2],n[5]="")}var a=n[3],i=n[1]||m;return[i,a]=j(i,a),E(e,a,i,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},_=/\(error: (.*)\)/,C=50;function D(r){for(var e=arguments.length,n=new Array(e>1?e-1:0),t=1;t<e;t++)n[t-1]=arguments[t];return function(e,t){void 0===t&&(t=0);for(var a=[],i=e.split("\n"),u=t;u<i.length;u++){var c=i[u];if(!(c.length>1024)){var l=_.test(c)?c.replace(_,"$1"):c;if(!l.match(/\S*Error: /)){for(var v of n){var s=v(l,r);if(s){a.push(s);break}}if(a.length>=C)break}}}return function(r){if(!r.length)return[];var e=Array.from(r);return e.reverse(),e.slice(0,C).map((r=>{return o({},r,{filename:r.filename||(n=e,n[n.length-1]||{}).filename,function:r.function||m});var n}))}(a)}}class P{match(r){return this.isDOMException(r)||this.isDOMError(r)}coerce(r,e){var n=s(r.stack);return{type:this.getType(r),value:this.getValue(r),stack:n?r.stack:void 0,cause:r.cause?e.next(r.cause):void 0,synthetic:!1}}getType(r){return this.isDOMError(r)?"DOMError":"DOMException"}getValue(r){var e=r.name||(this.isDOMError(r)?"DOMError":"DOMException");return r.message?e+": "+r.message:e}isDOMException(r){return d(r,"DOMException")}isDOMError(r){return d(r,"DOMError")}}class T{match(r){return r instanceof Error}coerce(r,e){return{type:this.getType(r),value:this.getMessage(r,e),stack:this.getStack(r),cause:r.cause?e.next(r.cause):void 0,synthetic:!1}}getType(r){return r.name||r.constructor.name}getMessage(r,e){var n=r.message;return n.error&&"string"==typeof n.error.message?String(n.error.message):String(n)}getStack(r){return r.stacktrace||r.stack||void 0}}class U{constructor(){}match(r){return d(r,"ErrorEvent")&&null!=r.error}coerce(r,e){var n,t=e.apply(r.error);return t||{type:"ErrorEvent",value:r.message,stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}}var F=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class I{match(r){return"string"==typeof r}coerce(r,e){var n,[t,a]=this.getInfos(r);return{type:null!=t?t:"Error",value:null!=a?a:r,stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}getInfos(r){var e="Error",n=r,t=r.match(F);return t&&(e=t[1],n=t[2]),[e,n]}}var z=["fatal","error","warning","log","info","debug"];function L(r,e){void 0===e&&(e=40);var n=Object.keys(r);if(n.sort(),!n.length)return"[object has no keys]";for(var t=n.length;t>0;t--){var a=n.slice(0,t).join(", ");if(!(a.length>e))return t===n.length||a.length<=e?a:a.slice(0,e)+"..."}return""}class H{match(r){return"object"==typeof r&&null!==r}coerce(r,e){var n,t=this.getErrorPropertyFromObject(r);return t?e.apply(t):{type:this.getType(r),value:this.getValue(r),stack:null==(n=e.syntheticException)?void 0:n.stack,level:this.isSeverityLevel(r.level)?r.level:"error",synthetic:!0}}getType(r){return h(r)?r.constructor.name:"Error"}getValue(r){if("name"in r&&"string"==typeof r.name){var e="'"+r.name+"' captured as exception";return"message"in r&&"string"==typeof r.message&&(e+=" with message: '"+r.message+"'"),e}if("message"in r&&"string"==typeof r.message)return r.message;var n=this.getObjectClassName(r);return(n&&"Object"!==n?"'"+n+"'":"Object")+" captured as exception with keys: "+L(r)}isSeverityLevel(r){return s(r)&&!(r=>s(r)&&0===r.trim().length)(r)&&z.indexOf(r)>=0}getErrorPropertyFromObject(r){for(var e in r)if(Object.prototype.hasOwnProperty.call(r,e)){var n=r[e];if(n instanceof Error)return n}}getObjectClassName(r){try{var e=Object.getPrototypeOf(r);return e?e.constructor.name:void 0}catch(r){return}}}class N{match(r){return h(r)}coerce(r,e){var n,t=r.constructor.name;return{type:t,value:t+" captured as exception with keys: "+L(r),stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}}class V{match(r){return f(r)}coerce(r,e){var n;return{type:"Error",value:"Primitive value captured as exception: "+String(r),stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}}class W{match(r){return d(r,"PromiseRejectionEvent")}coerce(r,e){var n,t=this.getUnhandledRejectionReason(r);return f(t)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(t),stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}:e.apply(t)}getUnhandledRejectionReason(r){if(f(r))return r;try{if("reason"in r)return r.reason;if("detail"in r&&"reason"in r.detail)return r.detail.reason}catch(r){}return r}}var Y=function(e,n){var{debugEnabled:a}=void 0===n?{}:n,i={t:function(n){if(r&&(t.POSTHOG_DEBUG||a)&&!v(r.console)&&r.console){for(var i=("__rrweb_original__"in r.console[n]?r.console[n].__rrweb_original__:r.console[n]),o=arguments.length,u=new Array(o>1?o-1:0),c=1;c<o;c++)u[c-1]=arguments[c];i(e,...u)}},info:function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];i.t("log",...e)},warn:function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];i.t("warn",...e)},error:function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];i.t("error",...e)},critical:function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];console.error(e,...n)},uninitializedWarning:r=>{i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Y(e+" "+r,n)};return i},q=Y("[PostHog.js]").createLogger;null!=n&&n.sendBeacon,q("[Error tracking]");var B=q("[ExceptionAutocapture]"),G=new b([new P,new W,new U,new T,new N,new H,new I,new V],D("web:javascript",S,R));function J(r){var{event:e,error:n}=r;return G.buildFromUnknown(n||e,{mechanism:{handled:!1}})}var K={wrapOnError:e=>{var n=r;n||B.info("window not available, cannot wrap onerror");var t=n.onerror;return n.onerror=function(){for(var r,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];var o=J({event:a[0],error:a[4]});return e(o),null!==(r=null==t?void 0:t(...a))&&void 0!==r&&r},n.onerror.__POSTHOG_INSTRUMENTED__=!0,()=>{var r;null==(r=n.onerror)||delete r.__POSTHOG_INSTRUMENTED__,n.onerror=t}},wrapUnhandledRejection:e=>{var n=r;n||B.info("window not available, cannot wrap onUnhandledRejection");var t=n.onunhandledrejection;return n.onunhandledrejection=function(r){var a,i=J({event:r});return e(i),null!==(a=null==t?void 0:t.apply(n,[r]))&&void 0!==a&&a},n.onunhandledrejection.__POSTHOG_INSTRUMENTED__=!0,()=>{var r;null==(r=n.onunhandledrejection)||delete r.__POSTHOG_INSTRUMENTED__,n.onunhandledrejection=t}},wrapConsoleError:r=>{var e=console;e||B.info("console not available, cannot wrap console.error");var n=e.error;return e.error=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];var i=t.join(" "),o=J({error:t.find((r=>r instanceof Error)),event:i});return r(o),null==n?void 0:n(...t)},e.error.__POSTHOG_INSTRUMENTED__=!0,()=>{var r;null==(r=e.error)||delete r.__POSTHOG_INSTRUMENTED__,e.error=n}}};t.__PosthogExtensions__=t.__PosthogExtensions__||{},t.__PosthogExtensions__.errorWrappingFunctions=K,t.posthogErrorWrappingFunctions=K}();
1
+ !function(){"use strict";var r="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:r;"undefined"==typeof self&&(e.self=e),"undefined"==typeof File&&(e.File=function(){});var n=null==e?void 0:e.navigator;null==e||e.document,null==e||e.location,null==e||e.fetch,null!=e&&e.XMLHttpRequest&&"withCredentials"in new e.XMLHttpRequest&&e.XMLHttpRequest,null==e||e.AbortController,null==n||n.userAgent;var t=null!=r?r:{};function i(r,e,n,t,i,a,o){try{var u=r[a](o),c=u.value}catch(r){return void n(r)}u.done?e(c):Promise.resolve(c).then(t,i)}function a(r){return function(){var e=this,n=arguments;return new Promise((function(t,a){var o=r.apply(e,n);function u(r){i(o,t,a,u,c,"next",r)}function c(r){i(o,t,a,u,c,"throw",r)}u(void 0)}))}}function o(){return o=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)({}).hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},o.apply(null,arguments)}var u=Array.isArray,c=Object.prototype.toString,l=u||function(r){return"[object Array]"===c.call(r)},s=r=>void 0===r,v=r=>"[object String]"==c.call(r);function f(r){return null===r||"object"!=typeof r}function d(r,e){return Object.prototype.toString.call(r)==="[object "+e+"]"}function h(r){return!s(Event)&&function(r,e){try{return r instanceof e}catch(r){return!1}}(r,Event)}var p,y,w;function g(r){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return w&&n.length===y?w:(y=n.length,w=n.reduce(((n,t)=>{p||(p={});var i=p[t];if(i)n[i[0]]=i[1];else for(var a=r(t),o=a.length-1;o>=0;o--){var u=a[o],c=null==u?void 0:u.filename,l=e[t];if(c&&l){n[c]=l,p[t]=[c,l];break}}return n}),{}))}}class b{constructor(r,e,n){void 0===n&&(n=[]),this.coercers=r,this.stackParser=e,this.modifiers=n}buildFromUnknown(r,e){void 0===e&&(e={});var n=e&&e.mechanism||{handled:!0,type:"generic"},t=this.buildCoercingContext(n,e,0).apply(r),i=this.buildParsingContext(),a=this.parseStacktrace(t,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:"error"}}modifyFrames(r){var e=this;return a((function*(){for(var n of r)n.stacktrace&&n.stacktrace.frames&&l(n.stacktrace.frames)&&(n.stacktrace.frames=yield e.applyModifiers(n.stacktrace.frames));return r}))()}coerceFallback(r){var e;return{type:"Error",value:"Unknown error",stack:null==(e=r.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(r,e){var n,t;return null!=r.cause&&(n=this.parseStacktrace(r.cause,e)),""!=r.stack&&null!=r.stack&&(t=this.applyChunkIds(this.stackParser(r.stack,r.synthetic?1:0),e.chunkIdMap)),o({},r,{cause:n,stack:t})}applyChunkIds(r,e){return r.map((r=>(r.filename&&e&&(r.chunk_id=e[r.filename]),r)))}applyCoercers(r,e){for(var n of this.coercers)if(n.match(r))return n.coerce(r,e);return this.coerceFallback(e)}applyModifiers(r){var e=this;return a((function*(){var n=r;for(var t of e.modifiers)n=yield t(n);return n}))()}convertToExceptionList(r,e){var n,t,i,a={type:r.type,value:r.value,mechanism:{type:null!==(n=e.type)&&void 0!==n?n:"generic",handled:null===(t=e.handled)||void 0===t||t,synthetic:null!==(i=r.synthetic)&&void 0!==i&&i}};r.stack&&(a.stacktrace={type:"raw",frames:r.stack});var u=[a];return null!=r.cause&&u.push(...this.convertToExceptionList(r.cause,o({},e,{handled:!0}))),u}buildParsingContext(){return{chunkIdMap:g(this.stackParser)}}buildCoercingContext(r,e,n){void 0===n&&(n=0);var t=(n,t)=>{if(t<=4){var i=this.buildCoercingContext(r,e,t);return this.applyCoercers(n,i)}};return o({},e,{syntheticException:0==n?e.syntheticException:void 0,mechanism:r,apply:r=>t(r,n),next:r=>t(r,n+1)})}}var m="?";function E(r,e,n,t,i){var a={platform:r,filename:e,function:"<anonymous>"===n?m:n,in_app:!0};return s(t)||(a.lineno=t),s(i)||(a.colno=i),a}var j=(r,e)=>{var n=-1!==r.indexOf("safari-extension"),t=-1!==r.indexOf("safari-web-extension");return n||t?[-1!==r.indexOf("@")?r.split("@")[0]:m,n?"safari-extension:"+e:"safari-web-extension:"+e]:[r,e]},x=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,k=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,O=/\((\S*)(?::(\d+))(?::(\d+))\)/,S=(r,e)=>{var n=x.exec(r);if(n){var[,t,i,a]=n;return E(e,t,m,+i,+a)}var o=k.exec(r);if(o){if(o[2]&&0===o[2].indexOf("eval")){var u=O.exec(o[2]);u&&(o[2]=u[1],o[3]=u[2],o[4]=u[3])}var[c,l]=j(o[1]||m,o[2]);return E(e,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},A=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,M=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,P=(r,e)=>{var n=A.exec(r);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var t=M.exec(n[3]);t&&(n[1]=n[1]||"eval",n[3]=t[1],n[4]=t[2],n[5]="")}var i=n[3],a=n[1]||m;return[a,i]=j(a,i),E(e,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},R=/\(error: (.*)\)/,_=50;function C(r){for(var e=arguments.length,n=new Array(e>1?e-1:0),t=1;t<e;t++)n[t-1]=arguments[t];return function(e,t){void 0===t&&(t=0);for(var i=[],a=e.split("\n"),u=t;u<a.length;u++){var c=a[u];if(!(c.length>1024)){var l=R.test(c)?c.replace(R,"$1"):c;if(!l.match(/\S*Error: /)){for(var s of n){var v=s(l,r);if(v){i.push(v);break}}if(i.length>=_)break}}}return function(r){if(!r.length)return[];var e=Array.from(r);return e.reverse(),e.slice(0,_).map((r=>{return o({},r,{filename:r.filename||(n=e,n[n.length-1]||{}).filename,function:r.function||m});var n}))}(i)}}class D{match(r){return this.isDOMException(r)||this.isDOMError(r)}coerce(r,e){var n=v(r.stack);return{type:this.getType(r),value:this.getValue(r),stack:n?r.stack:void 0,cause:r.cause?e.next(r.cause):void 0,synthetic:!1}}getType(r){return this.isDOMError(r)?"DOMError":"DOMException"}getValue(r){var e=r.name||(this.isDOMError(r)?"DOMError":"DOMException");return r.message?e+": "+r.message:e}isDOMException(r){return d(r,"DOMException")}isDOMError(r){return d(r,"DOMError")}}class T{match(r){return r instanceof Error}coerce(r,e){return{type:this.getType(r),value:this.getMessage(r,e),stack:this.getStack(r),cause:r.cause?e.next(r.cause):void 0,synthetic:!1}}getType(r){return r.name||r.constructor.name}getMessage(r,e){var n=r.message;return n.error&&"string"==typeof n.error.message?String(n.error.message):String(n)}getStack(r){return r.stacktrace||r.stack||void 0}}class U{constructor(){}match(r){return d(r,"ErrorEvent")&&null!=r.error}coerce(r,e){var n,t=e.apply(r.error);return t||{type:"ErrorEvent",value:r.message,stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}}var F=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class I{match(r){return"string"==typeof r}coerce(r,e){var n,[t,i]=this.getInfos(r);return{type:null!=t?t:"Error",value:null!=i?i:r,stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}getInfos(r){var e="Error",n=r,t=r.match(F);return t&&(e=t[1],n=t[2]),[e,n]}}var z=["fatal","error","warning","log","info","debug"];function H(r,e){void 0===e&&(e=40);var n=Object.keys(r);if(n.sort(),!n.length)return"[object has no keys]";for(var t=n.length;t>0;t--){var i=n.slice(0,t).join(", ");if(!(i.length>e))return t===n.length||i.length<=e?i:i.slice(0,e)+"..."}return""}class L{match(r){return"object"==typeof r&&null!==r}coerce(r,e){var n,t=this.getErrorPropertyFromObject(r);return t?e.apply(t):{type:this.getType(r),value:this.getValue(r),stack:null==(n=e.syntheticException)?void 0:n.stack,level:this.isSeverityLevel(r.level)?r.level:"error",synthetic:!0}}getType(r){return h(r)?r.constructor.name:"Error"}getValue(r){if("name"in r&&"string"==typeof r.name){var e="'"+r.name+"' captured as exception";return"message"in r&&"string"==typeof r.message&&(e+=" with message: '"+r.message+"'"),e}if("message"in r&&"string"==typeof r.message)return r.message;var n=this.getObjectClassName(r);return(n&&"Object"!==n?"'"+n+"'":"Object")+" captured as exception with keys: "+H(r)}isSeverityLevel(r){return v(r)&&!(r=>v(r)&&0===r.trim().length)(r)&&z.indexOf(r)>=0}getErrorPropertyFromObject(r){for(var e in r)if(Object.prototype.hasOwnProperty.call(r,e)){var n=r[e];if(n instanceof Error)return n}}getObjectClassName(r){try{var e=Object.getPrototypeOf(r);return e?e.constructor.name:void 0}catch(r){return}}}class N{match(r){return h(r)}coerce(r,e){var n,t=r.constructor.name;return{type:t,value:t+" captured as exception with keys: "+H(r),stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}}class V{match(r){return f(r)}coerce(r,e){var n;return{type:"Error",value:"Primitive value captured as exception: "+String(r),stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}}}class W{match(r){return d(r,"PromiseRejectionEvent")}coerce(r,e){var n,t=this.getUnhandledRejectionReason(r);return f(t)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(t),stack:null==(n=e.syntheticException)?void 0:n.stack,synthetic:!0}:e.apply(t)}getUnhandledRejectionReason(r){if(f(r))return r;try{if("reason"in r)return r.reason;if("detail"in r&&"reason"in r.detail)return r.detail.reason}catch(r){}return r}}var Y=function(e,n){var{debugEnabled:i}=void 0===n?{}:n,a={t:function(n){if(r&&(t.POSTHOG_DEBUG||i)&&!s(r.console)&&r.console){for(var a=("__rrweb_original__"in r.console[n]?r.console[n].__rrweb_original__:r.console[n]),o=arguments.length,u=new Array(o>1?o-1:0),c=1;c<o;c++)u[c-1]=arguments[c];a(e,...u)}},info:function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];a.t("log",...e)},warn:function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];a.t("warn",...e)},error:function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];a.t("error",...e)},critical:function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];console.error(e,...n)},uninitializedWarning:r=>{a.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Y(e+" "+r,n)};return a},q=Y("[PostHog.js]").createLogger;null!=n&&n.sendBeacon,q("[Error tracking]");var B=q("[ExceptionAutocapture]"),G=new b([new D,new W,new U,new T,new N,new L,new I,new V],C("web:javascript",S,P)),J={wrapOnError:e=>{var n=r;n||B.info("window not available, cannot wrap onerror");var t=n.onerror;return n.onerror=function(){for(var r,n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];var o=i[4],u=i[0],c=G.buildFromUnknown(o||u,{mechanism:{handled:!1}});return e(c),null!==(r=null==t?void 0:t(...i))&&void 0!==r&&r},n.onerror.__POSTHOG_INSTRUMENTED__=!0,()=>{var r;null==(r=n.onerror)||delete r.__POSTHOG_INSTRUMENTED__,n.onerror=t}},wrapUnhandledRejection:e=>{var n=r;n||B.info("window not available, cannot wrap onUnhandledRejection");var t=n.onunhandledrejection;return n.onunhandledrejection=function(r){var i,a=G.buildFromUnknown(r,{mechanism:{handled:!1}});return e(a),null!==(i=null==t?void 0:t.apply(n,[r]))&&void 0!==i&&i},n.onunhandledrejection.__POSTHOG_INSTRUMENTED__=!0,()=>{var r;null==(r=n.onunhandledrejection)||delete r.__POSTHOG_INSTRUMENTED__,n.onunhandledrejection=t}},wrapConsoleError:r=>{var e=console;e||B.info("console not available, cannot wrap console.error");var n=e.error;return e.error=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var a=t.join(" "),o=t.find((r=>r instanceof Error)),u=G.buildFromUnknown(o||a,{mechanism:{handled:!1},syntheticException:new Error("PostHog syntheticException")});return r(u),null==n?void 0:n(...t)},e.error.__POSTHOG_INSTRUMENTED__=!0,()=>{var r;null==(r=e.error)||delete r.__POSTHOG_INSTRUMENTED__,e.error=n}}};t.__PosthogExtensions__=t.__PosthogExtensions__||{},t.__PosthogExtensions__.errorWrappingFunctions=J,t.posthogErrorWrappingFunctions=J}();
2
2
  //# sourceMappingURL=exception-autocapture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exception-autocapture.js","sources":["../src/utils/globals.ts","../../core/dist/utils/type-utils.mjs","../../core/dist/utils/index.mjs","../../core/dist/error-tracking/chunk-ids.mjs","../../core/dist/error-tracking/error-properties-builder.mjs","../../core/dist/error-tracking/parsers/base.mjs","../../core/dist/error-tracking/parsers/safari.mjs","../../core/dist/error-tracking/parsers/chrome.mjs","../../core/dist/error-tracking/parsers/gecko.mjs","../../core/dist/error-tracking/parsers/index.mjs","../../core/dist/error-tracking/coercers/dom-exception-coercer.mjs","../../core/dist/error-tracking/coercers/error-coercer.mjs","../../core/dist/error-tracking/coercers/error-event-coercer.mjs","../../core/dist/error-tracking/coercers/string-coercer.mjs","../../core/dist/error-tracking/types.mjs","../../core/dist/error-tracking/coercers/utils.mjs","../../core/dist/error-tracking/coercers/object-coercer.mjs","../../core/dist/error-tracking/coercers/event-coercer.mjs","../../core/dist/error-tracking/coercers/primitive-coercer.mjs","../../core/dist/error-tracking/coercers/promise-rejection-event.mjs","../src/utils/logger.ts","../src/request.ts","../src/posthog-exceptions.ts","../src/entrypoints/exception-autocapture.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\n\n/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n tracingHeadersPatchFns?: {\n _patchFetch: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n _patchXHR: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\n\nexport const ArrayProto = Array.prototype\nexport const nativeForEach = ArrayProto.forEach\nexport const nativeIndexOf = ArrayProto.indexOf\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","import { knownUnsafeEditableEvent } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return !isUndefined(Event) && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isInstanceOf, isKnownUnsafeEditableEvent, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","export * from \"./bot-detection.mjs\";\nexport * from \"./bucketed-rate-limiter.mjs\";\nexport * from \"./number-utils.mjs\";\nexport * from \"./string-utils.mjs\";\nexport * from \"./type-utils.mjs\";\nexport * from \"./promise-queue.mjs\";\nexport * from \"./logger.mjs\";\nconst STRING_FORMAT = 'utf8';\nfunction assert(truthyValue, message) {\n if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);\n}\nfunction isEmpty(truthyValue) {\n if (0 === truthyValue.trim().length) return true;\n return false;\n}\nfunction removeTrailingSlash(url) {\n return url?.replace(/\\/+$/, '');\n}\nasync function retriable(fn, props) {\n let lastError = null;\n for(let i = 0; i < props.retryCount + 1; i++){\n if (i > 0) await new Promise((r)=>setTimeout(r, props.retryDelay));\n try {\n const res = await fn();\n return res;\n } catch (e) {\n lastError = e;\n if (!props.retryCheck(e)) throw e;\n }\n }\n throw lastError;\n}\nfunction currentTimestamp() {\n return new Date().getTime();\n}\nfunction currentISOTime() {\n return new Date().toISOString();\n}\nfunction safeSetTimeout(fn, timeout) {\n const t = setTimeout(fn, timeout);\n t?.unref && t?.unref();\n return t;\n}\nconst isPromise = (obj)=>obj && 'function' == typeof obj.then;\nconst isError = (x)=>x instanceof Error;\nfunction getFetch() {\n return 'undefined' != typeof fetch ? fetch : void 0 !== globalThis.fetch ? globalThis.fetch : void 0;\n}\nfunction allSettled(promises) {\n return Promise.all(promises.map((p)=>(p ?? Promise.resolve()).then((value)=>({\n status: 'fulfilled',\n value\n }), (reason)=>({\n status: 'rejected',\n reason\n }))));\n}\nexport { STRING_FORMAT, allSettled, assert, currentISOTime, currentTimestamp, getFetch, isError, isPromise, removeTrailingSlash, retriable, safeSetTimeout };\n","let parsedStackResults;\nlet lastKeysCount;\nlet cachedFilenameChunkIds;\nfunction getFilenameToChunkIdMap(stackParser) {\n const chunkIdMap = globalThis._posthogChunkIds;\n if (!chunkIdMap) return;\n const chunkIdKeys = Object.keys(chunkIdMap);\n if (cachedFilenameChunkIds && chunkIdKeys.length === lastKeysCount) return cachedFilenameChunkIds;\n lastKeysCount = chunkIdKeys.length;\n cachedFilenameChunkIds = chunkIdKeys.reduce((acc, stackKey)=>{\n if (!parsedStackResults) parsedStackResults = {};\n const result = parsedStackResults[stackKey];\n if (result) acc[result[0]] = result[1];\n else {\n const parsedStack = stackParser(stackKey);\n for(let i = parsedStack.length - 1; i >= 0; i--){\n const stackFrame = parsedStack[i];\n const filename = stackFrame?.filename;\n const chunkId = chunkIdMap[stackKey];\n if (filename && chunkId) {\n acc[filename] = chunkId;\n parsedStackResults[stackKey] = [\n filename,\n chunkId\n ];\n break;\n }\n }\n }\n return acc;\n }, {});\n return cachedFilenameChunkIds;\n}\nexport { getFilenameToChunkIdMap };\n","import { isArray } from \"../utils/index.mjs\";\nimport { getFilenameToChunkIdMap } from \"./chunk-ids.mjs\";\nconst MAX_CAUSE_RECURSION = 4;\nclass ErrorPropertiesBuilder {\n constructor(coercers, stackParser, modifiers = []){\n this.coercers = coercers;\n this.stackParser = stackParser;\n this.modifiers = modifiers;\n }\n buildFromUnknown(input, hint = {}) {\n const providedMechanism = hint && hint.mechanism;\n const mechanism = providedMechanism || {\n handled: true,\n type: 'generic'\n };\n const coercingContext = this.buildCoercingContext(mechanism, hint, 0);\n const exceptionWithCause = coercingContext.apply(input);\n const parsingContext = this.buildParsingContext();\n const exceptionWithStack = this.parseStacktrace(exceptionWithCause, parsingContext);\n const exceptionList = this.convertToExceptionList(exceptionWithStack, mechanism);\n return {\n $exception_list: exceptionList,\n $exception_level: 'error'\n };\n }\n async modifyFrames(exceptionList) {\n for (const exc of exceptionList)if (exc.stacktrace && exc.stacktrace.frames && isArray(exc.stacktrace.frames)) exc.stacktrace.frames = await this.applyModifiers(exc.stacktrace.frames);\n return exceptionList;\n }\n coerceFallback(ctx) {\n return {\n type: 'Error',\n value: 'Unknown error',\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n parseStacktrace(err, ctx) {\n let cause;\n if (null != err.cause) cause = this.parseStacktrace(err.cause, ctx);\n let stack;\n if ('' != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ? 1 : 0), ctx.chunkIdMap);\n return {\n ...err,\n cause,\n stack\n };\n }\n applyChunkIds(frames, chunkIdMap) {\n return frames.map((frame)=>{\n if (frame.filename && chunkIdMap) frame.chunk_id = chunkIdMap[frame.filename];\n return frame;\n });\n }\n applyCoercers(input, ctx) {\n for (const adapter of this.coercers)if (adapter.match(input)) return adapter.coerce(input, ctx);\n return this.coerceFallback(ctx);\n }\n async applyModifiers(frames) {\n let newFrames = frames;\n for (const modifier of this.modifiers)newFrames = await modifier(newFrames);\n return newFrames;\n }\n convertToExceptionList(exceptionWithStack, mechanism) {\n const currentException = {\n type: exceptionWithStack.type,\n value: exceptionWithStack.value,\n mechanism: {\n type: mechanism.type ?? 'generic',\n handled: mechanism.handled ?? true,\n synthetic: exceptionWithStack.synthetic ?? false\n }\n };\n if (exceptionWithStack.stack) currentException.stacktrace = {\n type: 'raw',\n frames: exceptionWithStack.stack\n };\n const exceptionList = [\n currentException\n ];\n if (null != exceptionWithStack.cause) exceptionList.push(...this.convertToExceptionList(exceptionWithStack.cause, {\n ...mechanism,\n handled: true\n }));\n return exceptionList;\n }\n buildParsingContext() {\n const context = {\n chunkIdMap: getFilenameToChunkIdMap(this.stackParser)\n };\n return context;\n }\n buildCoercingContext(mechanism, hint, depth = 0) {\n const coerce = (input, depth)=>{\n if (!(depth <= MAX_CAUSE_RECURSION)) return;\n {\n const ctx = this.buildCoercingContext(mechanism, hint, depth);\n return this.applyCoercers(input, ctx);\n }\n };\n const context = {\n ...hint,\n syntheticException: 0 == depth ? hint.syntheticException : void 0,\n mechanism,\n apply: (input)=>coerce(input, depth),\n next: (input)=>coerce(input, depth + 1)\n };\n return context;\n }\n}\nexport { ErrorPropertiesBuilder };\n","import { isUndefined } from \"../../utils/index.mjs\";\nconst UNKNOWN_FUNCTION = '?';\nfunction createFrame(platform, filename, func, lineno, colno) {\n const frame = {\n platform,\n filename,\n function: '<anonymous>' === func ? UNKNOWN_FUNCTION : func,\n in_app: true\n };\n if (!isUndefined(lineno)) frame.lineno = lineno;\n if (!isUndefined(colno)) frame.colno = colno;\n return frame;\n}\nexport { UNKNOWN_FUNCTION, createFrame };\n","import { UNKNOWN_FUNCTION } from \"./base.mjs\";\nconst extractSafariExtensionDetails = (func, filename)=>{\n const isSafariExtension = -1 !== func.indexOf('safari-extension');\n const isSafariWebExtension = -1 !== func.indexOf('safari-web-extension');\n return isSafariExtension || isSafariWebExtension ? [\n -1 !== func.indexOf('@') ? func.split('@')[0] : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`\n ] : [\n func,\n filename\n ];\n};\nexport { extractSafariExtensionDetails };\n","import { UNKNOWN_FUNCTION, createFrame } from \"./base.mjs\";\nimport { extractSafariExtensionDetails } from \"./safari.mjs\";\nconst chromeRegexNoFnName = /^\\s*at (\\S+?)(?::(\\d+))(?::(\\d+))\\s*$/i;\nconst chromeRegex = /^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i;\nconst chromeEvalRegex = /\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/;\nconst chromeStackLineParser = (line, platform)=>{\n const noFnParts = chromeRegexNoFnName.exec(line);\n if (noFnParts) {\n const [, filename, line, col] = noFnParts;\n return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);\n }\n const parts = chromeRegex.exec(line);\n if (parts) {\n const isEval = parts[2] && 0 === parts[2].indexOf('eval');\n if (isEval) {\n const subMatch = chromeEvalRegex.exec(parts[2]);\n if (subMatch) {\n parts[2] = subMatch[1];\n parts[3] = subMatch[2];\n parts[4] = subMatch[3];\n }\n }\n const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]);\n return createFrame(platform, filename, func, parts[3] ? +parts[3] : void 0, parts[4] ? +parts[4] : void 0);\n }\n};\nexport { chromeStackLineParser };\n","import { UNKNOWN_FUNCTION, createFrame } from \"./base.mjs\";\nimport { extractSafariExtensionDetails } from \"./safari.mjs\";\nconst geckoREgex = /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i;\nconst geckoEvalRegex = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i;\nconst geckoStackLineParser = (line, platform)=>{\n const parts = geckoREgex.exec(line);\n if (parts) {\n const isEval = parts[3] && parts[3].indexOf(' > eval') > -1;\n if (isEval) {\n const subMatch = geckoEvalRegex.exec(parts[3]);\n if (subMatch) {\n parts[1] = parts[1] || 'eval';\n parts[3] = subMatch[1];\n parts[4] = subMatch[2];\n parts[5] = '';\n }\n }\n let filename = parts[3];\n let func = parts[1] || UNKNOWN_FUNCTION;\n [func, filename] = extractSafariExtensionDetails(func, filename);\n return createFrame(platform, filename, func, parts[4] ? +parts[4] : void 0, parts[5] ? +parts[5] : void 0);\n }\n};\nexport { geckoStackLineParser };\n","import { UNKNOWN_FUNCTION } from \"./base.mjs\";\nimport { chromeStackLineParser } from \"./chrome.mjs\";\nimport { winjsStackLineParser } from \"./winjs.mjs\";\nimport { geckoStackLineParser } from \"./gecko.mjs\";\nimport { opera10StackLineParser, opera11StackLineParser } from \"./opera.mjs\";\nimport { nodeStackLineParser } from \"./node.mjs\";\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/;\nconst STACKTRACE_FRAME_LIMIT = 50;\nfunction reverseAndStripFrames(stack) {\n if (!stack.length) return [];\n const localStack = Array.from(stack);\n localStack.reverse();\n return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame)=>({\n ...frame,\n filename: frame.filename || getLastStackFrame(localStack).filename,\n function: frame.function || UNKNOWN_FUNCTION\n }));\n}\nfunction getLastStackFrame(arr) {\n return arr[arr.length - 1] || {};\n}\nfunction createStackParser(platform, ...parsers) {\n return (stack, skipFirstLines = 0)=>{\n const frames = [];\n const lines = stack.split('\\n');\n for(let i = skipFirstLines; i < lines.length; i++){\n const line = lines[i];\n if (line.length > 1024) continue;\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;\n if (!cleanedLine.match(/\\S*Error: /)) {\n for (const parser of parsers){\n const frame = parser(cleanedLine, platform);\n if (frame) {\n frames.push(frame);\n break;\n }\n }\n if (frames.length >= STACKTRACE_FRAME_LIMIT) break;\n }\n }\n return reverseAndStripFrames(frames);\n };\n}\nexport { chromeStackLineParser, createStackParser, geckoStackLineParser, nodeStackLineParser, opera10StackLineParser, opera11StackLineParser, reverseAndStripFrames, winjsStackLineParser };\n","import { isBuiltin, isString } from \"../../utils/index.mjs\";\nclass DOMExceptionCoercer {\n match(err) {\n return this.isDOMException(err) || this.isDOMError(err);\n }\n coerce(err, ctx) {\n const hasStack = isString(err.stack);\n return {\n type: this.getType(err),\n value: this.getValue(err),\n stack: hasStack ? err.stack : void 0,\n cause: err.cause ? ctx.next(err.cause) : void 0,\n synthetic: false\n };\n }\n getType(candidate) {\n return this.isDOMError(candidate) ? 'DOMError' : 'DOMException';\n }\n getValue(err) {\n const name = err.name || (this.isDOMError(err) ? 'DOMError' : 'DOMException');\n const message = err.message ? `${name}: ${err.message}` : name;\n return message;\n }\n isDOMException(err) {\n return isBuiltin(err, 'DOMException');\n }\n isDOMError(err) {\n return isBuiltin(err, 'DOMError');\n }\n}\nexport { DOMExceptionCoercer };\n","import { isPlainError } from \"../../utils/index.mjs\";\nclass ErrorCoercer {\n match(err) {\n return isPlainError(err);\n }\n coerce(err, ctx) {\n return {\n type: this.getType(err),\n value: this.getMessage(err, ctx),\n stack: this.getStack(err),\n cause: err.cause ? ctx.next(err.cause) : void 0,\n synthetic: false\n };\n }\n getType(err) {\n return err.name || err.constructor.name;\n }\n getMessage(err, _ctx) {\n const message = err.message;\n if (message.error && 'string' == typeof message.error.message) return String(message.error.message);\n return String(message);\n }\n getStack(err) {\n return err.stacktrace || err.stack || void 0;\n }\n}\nexport { ErrorCoercer };\n","import { isErrorEvent } from \"../../utils/index.mjs\";\nclass ErrorEventCoercer {\n constructor(){}\n match(err) {\n return isErrorEvent(err) && void 0 != err.error;\n }\n coerce(err, ctx) {\n const exceptionLike = ctx.apply(err.error);\n if (!exceptionLike) return {\n type: 'ErrorEvent',\n value: err.message,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n return exceptionLike;\n }\n}\nexport { ErrorEventCoercer };\n","const ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;\nclass StringCoercer {\n match(input) {\n return 'string' == typeof input;\n }\n coerce(input, ctx) {\n const [type, value] = this.getInfos(input);\n return {\n type: type ?? 'Error',\n value: value ?? input,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n getInfos(candidate) {\n let type = 'Error';\n let value = candidate;\n const groups = candidate.match(ERROR_TYPES_PATTERN);\n if (groups) {\n type = groups[1];\n value = groups[2];\n }\n return [\n type,\n value\n ];\n }\n}\nexport { StringCoercer };\n","const severityLevels = [\n 'fatal',\n 'error',\n 'warning',\n 'log',\n 'info',\n 'debug'\n];\nexport { severityLevels };\n","function truncate(str, max = 0) {\n if ('string' != typeof str || 0 === max) return str;\n return str.length <= max ? str : `${str.slice(0, max)}...`;\n}\nfunction extractExceptionKeysForMessage(err, maxLength = 40) {\n const keys = Object.keys(err);\n keys.sort();\n if (!keys.length) return '[object has no keys]';\n for(let i = keys.length; i > 0; i--){\n const serialized = keys.slice(0, i).join(', ');\n if (!(serialized.length > maxLength)) {\n if (i === keys.length) return serialized;\n return serialized.length <= maxLength ? serialized : `${serialized.slice(0, maxLength)}...`;\n }\n }\n return '';\n}\nexport { extractExceptionKeysForMessage, truncate };\n","import { isEmptyString, isError, isEvent, isString } from \"../../utils/index.mjs\";\nimport { severityLevels } from \"../types.mjs\";\nimport { extractExceptionKeysForMessage } from \"./utils.mjs\";\nclass ObjectCoercer {\n match(candidate) {\n return 'object' == typeof candidate && null !== candidate;\n }\n coerce(candidate, ctx) {\n const errorProperty = this.getErrorPropertyFromObject(candidate);\n if (errorProperty) return ctx.apply(errorProperty);\n return {\n type: this.getType(candidate),\n value: this.getValue(candidate),\n stack: ctx.syntheticException?.stack,\n level: this.isSeverityLevel(candidate.level) ? candidate.level : 'error',\n synthetic: true\n };\n }\n getType(err) {\n return isEvent(err) ? err.constructor.name : 'Error';\n }\n getValue(err) {\n if ('name' in err && 'string' == typeof err.name) {\n let message = `'${err.name}' captured as exception`;\n if ('message' in err && 'string' == typeof err.message) message += ` with message: '${err.message}'`;\n return message;\n }\n if ('message' in err && 'string' == typeof err.message) return err.message;\n const className = this.getObjectClassName(err);\n const keys = extractExceptionKeysForMessage(err);\n return `${className && 'Object' !== className ? `'${className}'` : 'Object'} captured as exception with keys: ${keys}`;\n }\n isSeverityLevel(x) {\n return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;\n }\n getErrorPropertyFromObject(obj) {\n for(const prop in obj)if (Object.prototype.hasOwnProperty.call(obj, prop)) {\n const value = obj[prop];\n if (isError(value)) return value;\n }\n }\n getObjectClassName(obj) {\n try {\n const prototype = Object.getPrototypeOf(obj);\n return prototype ? prototype.constructor.name : void 0;\n } catch (e) {\n return;\n }\n }\n}\nexport { ObjectCoercer };\n","import { isEvent } from \"../../utils/index.mjs\";\nimport { extractExceptionKeysForMessage } from \"./utils.mjs\";\nclass EventCoercer {\n match(err) {\n return isEvent(err);\n }\n coerce(evt, ctx) {\n const constructorName = evt.constructor.name;\n return {\n type: constructorName,\n value: `${constructorName} captured as exception with keys: ${extractExceptionKeysForMessage(evt)}`,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n}\nexport { EventCoercer };\n","import { isPrimitive } from \"../../utils/index.mjs\";\nclass PrimitiveCoercer {\n match(candidate) {\n return isPrimitive(candidate);\n }\n coerce(value, ctx) {\n return {\n type: 'Error',\n value: `Primitive value captured as exception: ${String(value)}`,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n}\nexport { PrimitiveCoercer };\n","import { isBuiltin, isPrimitive } from \"../../utils/index.mjs\";\nclass PromiseRejectionEventCoercer {\n match(err) {\n return isBuiltin(err, 'PromiseRejectionEvent');\n }\n coerce(err, ctx) {\n const reason = this.getUnhandledRejectionReason(err);\n if (isPrimitive(reason)) return {\n type: 'UnhandledRejection',\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n return ctx.apply(reason);\n }\n getUnhandledRejectionReason(error) {\n if (isPrimitive(error)) return error;\n try {\n if ('reason' in error) return error.reason;\n if ('detail' in error && 'reason' in error.detail) return error.detail.reason;\n } catch {}\n return error;\n }\n}\nexport { PromiseRejectionEventCoercer };\n","import Config from '../config'\nimport { isUndefined } from '@posthog/core'\nimport { assignableWindow, window } from './globals'\nimport type { Logger } from '@posthog/core'\n\ntype CreateLoggerOptions = {\n debugEnabled?: boolean\n}\n\ntype PosthogJsLogger = Omit<Logger, 'createLogger'> & {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string, options?: CreateLoggerOptions) => PosthogJsLogger\n}\n\nconst _createLogger = (prefix: string, { debugEnabled }: CreateLoggerOptions = {}): PosthogJsLogger => {\n const logger: PosthogJsLogger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG || debugEnabled) &&\n !isUndefined(window.console) &&\n window.console\n ) {\n const consoleLog =\n '__rrweb_original__' in window.console[level]\n ? (window.console[level] as any)['__rrweb_original__']\n : window.console[level]\n\n // eslint-disable-next-line no-console\n consoleLog(prefix, ...args)\n }\n },\n\n info: (...args: any[]) => {\n logger._log('log', ...args)\n },\n\n warn: (...args: any[]) => {\n logger._log('warn', ...args)\n },\n\n error: (...args: any[]) => {\n logger._log('error', ...args)\n },\n\n critical: (...args: any[]) => {\n // Critical errors are always logged to the console\n // eslint-disable-next-line no-console\n console.error(prefix, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n\n createLogger: (additionalPrefix: string, options?: CreateLoggerOptions) =>\n _createLogger(`${prefix} ${additionalPrefix}`, options),\n }\n return logger\n}\n\nexport const logger = _createLogger('[PostHog.js]')\n\nexport const createLogger = logger.createLogger\n","import { each, find } from './utils'\nimport Config from './config'\nimport { Compression, RequestWithOptions, RequestResponse } from './types'\nimport { formDataToQuery } from './utils/request-utils'\n\nimport { logger } from './utils/logger'\nimport { AbortController, fetch, navigator, XMLHttpRequest } from './utils/globals'\nimport { gzipSync, strToU8 } from 'fflate'\n\nimport { _base64Encode } from './utils/encode-utils'\n\n// eslint-disable-next-line compat/compat\nexport const SUPPORTS_REQUEST = !!XMLHttpRequest || !!fetch\n\nconst CONTENT_TYPE_PLAIN = 'text/plain'\nconst CONTENT_TYPE_JSON = 'application/json'\nconst CONTENT_TYPE_FORM = 'application/x-www-form-urlencoded'\nconst SIXTY_FOUR_KILOBYTES = 64 * 1024\n/*\n fetch will fail if we request keepalive with a body greater than 64kb\n sets the threshold lower than that so that\n any overhead doesn't push over the threshold after checking here\n*/\nconst KEEP_ALIVE_THRESHOLD = SIXTY_FOUR_KILOBYTES * 0.8\ntype EncodedBody = {\n contentType: string\n body: string | BlobPart\n estimatedSize: number\n}\n\n/**\n * Extends a URL with additional query parameters\n * @param url - The URL to extend\n * @param params - The parameters to add\n * @param replace - When true (default), new params overwrite existing ones with same key. When false, existing params are preserved.\n * @returns The URL with extended parameters\n */\nexport const extendURLParams = (url: string, params: Record<string, any>, replace: boolean = true): string => {\n const [baseUrl, search] = url.split('?')\n const newParams = { ...params }\n\n const updatedSearch =\n search?.split('&').map((pair) => {\n const [key, origValue] = pair.split('=')\n const value = replace ? (newParams[key] ?? origValue) : origValue\n delete newParams[key]\n return `${key}=${value}`\n }) ?? []\n\n const remaining = formDataToQuery(newParams)\n if (remaining) {\n updatedSearch.push(remaining)\n }\n\n return `${baseUrl}?${updatedSearch.join('&')}`\n}\n\nexport const jsonStringify = (data: any, space?: string | number): string => {\n // With plain JSON.stringify, we get an exception when a property is a BigInt. This has caused problems for some users,\n // see https://github.com/PostHog/posthog-js/issues/1440\n // To work around this, we convert BigInts to strings before stringifying the data. This is not ideal, as we lose\n // information that this was originally a number, but given ClickHouse doesn't support BigInts, the customer\n // would not be able to operate on these numerically anyway.\n return JSON.stringify(data, (_, value) => (typeof value === 'bigint' ? value.toString() : value), space)\n}\n\nconst encodeToDataString = (data: string | Record<string, any>): string => {\n return 'data=' + encodeURIComponent(typeof data === 'string' ? data : jsonStringify(data))\n}\n\nconst encodePostData = ({ data, compression }: RequestWithOptions): EncodedBody | undefined => {\n if (!data) {\n return\n }\n\n if (compression === Compression.GZipJS) {\n const gzipData = gzipSync(strToU8(jsonStringify(data)), { mtime: 0 })\n const blob = new Blob([gzipData], { type: CONTENT_TYPE_PLAIN })\n return {\n contentType: CONTENT_TYPE_PLAIN,\n body: blob,\n estimatedSize: blob.size,\n }\n }\n\n if (compression === Compression.Base64) {\n const b64data = _base64Encode(jsonStringify(data))\n const encodedBody = encodeToDataString(b64data)\n\n return {\n contentType: CONTENT_TYPE_FORM,\n body: encodedBody,\n estimatedSize: new Blob([encodedBody]).size,\n }\n }\n\n const jsonBody = jsonStringify(data)\n return {\n contentType: CONTENT_TYPE_JSON,\n body: jsonBody,\n estimatedSize: new Blob([jsonBody]).size,\n }\n}\n\nconst xhr = (options: RequestWithOptions) => {\n const req = new XMLHttpRequest!()\n req.open(options.method || 'GET', options.url, true)\n const { contentType, body } = encodePostData(options) ?? {}\n\n each(options.headers, function (headerValue, headerName) {\n req.setRequestHeader(headerName, headerValue)\n })\n\n if (contentType) {\n req.setRequestHeader('Content-Type', contentType)\n }\n\n if (options.timeout) {\n req.timeout = options.timeout\n }\n if (!options.disableXHRCredentials) {\n // send the ph_optout cookie\n // withCredentials cannot be modified until after calling .open on Android and Mobile Safari\n req.withCredentials = true\n }\n req.onreadystatechange = () => {\n // XMLHttpRequest.DONE == 4, except in safari 4\n if (req.readyState === 4) {\n const response: RequestResponse = {\n statusCode: req.status,\n text: req.responseText,\n }\n if (req.status === 200) {\n try {\n response.json = JSON.parse(req.responseText)\n } catch {\n // logger.error(e)\n }\n }\n\n options.callback?.(response)\n }\n }\n req.send(body)\n}\n\nconst _fetch = (options: RequestWithOptions) => {\n const { contentType, body, estimatedSize } = encodePostData(options) ?? {}\n\n // eslint-disable-next-line compat/compat\n const headers = new Headers()\n each(options.headers, function (headerValue, headerName) {\n headers.append(headerName, headerValue)\n })\n\n if (contentType) {\n headers.append('Content-Type', contentType)\n }\n\n const url = options.url\n let aborter: { signal: any; timeout: ReturnType<typeof setTimeout> } | null = null\n\n if (AbortController) {\n const controller = new AbortController()\n aborter = {\n signal: controller.signal,\n timeout: setTimeout(() => controller.abort(), options.timeout),\n }\n }\n\n fetch!(url, {\n method: options?.method || 'GET',\n headers,\n // if body is greater than 64kb, then fetch with keepalive will error\n // see 8:10:5 at https://fetch.spec.whatwg.org/#http-network-or-cache-fetch,\n // but we do want to set keepalive sometimes as it can help with success\n // when e.g. a page is being closed\n // so let's get the best of both worlds and only set keepalive for POST requests\n // where the body is less than 64kb\n // NB this is fetch keepalive and not http keepalive\n keepalive: options.method === 'POST' && (estimatedSize || 0) < KEEP_ALIVE_THRESHOLD,\n body,\n signal: aborter?.signal,\n ...options.fetchOptions,\n })\n .then((response) => {\n return response.text().then((responseText) => {\n const res: RequestResponse = {\n statusCode: response.status,\n text: responseText,\n }\n\n if (response.status === 200) {\n try {\n res.json = JSON.parse(responseText)\n } catch (e) {\n logger.error(e)\n }\n }\n\n options.callback?.(res)\n })\n })\n .catch((error) => {\n logger.error(error)\n options.callback?.({ statusCode: 0, text: error })\n })\n .finally(() => (aborter ? clearTimeout(aborter.timeout) : null))\n\n return\n}\n\nconst _sendBeacon = (options: RequestWithOptions) => {\n // beacon documentation https://w3c.github.io/beacon/\n // beacons format the message and use the type property\n\n const url = extendURLParams(options.url, {\n beacon: '1',\n })\n\n try {\n const { contentType, body } = encodePostData(options) ?? {}\n // sendBeacon requires a blob so we convert it\n const sendBeaconBody = typeof body === 'string' ? new Blob([body], { type: contentType }) : body\n navigator!.sendBeacon!(url, sendBeaconBody)\n } catch {\n // send beacon is a best-effort, fire-and-forget mechanism on page unload,\n // we don't want to throw errors here\n }\n}\n\nconst AVAILABLE_TRANSPORTS: {\n transport: RequestWithOptions['transport']\n method: (options: RequestWithOptions) => void\n}[] = []\n\n// We add the transports in order of preference\nif (fetch) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'fetch',\n method: _fetch,\n })\n}\n\nif (XMLHttpRequest) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'XHR',\n method: xhr,\n })\n}\n\nif (navigator?.sendBeacon) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'sendBeacon',\n method: _sendBeacon,\n })\n}\n\n// This is the entrypoint. It takes care of sanitizing the options and then calls the appropriate request method.\nexport const request = (_options: RequestWithOptions) => {\n // Clone the options so we don't modify the original object\n const options = { ..._options }\n options.timeout = options.timeout || 60000\n\n options.url = extendURLParams(options.url, {\n _: new Date().getTime().toString(),\n ver: Config.LIB_VERSION,\n compression: options.compression,\n })\n\n const transport = options.transport ?? 'fetch'\n\n const availableTransports = AVAILABLE_TRANSPORTS.filter(\n (t) => !options.disableTransport || !t.transport || !options.disableTransport.includes(t.transport)\n )\n\n const transportMethod =\n find(availableTransports, (t) => t.transport === transport)?.method ?? availableTransports[0].method\n\n if (!transportMethod) {\n throw new Error('No available transport method')\n }\n\n transportMethod(options)\n}\n","import { ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS, ERROR_TRACKING_SUPPRESSION_RULES } from './constants'\nimport { PostHog } from './posthog-core'\nimport { CaptureResult, ErrorTrackingSuppressionRule, Properties, RemoteConfig } from './types'\nimport { createLogger } from './utils/logger'\nimport { propertyComparisons } from './utils/property-utils'\nimport { isString, isArray, ErrorTracking, isNullish } from '@posthog/core'\n\nconst logger = createLogger('[Error tracking]')\n\nexport function buildErrorPropertiesBuilder() {\n return new ErrorTracking.ErrorPropertiesBuilder(\n [\n new ErrorTracking.DOMExceptionCoercer(),\n new ErrorTracking.PromiseRejectionEventCoercer(),\n new ErrorTracking.ErrorEventCoercer(),\n new ErrorTracking.ErrorCoercer(),\n new ErrorTracking.EventCoercer(),\n new ErrorTracking.ObjectCoercer(),\n new ErrorTracking.StringCoercer(),\n new ErrorTracking.PrimitiveCoercer(),\n ],\n ErrorTracking.createStackParser(\n 'web:javascript',\n ErrorTracking.chromeStackLineParser,\n ErrorTracking.geckoStackLineParser\n )\n )\n}\nexport class PostHogExceptions {\n private readonly _instance: PostHog\n private _suppressionRules: ErrorTrackingSuppressionRule[] = []\n private _errorPropertiesBuilder: ErrorTracking.ErrorPropertiesBuilder = buildErrorPropertiesBuilder()\n\n constructor(instance: PostHog) {\n this._instance = instance\n this._suppressionRules = this._instance.persistence?.get_property(ERROR_TRACKING_SUPPRESSION_RULES) ?? []\n }\n\n onRemoteConfig(response: RemoteConfig) {\n const suppressionRules = response.errorTracking?.suppressionRules ?? []\n const captureExtensionExceptions = response.errorTracking?.captureExtensionExceptions\n\n // store this in-memory in case persistence is disabled\n this._suppressionRules = suppressionRules\n\n if (this._instance.persistence) {\n this._instance.persistence.register({\n [ERROR_TRACKING_SUPPRESSION_RULES]: this._suppressionRules,\n [ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS]: captureExtensionExceptions,\n })\n }\n }\n\n private get _captureExtensionExceptions() {\n const enabled_server_side = !!this._instance.get_property(ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS)\n const enabled_client_side = this._instance.config.error_tracking.captureExtensionExceptions\n return enabled_client_side ?? enabled_server_side ?? false\n }\n\n buildProperties(\n input: unknown,\n metadata?: { handled?: boolean; syntheticException?: Error }\n ): ErrorTracking.ErrorProperties {\n return this._errorPropertiesBuilder.buildFromUnknown(input, {\n syntheticException: metadata?.syntheticException,\n mechanism: {\n handled: metadata?.handled,\n },\n })\n }\n\n sendExceptionEvent(properties: Properties): CaptureResult | undefined {\n const exceptionList = properties.$exception_list\n\n if (this._isExceptionList(exceptionList)) {\n if (this._matchesSuppressionRule(exceptionList)) {\n logger.info('Skipping exception capture because a suppression rule matched')\n return\n }\n\n if (!this._captureExtensionExceptions && this._isExtensionException(exceptionList)) {\n logger.info('Skipping exception capture because it was thrown by an extension')\n return\n }\n\n if (\n !this._instance.config.error_tracking.__capturePostHogExceptions &&\n this._isPostHogException(exceptionList)\n ) {\n logger.info('Skipping exception capture because it was thrown by the PostHog SDK')\n return\n }\n }\n\n return this._instance.capture('$exception', properties, {\n _noTruncate: true,\n _batchKey: 'exceptionEvent',\n })\n }\n\n private _matchesSuppressionRule(exceptionList: ErrorTracking.ExceptionList): boolean {\n if (exceptionList.length === 0) {\n return false\n }\n\n const exceptionValues = exceptionList.reduce(\n (acc, { type, value }) => {\n if (isString(type) && type.length > 0) {\n acc['$exception_types'].push(type)\n }\n if (isString(value) && value.length > 0) {\n acc['$exception_values'].push(value)\n }\n return acc\n },\n {\n $exception_types: [] as string[],\n $exception_values: [] as string[],\n }\n )\n\n return this._suppressionRules.some((rule) => {\n const results = rule.values.map((v) => {\n const compare = propertyComparisons[v.operator]\n const targets = isArray(v.value) ? v.value : [v.value]\n const values = exceptionValues[v.key] ?? []\n return targets.length > 0 ? compare(targets, values) : false\n })\n return rule.type === 'OR' ? results.some(Boolean) : results.every(Boolean)\n })\n }\n\n private _isExtensionException(exceptionList: ErrorTracking.ExceptionList): boolean {\n const frames = exceptionList.flatMap((e) => e.stacktrace?.frames ?? [])\n return frames.some((f) => f.filename && f.filename.startsWith('chrome-extension://'))\n }\n\n private _isPostHogException(exceptionList: ErrorTracking.ExceptionList): boolean {\n if (exceptionList.length > 0) {\n const exception = exceptionList[0]\n const frames = exception.stacktrace?.frames ?? []\n const lastFrame = frames[frames.length - 1]\n return lastFrame?.filename?.includes('posthog.com/static') ?? false\n }\n\n return false\n }\n\n private _isExceptionList(candidate: unknown): candidate is ErrorTracking.ExceptionList {\n return !isNullish(candidate) && isArray(candidate)\n }\n}\n","import { assignableWindow, window } from '../utils/globals'\nimport { ErrorEventArgs } from '../types'\nimport { createLogger } from '../utils/logger'\nimport type { ErrorTracking } from '@posthog/core'\nimport { buildErrorPropertiesBuilder } from '../posthog-exceptions'\n\nconst logger = createLogger('[ExceptionAutocapture]')\nconst errorPropertiesBuilder = buildErrorPropertiesBuilder()\n\nfunction errorToProperties({ event, error }: { event: Event | string; error?: Error }) {\n return errorPropertiesBuilder.buildFromUnknown(error || event, {\n mechanism: {\n handled: false,\n },\n })\n}\n\nconst wrapOnError = (captureFn: (props: ErrorTracking.ErrorProperties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onerror')\n }\n const originalOnError = win.onerror\n\n win.onerror = function (...args: ErrorEventArgs): boolean {\n const errorProperties = errorToProperties({ event: args[0], error: args[4] })\n captureFn(errorProperties)\n return originalOnError?.(...args) ?? false\n }\n win.onerror.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onerror?.__POSTHOG_INSTRUMENTED__\n win.onerror = originalOnError\n }\n}\n\nconst wrapUnhandledRejection = (captureFn: (props: ErrorTracking.ErrorProperties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onUnhandledRejection')\n }\n\n const originalOnUnhandledRejection = win.onunhandledrejection\n\n win.onunhandledrejection = function (ev: PromiseRejectionEvent): boolean {\n const errorProperties = errorToProperties({ event: ev })\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, [ev]) ?? false\n }\n win.onunhandledrejection.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onunhandledrejection?.__POSTHOG_INSTRUMENTED__\n win.onunhandledrejection = originalOnUnhandledRejection\n }\n}\n\nconst wrapConsoleError = (captureFn: (props: ErrorTracking.ErrorProperties) => void) => {\n const con = console as any\n if (!con) {\n logger.info('console not available, cannot wrap console.error')\n }\n\n const originalConsoleError = con.error\n\n con.error = function (...args: any[]): void {\n const event = args.join(' ')\n const error = args.find((arg) => arg instanceof Error)\n const errorProperties = errorToProperties({ error, event })\n captureFn(errorProperties)\n return originalConsoleError?.(...args)\n }\n con.error.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete con.error?.__POSTHOG_INSTRUMENTED__\n con.error = originalConsoleError\n }\n}\n\nconst posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n wrapConsoleError,\n}\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.errorWrappingFunctions = posthogErrorWrappingFunctions\n\n// we used to put these on window, and now we put them on __PosthogExtensions__\n// but that means that old clients which lazily load this extension are looking in the wrong place\n// yuck,\n// so we also put them directly on the window\n// when 1.161.1 is the oldest version seen in production we can remove this\nassignableWindow.posthogErrorWrappingFunctions = posthogErrorWrappingFunctions\n\nexport default posthogErrorWrappingFunctions\n"],"names":["win","window","undefined","global","globalThis","self","File","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","nativeIsArray","Array","isArray","type_utils_toString","Object","prototype","toString","obj","call","isUndefined","x","isString","isPrimitive","value","isBuiltin","candidate","className","isEvent","Event","base","_unused","isInstanceOf","parsedStackResults","lastKeysCount","cachedFilenameChunkIds","getFilenameToChunkIdMap","stackParser","chunkIdMap","_posthogChunkIds","chunkIdKeys","keys","length","reduce","acc","stackKey","result","parsedStack","i","stackFrame","filename","chunkId","ErrorPropertiesBuilder","constructor","coercers","modifiers","this","buildFromUnknown","input","hint","mechanism","handled","type","exceptionWithCause","buildCoercingContext","apply","parsingContext","buildParsingContext","exceptionWithStack","parseStacktrace","$exception_list","convertToExceptionList","$exception_level","modifyFrames","exceptionList","_this","_asyncToGenerator","exc","stacktrace","frames","applyModifiers","coerceFallback","ctx","_ctx$syntheticExcepti","stack","syntheticException","synthetic","err","cause","applyChunkIds","_extends","map","frame","chunk_id","applyCoercers","adapter","match","coerce","_this2","newFrames","modifier","_mechanism$type","_mechanism$handled","_exceptionWithStack$s","currentException","push","depth","next","UNKNOWN_FUNCTION","createFrame","platform","func","lineno","colno","function","in_app","extractSafariExtensionDetails","isSafariExtension","indexOf","isSafariWebExtension","split","chromeRegexNoFnName","chromeRegex","chromeEvalRegex","chromeStackLineParser","line","noFnParts","exec","col","parts","subMatch","geckoREgex","geckoEvalRegex","geckoStackLineParser","WEBPACK_ERROR_REGEXP","STACKTRACE_FRAME_LIMIT","createStackParser","_len","arguments","parsers","_key","skipFirstLines","lines","cleanedLine","test","replace","parser","localStack","from","reverse","slice","arr","reverseAndStripFrames","DOMExceptionCoercer","isDOMException","isDOMError","hasStack","getType","getValue","name","message","ErrorCoercer","Error","getMessage","getStack","_ctx","error","String","ErrorEventCoercer","exceptionLike","ERROR_TYPES_PATTERN","StringCoercer","getInfos","groups","severityLevels","extractExceptionKeysForMessage","maxLength","sort","serialized","join","ObjectCoercer","errorProperty","getErrorPropertyFromObject","level","isSeverityLevel","getObjectClassName","trim","isEmptyString","prop","hasOwnProperty","getPrototypeOf","e","EventCoercer","evt","constructorName","PrimitiveCoercer","PromiseRejectionEventCoercer","reason","getUnhandledRejectionReason","detail","_createLogger","prefix","_temp","debugEnabled","logger","_log","POSTHOG_DEBUG","console","consoleLog","args","info","_len2","_key2","warn","_len3","_key3","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","createLogger","additionalPrefix","options","sendBeacon","errorPropertiesBuilder","ErrorTracking","errorToProperties","_ref","event","posthogErrorWrappingFunctions","wrapOnError","captureFn","originalOnError","onerror","_originalOnError","errorProperties","__POSTHOG_INSTRUMENTED__","_win$onerror","wrapUnhandledRejection","originalOnUnhandledRejection","onunhandledrejection","ev","_originalOnUnhandledR","_win$onunhandledrejec","wrapConsoleError","con","originalConsoleError","find","arg","_con$error","__PosthogExtensions__","errorWrappingFunctions"],"mappings":"yBA2BA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAqMzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAG3E,oBAATK,OACLF,EAAeE,KAAOF,GAER,oBAATG,OACLH,EAAeG,KAAO,WAAa,GAOlC,IAAMC,EAAkB,MAANJ,OAAM,EAANA,EAAQI,UACH,MAANJ,GAAAA,EAAQK,SACF,MAANL,GAAAA,EAAQM,SACL,MAANN,GAAAA,EAAQO,YAEzBP,GAAAA,EAAQQ,gBAAkB,oBAAqB,IAAIR,EAAOQ,gBAAmBR,EAAOQ,eACnD,MAANR,GAAAA,EAAQS,gBACL,MAATL,GAAAA,EAAWM,UAC7B,IAAMC,EAAqCd,QAAAA,EAAQ,CAAA,shBCpP1D,IAAMe,EAAgBC,MAAMC,QAGtBC,EAFWC,OAAOC,UAEaC,SAC/BJ,EAAUF,GAAiB,SAASO,GACtC,MAAO,mBAAqBJ,EAAoBK,KAAKD,EACzD,EAWME,EAAeC,QAAI,IAAWA,EAC9BC,EAAYD,GAAI,mBAAqBP,EAAoBK,KAAKE,GAiBpE,SAASE,EAAYC,GACjB,OAAO,OAASA,GAAS,iBAAmBA,CAChD,CACA,SAASC,EAAUC,EAAWC,GAC1B,OAAOZ,OAAOC,UAAUC,SAASE,KAAKO,KAAU,WAAgBC,EAAS,GAC7E,CAgBA,SAASC,EAAQF,GACb,OAAQN,EAAYS,QA7BxB,SAAsBH,EAAWI,GAC7B,IACI,OAAOJ,aAAqBI,CAChC,CAAE,MAAAC,GACE,OAAO,CACX,CACJ,CAuBkCC,CAAaN,EAAWG,MAC1D,C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AhBA,EAAOJ,EAAIlF,eAAJsF,EAAWb,yBAClBS,EAAIlF,MAAQmF,CAAoB,CACnC,GASL/O,EAAiBmP,sBAAwBnP,EAAiBmP,uBAAyB,CAAA,EACnFnP,EAAiBmP,sBAAsBC,uBAAyBtB,EAOhE9N,EAAiB8N,8BAAgCA"}
1
+ {"version":3,"file":"exception-autocapture.js","sources":["../src/utils/globals.ts","../../core/dist/utils/type-utils.mjs","../../core/dist/utils/index.mjs","../../core/dist/error-tracking/chunk-ids.mjs","../../core/dist/error-tracking/error-properties-builder.mjs","../../core/dist/error-tracking/parsers/base.mjs","../../core/dist/error-tracking/parsers/safari.mjs","../../core/dist/error-tracking/parsers/chrome.mjs","../../core/dist/error-tracking/parsers/gecko.mjs","../../core/dist/error-tracking/parsers/index.mjs","../../core/dist/error-tracking/coercers/dom-exception-coercer.mjs","../../core/dist/error-tracking/coercers/error-coercer.mjs","../../core/dist/error-tracking/coercers/error-event-coercer.mjs","../../core/dist/error-tracking/coercers/string-coercer.mjs","../../core/dist/error-tracking/types.mjs","../../core/dist/error-tracking/coercers/utils.mjs","../../core/dist/error-tracking/coercers/object-coercer.mjs","../../core/dist/error-tracking/coercers/event-coercer.mjs","../../core/dist/error-tracking/coercers/primitive-coercer.mjs","../../core/dist/error-tracking/coercers/promise-rejection-event.mjs","../src/utils/logger.ts","../src/request.ts","../src/posthog-exceptions.ts","../src/entrypoints/exception-autocapture.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\n\n/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n tracingHeadersPatchFns?: {\n _patchFetch: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n _patchXHR: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\n\nexport const ArrayProto = Array.prototype\nexport const nativeForEach = ArrayProto.forEach\nexport const nativeIndexOf = ArrayProto.indexOf\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","import { knownUnsafeEditableEvent } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return !isUndefined(Event) && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isInstanceOf, isKnownUnsafeEditableEvent, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","export * from \"./bot-detection.mjs\";\nexport * from \"./bucketed-rate-limiter.mjs\";\nexport * from \"./number-utils.mjs\";\nexport * from \"./string-utils.mjs\";\nexport * from \"./type-utils.mjs\";\nexport * from \"./promise-queue.mjs\";\nexport * from \"./logger.mjs\";\nconst STRING_FORMAT = 'utf8';\nfunction assert(truthyValue, message) {\n if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);\n}\nfunction isEmpty(truthyValue) {\n if (0 === truthyValue.trim().length) return true;\n return false;\n}\nfunction removeTrailingSlash(url) {\n return url?.replace(/\\/+$/, '');\n}\nasync function retriable(fn, props) {\n let lastError = null;\n for(let i = 0; i < props.retryCount + 1; i++){\n if (i > 0) await new Promise((r)=>setTimeout(r, props.retryDelay));\n try {\n const res = await fn();\n return res;\n } catch (e) {\n lastError = e;\n if (!props.retryCheck(e)) throw e;\n }\n }\n throw lastError;\n}\nfunction currentTimestamp() {\n return new Date().getTime();\n}\nfunction currentISOTime() {\n return new Date().toISOString();\n}\nfunction safeSetTimeout(fn, timeout) {\n const t = setTimeout(fn, timeout);\n t?.unref && t?.unref();\n return t;\n}\nconst isPromise = (obj)=>obj && 'function' == typeof obj.then;\nconst isError = (x)=>x instanceof Error;\nfunction getFetch() {\n return 'undefined' != typeof fetch ? fetch : void 0 !== globalThis.fetch ? globalThis.fetch : void 0;\n}\nfunction allSettled(promises) {\n return Promise.all(promises.map((p)=>(p ?? Promise.resolve()).then((value)=>({\n status: 'fulfilled',\n value\n }), (reason)=>({\n status: 'rejected',\n reason\n }))));\n}\nexport { STRING_FORMAT, allSettled, assert, currentISOTime, currentTimestamp, getFetch, isError, isPromise, removeTrailingSlash, retriable, safeSetTimeout };\n","let parsedStackResults;\nlet lastKeysCount;\nlet cachedFilenameChunkIds;\nfunction getFilenameToChunkIdMap(stackParser) {\n const chunkIdMap = globalThis._posthogChunkIds;\n if (!chunkIdMap) return;\n const chunkIdKeys = Object.keys(chunkIdMap);\n if (cachedFilenameChunkIds && chunkIdKeys.length === lastKeysCount) return cachedFilenameChunkIds;\n lastKeysCount = chunkIdKeys.length;\n cachedFilenameChunkIds = chunkIdKeys.reduce((acc, stackKey)=>{\n if (!parsedStackResults) parsedStackResults = {};\n const result = parsedStackResults[stackKey];\n if (result) acc[result[0]] = result[1];\n else {\n const parsedStack = stackParser(stackKey);\n for(let i = parsedStack.length - 1; i >= 0; i--){\n const stackFrame = parsedStack[i];\n const filename = stackFrame?.filename;\n const chunkId = chunkIdMap[stackKey];\n if (filename && chunkId) {\n acc[filename] = chunkId;\n parsedStackResults[stackKey] = [\n filename,\n chunkId\n ];\n break;\n }\n }\n }\n return acc;\n }, {});\n return cachedFilenameChunkIds;\n}\nexport { getFilenameToChunkIdMap };\n","import { isArray } from \"../utils/index.mjs\";\nimport { getFilenameToChunkIdMap } from \"./chunk-ids.mjs\";\nconst MAX_CAUSE_RECURSION = 4;\nclass ErrorPropertiesBuilder {\n constructor(coercers, stackParser, modifiers = []){\n this.coercers = coercers;\n this.stackParser = stackParser;\n this.modifiers = modifiers;\n }\n buildFromUnknown(input, hint = {}) {\n const providedMechanism = hint && hint.mechanism;\n const mechanism = providedMechanism || {\n handled: true,\n type: 'generic'\n };\n const coercingContext = this.buildCoercingContext(mechanism, hint, 0);\n const exceptionWithCause = coercingContext.apply(input);\n const parsingContext = this.buildParsingContext();\n const exceptionWithStack = this.parseStacktrace(exceptionWithCause, parsingContext);\n const exceptionList = this.convertToExceptionList(exceptionWithStack, mechanism);\n return {\n $exception_list: exceptionList,\n $exception_level: 'error'\n };\n }\n async modifyFrames(exceptionList) {\n for (const exc of exceptionList)if (exc.stacktrace && exc.stacktrace.frames && isArray(exc.stacktrace.frames)) exc.stacktrace.frames = await this.applyModifiers(exc.stacktrace.frames);\n return exceptionList;\n }\n coerceFallback(ctx) {\n return {\n type: 'Error',\n value: 'Unknown error',\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n parseStacktrace(err, ctx) {\n let cause;\n if (null != err.cause) cause = this.parseStacktrace(err.cause, ctx);\n let stack;\n if ('' != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ? 1 : 0), ctx.chunkIdMap);\n return {\n ...err,\n cause,\n stack\n };\n }\n applyChunkIds(frames, chunkIdMap) {\n return frames.map((frame)=>{\n if (frame.filename && chunkIdMap) frame.chunk_id = chunkIdMap[frame.filename];\n return frame;\n });\n }\n applyCoercers(input, ctx) {\n for (const adapter of this.coercers)if (adapter.match(input)) return adapter.coerce(input, ctx);\n return this.coerceFallback(ctx);\n }\n async applyModifiers(frames) {\n let newFrames = frames;\n for (const modifier of this.modifiers)newFrames = await modifier(newFrames);\n return newFrames;\n }\n convertToExceptionList(exceptionWithStack, mechanism) {\n const currentException = {\n type: exceptionWithStack.type,\n value: exceptionWithStack.value,\n mechanism: {\n type: mechanism.type ?? 'generic',\n handled: mechanism.handled ?? true,\n synthetic: exceptionWithStack.synthetic ?? false\n }\n };\n if (exceptionWithStack.stack) currentException.stacktrace = {\n type: 'raw',\n frames: exceptionWithStack.stack\n };\n const exceptionList = [\n currentException\n ];\n if (null != exceptionWithStack.cause) exceptionList.push(...this.convertToExceptionList(exceptionWithStack.cause, {\n ...mechanism,\n handled: true\n }));\n return exceptionList;\n }\n buildParsingContext() {\n const context = {\n chunkIdMap: getFilenameToChunkIdMap(this.stackParser)\n };\n return context;\n }\n buildCoercingContext(mechanism, hint, depth = 0) {\n const coerce = (input, depth)=>{\n if (!(depth <= MAX_CAUSE_RECURSION)) return;\n {\n const ctx = this.buildCoercingContext(mechanism, hint, depth);\n return this.applyCoercers(input, ctx);\n }\n };\n const context = {\n ...hint,\n syntheticException: 0 == depth ? hint.syntheticException : void 0,\n mechanism,\n apply: (input)=>coerce(input, depth),\n next: (input)=>coerce(input, depth + 1)\n };\n return context;\n }\n}\nexport { ErrorPropertiesBuilder };\n","import { isUndefined } from \"../../utils/index.mjs\";\nconst UNKNOWN_FUNCTION = '?';\nfunction createFrame(platform, filename, func, lineno, colno) {\n const frame = {\n platform,\n filename,\n function: '<anonymous>' === func ? UNKNOWN_FUNCTION : func,\n in_app: true\n };\n if (!isUndefined(lineno)) frame.lineno = lineno;\n if (!isUndefined(colno)) frame.colno = colno;\n return frame;\n}\nexport { UNKNOWN_FUNCTION, createFrame };\n","import { UNKNOWN_FUNCTION } from \"./base.mjs\";\nconst extractSafariExtensionDetails = (func, filename)=>{\n const isSafariExtension = -1 !== func.indexOf('safari-extension');\n const isSafariWebExtension = -1 !== func.indexOf('safari-web-extension');\n return isSafariExtension || isSafariWebExtension ? [\n -1 !== func.indexOf('@') ? func.split('@')[0] : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`\n ] : [\n func,\n filename\n ];\n};\nexport { extractSafariExtensionDetails };\n","import { UNKNOWN_FUNCTION, createFrame } from \"./base.mjs\";\nimport { extractSafariExtensionDetails } from \"./safari.mjs\";\nconst chromeRegexNoFnName = /^\\s*at (\\S+?)(?::(\\d+))(?::(\\d+))\\s*$/i;\nconst chromeRegex = /^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i;\nconst chromeEvalRegex = /\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/;\nconst chromeStackLineParser = (line, platform)=>{\n const noFnParts = chromeRegexNoFnName.exec(line);\n if (noFnParts) {\n const [, filename, line, col] = noFnParts;\n return createFrame(platform, filename, UNKNOWN_FUNCTION, +line, +col);\n }\n const parts = chromeRegex.exec(line);\n if (parts) {\n const isEval = parts[2] && 0 === parts[2].indexOf('eval');\n if (isEval) {\n const subMatch = chromeEvalRegex.exec(parts[2]);\n if (subMatch) {\n parts[2] = subMatch[1];\n parts[3] = subMatch[2];\n parts[4] = subMatch[3];\n }\n }\n const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]);\n return createFrame(platform, filename, func, parts[3] ? +parts[3] : void 0, parts[4] ? +parts[4] : void 0);\n }\n};\nexport { chromeStackLineParser };\n","import { UNKNOWN_FUNCTION, createFrame } from \"./base.mjs\";\nimport { extractSafariExtensionDetails } from \"./safari.mjs\";\nconst geckoREgex = /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i;\nconst geckoEvalRegex = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i;\nconst geckoStackLineParser = (line, platform)=>{\n const parts = geckoREgex.exec(line);\n if (parts) {\n const isEval = parts[3] && parts[3].indexOf(' > eval') > -1;\n if (isEval) {\n const subMatch = geckoEvalRegex.exec(parts[3]);\n if (subMatch) {\n parts[1] = parts[1] || 'eval';\n parts[3] = subMatch[1];\n parts[4] = subMatch[2];\n parts[5] = '';\n }\n }\n let filename = parts[3];\n let func = parts[1] || UNKNOWN_FUNCTION;\n [func, filename] = extractSafariExtensionDetails(func, filename);\n return createFrame(platform, filename, func, parts[4] ? +parts[4] : void 0, parts[5] ? +parts[5] : void 0);\n }\n};\nexport { geckoStackLineParser };\n","import { UNKNOWN_FUNCTION } from \"./base.mjs\";\nimport { chromeStackLineParser } from \"./chrome.mjs\";\nimport { winjsStackLineParser } from \"./winjs.mjs\";\nimport { geckoStackLineParser } from \"./gecko.mjs\";\nimport { opera10StackLineParser, opera11StackLineParser } from \"./opera.mjs\";\nimport { nodeStackLineParser } from \"./node.mjs\";\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/;\nconst STACKTRACE_FRAME_LIMIT = 50;\nfunction reverseAndStripFrames(stack) {\n if (!stack.length) return [];\n const localStack = Array.from(stack);\n localStack.reverse();\n return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame)=>({\n ...frame,\n filename: frame.filename || getLastStackFrame(localStack).filename,\n function: frame.function || UNKNOWN_FUNCTION\n }));\n}\nfunction getLastStackFrame(arr) {\n return arr[arr.length - 1] || {};\n}\nfunction createStackParser(platform, ...parsers) {\n return (stack, skipFirstLines = 0)=>{\n const frames = [];\n const lines = stack.split('\\n');\n for(let i = skipFirstLines; i < lines.length; i++){\n const line = lines[i];\n if (line.length > 1024) continue;\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;\n if (!cleanedLine.match(/\\S*Error: /)) {\n for (const parser of parsers){\n const frame = parser(cleanedLine, platform);\n if (frame) {\n frames.push(frame);\n break;\n }\n }\n if (frames.length >= STACKTRACE_FRAME_LIMIT) break;\n }\n }\n return reverseAndStripFrames(frames);\n };\n}\nexport { chromeStackLineParser, createStackParser, geckoStackLineParser, nodeStackLineParser, opera10StackLineParser, opera11StackLineParser, reverseAndStripFrames, winjsStackLineParser };\n","import { isBuiltin, isString } from \"../../utils/index.mjs\";\nclass DOMExceptionCoercer {\n match(err) {\n return this.isDOMException(err) || this.isDOMError(err);\n }\n coerce(err, ctx) {\n const hasStack = isString(err.stack);\n return {\n type: this.getType(err),\n value: this.getValue(err),\n stack: hasStack ? err.stack : void 0,\n cause: err.cause ? ctx.next(err.cause) : void 0,\n synthetic: false\n };\n }\n getType(candidate) {\n return this.isDOMError(candidate) ? 'DOMError' : 'DOMException';\n }\n getValue(err) {\n const name = err.name || (this.isDOMError(err) ? 'DOMError' : 'DOMException');\n const message = err.message ? `${name}: ${err.message}` : name;\n return message;\n }\n isDOMException(err) {\n return isBuiltin(err, 'DOMException');\n }\n isDOMError(err) {\n return isBuiltin(err, 'DOMError');\n }\n}\nexport { DOMExceptionCoercer };\n","import { isPlainError } from \"../../utils/index.mjs\";\nclass ErrorCoercer {\n match(err) {\n return isPlainError(err);\n }\n coerce(err, ctx) {\n return {\n type: this.getType(err),\n value: this.getMessage(err, ctx),\n stack: this.getStack(err),\n cause: err.cause ? ctx.next(err.cause) : void 0,\n synthetic: false\n };\n }\n getType(err) {\n return err.name || err.constructor.name;\n }\n getMessage(err, _ctx) {\n const message = err.message;\n if (message.error && 'string' == typeof message.error.message) return String(message.error.message);\n return String(message);\n }\n getStack(err) {\n return err.stacktrace || err.stack || void 0;\n }\n}\nexport { ErrorCoercer };\n","import { isErrorEvent } from \"../../utils/index.mjs\";\nclass ErrorEventCoercer {\n constructor(){}\n match(err) {\n return isErrorEvent(err) && void 0 != err.error;\n }\n coerce(err, ctx) {\n const exceptionLike = ctx.apply(err.error);\n if (!exceptionLike) return {\n type: 'ErrorEvent',\n value: err.message,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n return exceptionLike;\n }\n}\nexport { ErrorEventCoercer };\n","const ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;\nclass StringCoercer {\n match(input) {\n return 'string' == typeof input;\n }\n coerce(input, ctx) {\n const [type, value] = this.getInfos(input);\n return {\n type: type ?? 'Error',\n value: value ?? input,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n getInfos(candidate) {\n let type = 'Error';\n let value = candidate;\n const groups = candidate.match(ERROR_TYPES_PATTERN);\n if (groups) {\n type = groups[1];\n value = groups[2];\n }\n return [\n type,\n value\n ];\n }\n}\nexport { StringCoercer };\n","const severityLevels = [\n 'fatal',\n 'error',\n 'warning',\n 'log',\n 'info',\n 'debug'\n];\nexport { severityLevels };\n","function truncate(str, max = 0) {\n if ('string' != typeof str || 0 === max) return str;\n return str.length <= max ? str : `${str.slice(0, max)}...`;\n}\nfunction extractExceptionKeysForMessage(err, maxLength = 40) {\n const keys = Object.keys(err);\n keys.sort();\n if (!keys.length) return '[object has no keys]';\n for(let i = keys.length; i > 0; i--){\n const serialized = keys.slice(0, i).join(', ');\n if (!(serialized.length > maxLength)) {\n if (i === keys.length) return serialized;\n return serialized.length <= maxLength ? serialized : `${serialized.slice(0, maxLength)}...`;\n }\n }\n return '';\n}\nexport { extractExceptionKeysForMessage, truncate };\n","import { isEmptyString, isError, isEvent, isString } from \"../../utils/index.mjs\";\nimport { severityLevels } from \"../types.mjs\";\nimport { extractExceptionKeysForMessage } from \"./utils.mjs\";\nclass ObjectCoercer {\n match(candidate) {\n return 'object' == typeof candidate && null !== candidate;\n }\n coerce(candidate, ctx) {\n const errorProperty = this.getErrorPropertyFromObject(candidate);\n if (errorProperty) return ctx.apply(errorProperty);\n return {\n type: this.getType(candidate),\n value: this.getValue(candidate),\n stack: ctx.syntheticException?.stack,\n level: this.isSeverityLevel(candidate.level) ? candidate.level : 'error',\n synthetic: true\n };\n }\n getType(err) {\n return isEvent(err) ? err.constructor.name : 'Error';\n }\n getValue(err) {\n if ('name' in err && 'string' == typeof err.name) {\n let message = `'${err.name}' captured as exception`;\n if ('message' in err && 'string' == typeof err.message) message += ` with message: '${err.message}'`;\n return message;\n }\n if ('message' in err && 'string' == typeof err.message) return err.message;\n const className = this.getObjectClassName(err);\n const keys = extractExceptionKeysForMessage(err);\n return `${className && 'Object' !== className ? `'${className}'` : 'Object'} captured as exception with keys: ${keys}`;\n }\n isSeverityLevel(x) {\n return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;\n }\n getErrorPropertyFromObject(obj) {\n for(const prop in obj)if (Object.prototype.hasOwnProperty.call(obj, prop)) {\n const value = obj[prop];\n if (isError(value)) return value;\n }\n }\n getObjectClassName(obj) {\n try {\n const prototype = Object.getPrototypeOf(obj);\n return prototype ? prototype.constructor.name : void 0;\n } catch (e) {\n return;\n }\n }\n}\nexport { ObjectCoercer };\n","import { isEvent } from \"../../utils/index.mjs\";\nimport { extractExceptionKeysForMessage } from \"./utils.mjs\";\nclass EventCoercer {\n match(err) {\n return isEvent(err);\n }\n coerce(evt, ctx) {\n const constructorName = evt.constructor.name;\n return {\n type: constructorName,\n value: `${constructorName} captured as exception with keys: ${extractExceptionKeysForMessage(evt)}`,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n}\nexport { EventCoercer };\n","import { isPrimitive } from \"../../utils/index.mjs\";\nclass PrimitiveCoercer {\n match(candidate) {\n return isPrimitive(candidate);\n }\n coerce(value, ctx) {\n return {\n type: 'Error',\n value: `Primitive value captured as exception: ${String(value)}`,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n }\n}\nexport { PrimitiveCoercer };\n","import { isBuiltin, isPrimitive } from \"../../utils/index.mjs\";\nclass PromiseRejectionEventCoercer {\n match(err) {\n return isBuiltin(err, 'PromiseRejectionEvent');\n }\n coerce(err, ctx) {\n const reason = this.getUnhandledRejectionReason(err);\n if (isPrimitive(reason)) return {\n type: 'UnhandledRejection',\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n stack: ctx.syntheticException?.stack,\n synthetic: true\n };\n return ctx.apply(reason);\n }\n getUnhandledRejectionReason(error) {\n if (isPrimitive(error)) return error;\n try {\n if ('reason' in error) return error.reason;\n if ('detail' in error && 'reason' in error.detail) return error.detail.reason;\n } catch {}\n return error;\n }\n}\nexport { PromiseRejectionEventCoercer };\n","import Config from '../config'\nimport { isUndefined } from '@posthog/core'\nimport { assignableWindow, window } from './globals'\nimport type { Logger } from '@posthog/core'\n\ntype CreateLoggerOptions = {\n debugEnabled?: boolean\n}\n\ntype PosthogJsLogger = Omit<Logger, 'createLogger'> & {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string, options?: CreateLoggerOptions) => PosthogJsLogger\n}\n\nconst _createLogger = (prefix: string, { debugEnabled }: CreateLoggerOptions = {}): PosthogJsLogger => {\n const logger: PosthogJsLogger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG || debugEnabled) &&\n !isUndefined(window.console) &&\n window.console\n ) {\n const consoleLog =\n '__rrweb_original__' in window.console[level]\n ? (window.console[level] as any)['__rrweb_original__']\n : window.console[level]\n\n // eslint-disable-next-line no-console\n consoleLog(prefix, ...args)\n }\n },\n\n info: (...args: any[]) => {\n logger._log('log', ...args)\n },\n\n warn: (...args: any[]) => {\n logger._log('warn', ...args)\n },\n\n error: (...args: any[]) => {\n logger._log('error', ...args)\n },\n\n critical: (...args: any[]) => {\n // Critical errors are always logged to the console\n // eslint-disable-next-line no-console\n console.error(prefix, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n\n createLogger: (additionalPrefix: string, options?: CreateLoggerOptions) =>\n _createLogger(`${prefix} ${additionalPrefix}`, options),\n }\n return logger\n}\n\nexport const logger = _createLogger('[PostHog.js]')\n\nexport const createLogger = logger.createLogger\n","import { each, find } from './utils'\nimport Config from './config'\nimport { Compression, RequestWithOptions, RequestResponse } from './types'\nimport { formDataToQuery } from './utils/request-utils'\n\nimport { logger } from './utils/logger'\nimport { AbortController, fetch, navigator, XMLHttpRequest } from './utils/globals'\nimport { gzipSync, strToU8 } from 'fflate'\n\nimport { _base64Encode } from './utils/encode-utils'\n\n// eslint-disable-next-line compat/compat\nexport const SUPPORTS_REQUEST = !!XMLHttpRequest || !!fetch\n\nconst CONTENT_TYPE_PLAIN = 'text/plain'\nconst CONTENT_TYPE_JSON = 'application/json'\nconst CONTENT_TYPE_FORM = 'application/x-www-form-urlencoded'\nconst SIXTY_FOUR_KILOBYTES = 64 * 1024\n/*\n fetch will fail if we request keepalive with a body greater than 64kb\n sets the threshold lower than that so that\n any overhead doesn't push over the threshold after checking here\n*/\nconst KEEP_ALIVE_THRESHOLD = SIXTY_FOUR_KILOBYTES * 0.8\ntype EncodedBody = {\n contentType: string\n body: string | BlobPart\n estimatedSize: number\n}\n\n/**\n * Extends a URL with additional query parameters\n * @param url - The URL to extend\n * @param params - The parameters to add\n * @param replace - When true (default), new params overwrite existing ones with same key. When false, existing params are preserved.\n * @returns The URL with extended parameters\n */\nexport const extendURLParams = (url: string, params: Record<string, any>, replace: boolean = true): string => {\n const [baseUrl, search] = url.split('?')\n const newParams = { ...params }\n\n const updatedSearch =\n search?.split('&').map((pair) => {\n const [key, origValue] = pair.split('=')\n const value = replace ? (newParams[key] ?? origValue) : origValue\n delete newParams[key]\n return `${key}=${value}`\n }) ?? []\n\n const remaining = formDataToQuery(newParams)\n if (remaining) {\n updatedSearch.push(remaining)\n }\n\n return `${baseUrl}?${updatedSearch.join('&')}`\n}\n\nexport const jsonStringify = (data: any, space?: string | number): string => {\n // With plain JSON.stringify, we get an exception when a property is a BigInt. This has caused problems for some users,\n // see https://github.com/PostHog/posthog-js/issues/1440\n // To work around this, we convert BigInts to strings before stringifying the data. This is not ideal, as we lose\n // information that this was originally a number, but given ClickHouse doesn't support BigInts, the customer\n // would not be able to operate on these numerically anyway.\n return JSON.stringify(data, (_, value) => (typeof value === 'bigint' ? value.toString() : value), space)\n}\n\nconst encodeToDataString = (data: string | Record<string, any>): string => {\n return 'data=' + encodeURIComponent(typeof data === 'string' ? data : jsonStringify(data))\n}\n\nconst encodePostData = ({ data, compression }: RequestWithOptions): EncodedBody | undefined => {\n if (!data) {\n return\n }\n\n if (compression === Compression.GZipJS) {\n const gzipData = gzipSync(strToU8(jsonStringify(data)), { mtime: 0 })\n const blob = new Blob([gzipData], { type: CONTENT_TYPE_PLAIN })\n return {\n contentType: CONTENT_TYPE_PLAIN,\n body: blob,\n estimatedSize: blob.size,\n }\n }\n\n if (compression === Compression.Base64) {\n const b64data = _base64Encode(jsonStringify(data))\n const encodedBody = encodeToDataString(b64data)\n\n return {\n contentType: CONTENT_TYPE_FORM,\n body: encodedBody,\n estimatedSize: new Blob([encodedBody]).size,\n }\n }\n\n const jsonBody = jsonStringify(data)\n return {\n contentType: CONTENT_TYPE_JSON,\n body: jsonBody,\n estimatedSize: new Blob([jsonBody]).size,\n }\n}\n\nconst xhr = (options: RequestWithOptions) => {\n const req = new XMLHttpRequest!()\n req.open(options.method || 'GET', options.url, true)\n const { contentType, body } = encodePostData(options) ?? {}\n\n each(options.headers, function (headerValue, headerName) {\n req.setRequestHeader(headerName, headerValue)\n })\n\n if (contentType) {\n req.setRequestHeader('Content-Type', contentType)\n }\n\n if (options.timeout) {\n req.timeout = options.timeout\n }\n if (!options.disableXHRCredentials) {\n // send the ph_optout cookie\n // withCredentials cannot be modified until after calling .open on Android and Mobile Safari\n req.withCredentials = true\n }\n req.onreadystatechange = () => {\n // XMLHttpRequest.DONE == 4, except in safari 4\n if (req.readyState === 4) {\n const response: RequestResponse = {\n statusCode: req.status,\n text: req.responseText,\n }\n if (req.status === 200) {\n try {\n response.json = JSON.parse(req.responseText)\n } catch {\n // logger.error(e)\n }\n }\n\n options.callback?.(response)\n }\n }\n req.send(body)\n}\n\nconst _fetch = (options: RequestWithOptions) => {\n const { contentType, body, estimatedSize } = encodePostData(options) ?? {}\n\n // eslint-disable-next-line compat/compat\n const headers = new Headers()\n each(options.headers, function (headerValue, headerName) {\n headers.append(headerName, headerValue)\n })\n\n if (contentType) {\n headers.append('Content-Type', contentType)\n }\n\n const url = options.url\n let aborter: { signal: any; timeout: ReturnType<typeof setTimeout> } | null = null\n\n if (AbortController) {\n const controller = new AbortController()\n aborter = {\n signal: controller.signal,\n timeout: setTimeout(() => controller.abort(), options.timeout),\n }\n }\n\n fetch!(url, {\n method: options?.method || 'GET',\n headers,\n // if body is greater than 64kb, then fetch with keepalive will error\n // see 8:10:5 at https://fetch.spec.whatwg.org/#http-network-or-cache-fetch,\n // but we do want to set keepalive sometimes as it can help with success\n // when e.g. a page is being closed\n // so let's get the best of both worlds and only set keepalive for POST requests\n // where the body is less than 64kb\n // NB this is fetch keepalive and not http keepalive\n keepalive: options.method === 'POST' && (estimatedSize || 0) < KEEP_ALIVE_THRESHOLD,\n body,\n signal: aborter?.signal,\n ...options.fetchOptions,\n })\n .then((response) => {\n return response.text().then((responseText) => {\n const res: RequestResponse = {\n statusCode: response.status,\n text: responseText,\n }\n\n if (response.status === 200) {\n try {\n res.json = JSON.parse(responseText)\n } catch (e) {\n logger.error(e)\n }\n }\n\n options.callback?.(res)\n })\n })\n .catch((error) => {\n logger.error(error)\n options.callback?.({ statusCode: 0, text: error })\n })\n .finally(() => (aborter ? clearTimeout(aborter.timeout) : null))\n\n return\n}\n\nconst _sendBeacon = (options: RequestWithOptions) => {\n // beacon documentation https://w3c.github.io/beacon/\n // beacons format the message and use the type property\n\n const url = extendURLParams(options.url, {\n beacon: '1',\n })\n\n try {\n const { contentType, body } = encodePostData(options) ?? {}\n // sendBeacon requires a blob so we convert it\n const sendBeaconBody = typeof body === 'string' ? new Blob([body], { type: contentType }) : body\n navigator!.sendBeacon!(url, sendBeaconBody)\n } catch {\n // send beacon is a best-effort, fire-and-forget mechanism on page unload,\n // we don't want to throw errors here\n }\n}\n\nconst AVAILABLE_TRANSPORTS: {\n transport: RequestWithOptions['transport']\n method: (options: RequestWithOptions) => void\n}[] = []\n\n// We add the transports in order of preference\nif (fetch) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'fetch',\n method: _fetch,\n })\n}\n\nif (XMLHttpRequest) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'XHR',\n method: xhr,\n })\n}\n\nif (navigator?.sendBeacon) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'sendBeacon',\n method: _sendBeacon,\n })\n}\n\n// This is the entrypoint. It takes care of sanitizing the options and then calls the appropriate request method.\nexport const request = (_options: RequestWithOptions) => {\n // Clone the options so we don't modify the original object\n const options = { ..._options }\n options.timeout = options.timeout || 60000\n\n options.url = extendURLParams(options.url, {\n _: new Date().getTime().toString(),\n ver: Config.LIB_VERSION,\n compression: options.compression,\n })\n\n const transport = options.transport ?? 'fetch'\n\n const availableTransports = AVAILABLE_TRANSPORTS.filter(\n (t) => !options.disableTransport || !t.transport || !options.disableTransport.includes(t.transport)\n )\n\n const transportMethod =\n find(availableTransports, (t) => t.transport === transport)?.method ?? availableTransports[0].method\n\n if (!transportMethod) {\n throw new Error('No available transport method')\n }\n\n transportMethod(options)\n}\n","import { ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS, ERROR_TRACKING_SUPPRESSION_RULES } from './constants'\nimport { PostHog } from './posthog-core'\nimport { CaptureResult, ErrorTrackingSuppressionRule, Properties, RemoteConfig } from './types'\nimport { createLogger } from './utils/logger'\nimport { propertyComparisons } from './utils/property-utils'\nimport { isString, isArray, ErrorTracking, isNullish } from '@posthog/core'\n\nconst logger = createLogger('[Error tracking]')\n\nexport function buildErrorPropertiesBuilder() {\n return new ErrorTracking.ErrorPropertiesBuilder(\n [\n new ErrorTracking.DOMExceptionCoercer(),\n new ErrorTracking.PromiseRejectionEventCoercer(),\n new ErrorTracking.ErrorEventCoercer(),\n new ErrorTracking.ErrorCoercer(),\n new ErrorTracking.EventCoercer(),\n new ErrorTracking.ObjectCoercer(),\n new ErrorTracking.StringCoercer(),\n new ErrorTracking.PrimitiveCoercer(),\n ],\n ErrorTracking.createStackParser(\n 'web:javascript',\n ErrorTracking.chromeStackLineParser,\n ErrorTracking.geckoStackLineParser\n )\n )\n}\nexport class PostHogExceptions {\n private readonly _instance: PostHog\n private _suppressionRules: ErrorTrackingSuppressionRule[] = []\n private _errorPropertiesBuilder: ErrorTracking.ErrorPropertiesBuilder = buildErrorPropertiesBuilder()\n\n constructor(instance: PostHog) {\n this._instance = instance\n this._suppressionRules = this._instance.persistence?.get_property(ERROR_TRACKING_SUPPRESSION_RULES) ?? []\n }\n\n onRemoteConfig(response: RemoteConfig) {\n const suppressionRules = response.errorTracking?.suppressionRules ?? []\n const captureExtensionExceptions = response.errorTracking?.captureExtensionExceptions\n\n // store this in-memory in case persistence is disabled\n this._suppressionRules = suppressionRules\n\n if (this._instance.persistence) {\n this._instance.persistence.register({\n [ERROR_TRACKING_SUPPRESSION_RULES]: this._suppressionRules,\n [ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS]: captureExtensionExceptions,\n })\n }\n }\n\n private get _captureExtensionExceptions() {\n const enabled_server_side = !!this._instance.get_property(ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS)\n const enabled_client_side = this._instance.config.error_tracking.captureExtensionExceptions\n return enabled_client_side ?? enabled_server_side ?? false\n }\n\n buildProperties(\n input: unknown,\n metadata?: { handled?: boolean; syntheticException?: Error }\n ): ErrorTracking.ErrorProperties {\n return this._errorPropertiesBuilder.buildFromUnknown(input, {\n syntheticException: metadata?.syntheticException,\n mechanism: {\n handled: metadata?.handled,\n },\n })\n }\n\n sendExceptionEvent(properties: Properties): CaptureResult | undefined {\n const exceptionList = properties.$exception_list\n\n if (this._isExceptionList(exceptionList)) {\n if (this._matchesSuppressionRule(exceptionList)) {\n logger.info('Skipping exception capture because a suppression rule matched')\n return\n }\n\n if (!this._captureExtensionExceptions && this._isExtensionException(exceptionList)) {\n logger.info('Skipping exception capture because it was thrown by an extension')\n return\n }\n\n if (\n !this._instance.config.error_tracking.__capturePostHogExceptions &&\n this._isPostHogException(exceptionList)\n ) {\n logger.info('Skipping exception capture because it was thrown by the PostHog SDK')\n return\n }\n }\n\n return this._instance.capture('$exception', properties, {\n _noTruncate: true,\n _batchKey: 'exceptionEvent',\n })\n }\n\n private _matchesSuppressionRule(exceptionList: ErrorTracking.ExceptionList): boolean {\n if (exceptionList.length === 0) {\n return false\n }\n\n const exceptionValues = exceptionList.reduce(\n (acc, { type, value }) => {\n if (isString(type) && type.length > 0) {\n acc['$exception_types'].push(type)\n }\n if (isString(value) && value.length > 0) {\n acc['$exception_values'].push(value)\n }\n return acc\n },\n {\n $exception_types: [] as string[],\n $exception_values: [] as string[],\n }\n )\n\n return this._suppressionRules.some((rule) => {\n const results = rule.values.map((v) => {\n const compare = propertyComparisons[v.operator]\n const targets = isArray(v.value) ? v.value : [v.value]\n const values = exceptionValues[v.key] ?? []\n return targets.length > 0 ? compare(targets, values) : false\n })\n return rule.type === 'OR' ? results.some(Boolean) : results.every(Boolean)\n })\n }\n\n private _isExtensionException(exceptionList: ErrorTracking.ExceptionList): boolean {\n const frames = exceptionList.flatMap((e) => e.stacktrace?.frames ?? [])\n return frames.some((f) => f.filename && f.filename.startsWith('chrome-extension://'))\n }\n\n private _isPostHogException(exceptionList: ErrorTracking.ExceptionList): boolean {\n if (exceptionList.length > 0) {\n const exception = exceptionList[0]\n const frames = exception.stacktrace?.frames ?? []\n const lastFrame = frames[frames.length - 1]\n return lastFrame?.filename?.includes('posthog.com/static') ?? false\n }\n\n return false\n }\n\n private _isExceptionList(candidate: unknown): candidate is ErrorTracking.ExceptionList {\n return !isNullish(candidate) && isArray(candidate)\n }\n}\n","import { assignableWindow, window } from '../utils/globals'\nimport { ErrorEventArgs } from '../types'\nimport { createLogger } from '../utils/logger'\nimport type { ErrorTracking } from '@posthog/core'\nimport { buildErrorPropertiesBuilder } from '../posthog-exceptions'\n\nconst logger = createLogger('[ExceptionAutocapture]')\nconst errorPropertiesBuilder = buildErrorPropertiesBuilder()\n\nconst wrapOnError = (captureFn: (props: ErrorTracking.ErrorProperties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onerror')\n }\n const originalOnError = win.onerror\n\n win.onerror = function (...args: ErrorEventArgs): boolean {\n const error = args[4]\n const event = args[0]\n const errorProperties = errorPropertiesBuilder.buildFromUnknown(error || event, {\n mechanism: { handled: false },\n })\n captureFn(errorProperties)\n return originalOnError?.(...args) ?? false\n }\n win.onerror.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onerror?.__POSTHOG_INSTRUMENTED__\n win.onerror = originalOnError\n }\n}\n\nconst wrapUnhandledRejection = (captureFn: (props: ErrorTracking.ErrorProperties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onUnhandledRejection')\n }\n\n const originalOnUnhandledRejection = win.onunhandledrejection\n\n win.onunhandledrejection = function (ev: PromiseRejectionEvent): boolean {\n const errorProperties = errorPropertiesBuilder.buildFromUnknown(ev, {\n mechanism: { handled: false },\n })\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, [ev]) ?? false\n }\n win.onunhandledrejection.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onunhandledrejection?.__POSTHOG_INSTRUMENTED__\n win.onunhandledrejection = originalOnUnhandledRejection\n }\n}\n\nconst wrapConsoleError = (captureFn: (props: ErrorTracking.ErrorProperties) => void) => {\n const con = console as any\n if (!con) {\n logger.info('console not available, cannot wrap console.error')\n }\n\n const originalConsoleError = con.error\n\n con.error = function (...args: any[]): void {\n const event = args.join(' ')\n const error = args.find((arg) => arg instanceof Error)\n const errorProperties = errorPropertiesBuilder.buildFromUnknown(error || event, {\n mechanism: { handled: false },\n syntheticException: new Error('PostHog syntheticException'),\n })\n captureFn(errorProperties)\n return originalConsoleError?.(...args)\n }\n con.error.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete con.error?.__POSTHOG_INSTRUMENTED__\n con.error = originalConsoleError\n }\n}\n\nconst posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n wrapConsoleError,\n}\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.errorWrappingFunctions = posthogErrorWrappingFunctions\n\n// we used to put these on window, and now we put them on __PosthogExtensions__\n// but that means that old clients which lazily load this extension are looking in the wrong place\n// yuck,\n// so we also put them directly on the window\n// when 1.161.1 is the oldest version seen in production we can remove this\nassignableWindow.posthogErrorWrappingFunctions = posthogErrorWrappingFunctions\n\nexport default posthogErrorWrappingFunctions\n"],"names":["win","window","undefined","global","globalThis","self","File","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","nativeIsArray","Array","isArray","type_utils_toString","Object","prototype","toString","obj","call","isUndefined","x","isString","isPrimitive","value","isBuiltin","candidate","className","isEvent","Event","base","_unused","isInstanceOf","parsedStackResults","lastKeysCount","cachedFilenameChunkIds","getFilenameToChunkIdMap","stackParser","chunkIdMap","_posthogChunkIds","chunkIdKeys","keys","length","reduce","acc","stackKey","result","parsedStack","i","stackFrame","filename","chunkId","ErrorPropertiesBuilder","constructor","coercers","modifiers","this","buildFromUnknown","input","hint","mechanism","handled","type","exceptionWithCause","buildCoercingContext","apply","parsingContext","buildParsingContext","exceptionWithStack","parseStacktrace","$exception_list","convertToExceptionList","$exception_level","modifyFrames","exceptionList","_this","_asyncToGenerator","exc","stacktrace","frames","applyModifiers","coerceFallback","ctx","_ctx$syntheticExcepti","stack","syntheticException","synthetic","err","cause","applyChunkIds","_extends","map","frame","chunk_id","applyCoercers","adapter","match","coerce","_this2","newFrames","modifier","_mechanism$type","_mechanism$handled","_exceptionWithStack$s","currentException","push","depth","next","UNKNOWN_FUNCTION","createFrame","platform","func","lineno","colno","function","in_app","extractSafariExtensionDetails","isSafariExtension","indexOf","isSafariWebExtension","split","chromeRegexNoFnName","chromeRegex","chromeEvalRegex","chromeStackLineParser","line","noFnParts","exec","col","parts","subMatch","geckoREgex","geckoEvalRegex","geckoStackLineParser","WEBPACK_ERROR_REGEXP","STACKTRACE_FRAME_LIMIT","createStackParser","_len","arguments","parsers","_key","skipFirstLines","lines","cleanedLine","test","replace","parser","localStack","from","reverse","slice","arr","reverseAndStripFrames","DOMExceptionCoercer","isDOMException","isDOMError","hasStack","getType","getValue","name","message","ErrorCoercer","Error","getMessage","getStack","_ctx","error","String","ErrorEventCoercer","exceptionLike","ERROR_TYPES_PATTERN","StringCoercer","getInfos","groups","severityLevels","extractExceptionKeysForMessage","maxLength","sort","serialized","join","ObjectCoercer","errorProperty","getErrorPropertyFromObject","level","isSeverityLevel","getObjectClassName","trim","isEmptyString","prop","hasOwnProperty","getPrototypeOf","e","EventCoercer","evt","constructorName","PrimitiveCoercer","PromiseRejectionEventCoercer","reason","getUnhandledRejectionReason","detail","_createLogger","prefix","_temp","debugEnabled","logger","_log","POSTHOG_DEBUG","console","consoleLog","args","info","_len2","_key2","warn","_len3","_key3","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","createLogger","additionalPrefix","options","sendBeacon","errorPropertiesBuilder","ErrorTracking","posthogErrorWrappingFunctions","wrapOnError","captureFn","originalOnError","onerror","_originalOnError","event","errorProperties","__POSTHOG_INSTRUMENTED__","_win$onerror","wrapUnhandledRejection","originalOnUnhandledRejection","onunhandledrejection","ev","_originalOnUnhandledR","_win$onunhandledrejec","wrapConsoleError","con","originalConsoleError","find","arg","_con$error","__PosthogExtensions__","errorWrappingFunctions"],"mappings":"yBA2BA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAqMzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAG3E,oBAATK,OACLF,EAAeE,KAAOF,GAER,oBAATG,OACLH,EAAeG,KA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