posthog-js 1.187.1 → 1.187.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.
Files changed (41) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.js +1 -10
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -10
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -10
  9. package/dist/array.js.map +1 -1
  10. package/dist/array.no-external.js +1 -10
  11. package/dist/array.no-external.js.map +1 -1
  12. package/dist/dead-clicks-autocapture.js +1 -1
  13. package/dist/dead-clicks-autocapture.js.map +1 -1
  14. package/dist/exception-autocapture.js +1 -1
  15. package/dist/exception-autocapture.js.map +1 -1
  16. package/dist/external-scripts-loader.js +1 -1
  17. package/dist/external-scripts-loader.js.map +1 -1
  18. package/dist/main.js +1 -10
  19. package/dist/main.js.map +1 -1
  20. package/dist/module.full.js +1 -10
  21. package/dist/module.full.js.map +1 -1
  22. package/dist/module.full.no-external.js +1 -10
  23. package/dist/module.full.no-external.js.map +1 -1
  24. package/dist/module.js +1 -10
  25. package/dist/module.js.map +1 -1
  26. package/dist/module.no-external.js +1 -10
  27. package/dist/module.no-external.js.map +1 -1
  28. package/dist/recorder-v2.js +1 -1
  29. package/dist/recorder-v2.js.map +1 -1
  30. package/dist/recorder.js +1 -1
  31. package/dist/recorder.js.map +1 -1
  32. package/dist/surveys-preview.js +1 -1
  33. package/dist/surveys-preview.js.map +1 -1
  34. package/dist/surveys.js +1 -1
  35. package/dist/surveys.js.map +1 -1
  36. package/dist/tracing-headers.js +1 -1
  37. package/dist/tracing-headers.js.map +1 -1
  38. package/dist/web-vitals.js +1 -1
  39. package/dist/web-vitals.js.map +1 -1
  40. package/lib/package.json +1 -1
  41. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- !function(){"use strict";const e="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:e,t=null==n?void 0:n.navigator;null==n||n.document,null==n||n.location,null==n||n.fetch,null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest&&n.XMLHttpRequest,null==n||n.AbortController,null==t||t.userAgent;const r=null!=e?e:{},o="[PostHog.js]",i={_log:function(n){if(e&&r.POSTHOG_DEBUG&&!p(e.console)&&e.console){const r="__rrweb_original__"in e.console[n]?e.console[n].__rrweb_original__:e.console[n];for(var t=arguments.length,i=new Array(t>1?t-1:0),c=1;c<t;c++)i[c-1]=arguments[c];r(o,...i)}},info:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];i._log("log",...n)},warn:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];i._log("warn",...n)},error:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];i._log("error",...n)},critical:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];console.error(o,...n)},uninitializedWarning:e=>{i.error(`You must initialize PostHog before calling ${e}`)}};let c;!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(c||(c={}));const l=["fatal","error","warning","log","info","debug"],s=Array.isArray,a=Object.prototype.toString,u=s||function(e){return"[object Array]"===a.call(e)},d=e=>"function"==typeof e,f=e=>e===Object(e)&&!u(e),p=e=>void 0===e,v=e=>"[object String]"==a.call(e),g=e=>v(e)&&0===e.trim().length,h=e=>null===e;function E(e){return!p(Event)&&x(e,Event)}function x(e,n){try{return e instanceof n}catch{return!1}}function _(e){return h(e)||!f(e)&&!d(e)}function y(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function w(e){return y(e,"DOMError")}const m=/\(error: (.*)\)/,O=50,b="?";function j(e,n,t,r){const o={platform:"javascript",filename:e,function:"<anonymous>"===n?b:n,in_app:!0};return p(t)||(o.lineno=t),p(r)||(o.colno=r),o}const M=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,T=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,$=/\((\S*)(?::(\d+))(?::(\d+))\)/,S=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,A=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,R=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];const r=n.sort(((e,n)=>e[0]-n[0])).map((e=>e[1]));return function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const t=[],o=e.split("\n");for(let e=n;e<o.length;e++){const n=o[e];if(n.length>1024)continue;const i=m.test(n)?n.replace(m,"$1"):n;if(!i.match(/\S*Error: /)){for(const e of r){const n=e(i);if(n){t.push(n);break}}if(t.length>=O)break}}return function(e){if(!e.length)return[];const n=Array.from(e);return n.reverse(),n.slice(0,O).map((e=>({...e,filename:e.filename||D(n).filename,function:e.function||b})))}(t)}}(...[[30,e=>{const n=M.exec(e);if(n){const[,e,t,r]=n;return j(e,b,+t,+r)}const t=T.exec(e);if(t){if(t[2]&&0===t[2].indexOf("eval")){const e=$.exec(t[2]);e&&(t[2]=e[1],t[3]=e[2],t[4]=e[3])}const[e,n]=P(t[1]||b,t[2]);return j(n,e,t[3]?+t[3]:void 0,t[4]?+t[4]:void 0)}}],[50,e=>{const n=S.exec(e);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){const e=A.exec(n[3]);e&&(n[1]=n[1]||"eval",n[3]=e[1],n[4]=e[2],n[5]="")}let e=n[3],t=n[1]||b;return[t,e]=P(t,e),j(e,t,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}}]]);function D(e){return e[e.length-1]||{}}const P=(e,n)=>{const t=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return t||r?[-1!==e.indexOf("@")?e.split("@")[0]:b,t?`safari-extension:${n}`:`safari-web-extension:${n}`]:[e,n]},k=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function U(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const t=e.stacktrace||e.stack||"",r=function(e){if(e&&H.test(e.message))return 1;return 0}(e);try{const e=R(t,r);return e.slice(0,e.length-n)}catch{}return[]}const H=/Minified React error #\d+;/i;function N(e,n){var t,r;const o=U(e),i=null===(t=null==n?void 0:n.handled)||void 0===t||t,c=null!==(r=null==n?void 0:n.synthetic)&&void 0!==r&&r;return{$exception_list:[{type:null!=n&&n.overrideExceptionType?n.overrideExceptionType:e.name,value:null!=n&&n.overrideExceptionMessage?n.overrideExceptionMessage:function(e){const n=e.message;if(n.error&&"string"==typeof n.error.message)return n.error.message;return n}(e),stacktrace:{frames:o,type:"raw"},mechanism:{handled:i,synthetic:c}}],$exception_level:"error"}}function G(e,n){var t,r,o;const i=null===(t=null==n?void 0:n.handled)||void 0===t||t,c=null===(r=null==n?void 0:n.synthetic)||void 0===r||r,l={type:null!=n&&n.overrideExceptionType?n.overrideExceptionType:null!==(o=null==n?void 0:n.defaultExceptionType)&&void 0!==o?o:"Error",value:null!=n&&n.overrideExceptionMessage?n.overrideExceptionMessage:e||(null==n?void 0:n.defaultExceptionMessage),mechanism:{handled:i,synthetic:c}};if(null!=n&&n.syntheticException){const e=U(n.syntheticException,1);e.length&&(l.stacktrace={frames:e,type:"raw"})}return{$exception_list:[l],$exception_level:"error"}}function I(e,n){var t,r;const o=null===(t=null==n?void 0:n.handled)||void 0===t||t,i=null===(r=null==n?void 0:n.synthetic)||void 0===r||r,c=null!=n&&n.overrideExceptionType?n.overrideExceptionType:E(e)?e.constructor.name:"Error",s=null!=n&&n.overrideExceptionMessage?n.overrideExceptionMessage:`Non-Error exception captured with keys: ${function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:40;const t=Object.keys(e);if(t.sort(),!t.length)return"[object has no keys]";for(let e=t.length;e>0;e--){const r=t.slice(0,e).join(", ");if(!(r.length>n))return e===t.length||r.length<=n?r:`${r.slice(0,n)}...`}return""}(e)}`,a={type:c,value:s,mechanism:{handled:o,synthetic:i}};if(null!=n&&n.syntheticException){const e=U(null==n?void 0:n.syntheticException,1);e.length&&(a.stacktrace={frames:e,type:"raw"})}return{$exception_list:[a],$exception_level:(u=e.level,v(u)&&!g(u)&&l.indexOf(u)>=0?e.level:"error")};var u}function z(e,n){let[t,r,o,i,c]=e,l={$exception_list:[]};const s=c||t;if(w(s)||function(e){return y(e,"DOMException")}(s)){const e=s;if(function(e){return"stack"in e}(s))l=N(s,n);else{const t=e.name||(w(e)?"DOMError":"DOMException"),r=e.message?`${t}: ${e.message}`:t,o=w(e)?"DOMError":"DOMException";l=G(r,{...n,overrideExceptionType:o,defaultExceptionMessage:r})}return"code"in e&&(l.$exception_DOMException_code=`${e.code}`),l}if(function(e){return y(e,"ErrorEvent")}(s)&&s.error)return N(s.error,n);if(function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return x(e,Error)}}(s))return N(s,n);if(function(e){return y(e,"Object")}(s)||E(s)){return I(s,n)}if(p(c)&&v(t)){let e="Error",r=t;const o=t.match(k);return o&&(e=o[1],r=o[2]),G(r,{...n,overrideExceptionType:e,defaultExceptionMessage:r})}return G(s,n)}function q(e){let[n]=e;const t=function(e){if(_(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}(n);return _(t)?G(`Non-Error promise rejection captured with value: ${String(t)}`,{handled:!1,synthetic:!1,overrideExceptionType:"UnhandledRejection"}):z([t],{handled:!1,overrideExceptionType:"UnhandledRejection",defaultExceptionMessage:String(t)})}const L={wrapOnError:n=>{const t=e;t||i.info("window not available, cannot wrap onerror");const r=t.onerror;return t.onerror=function(){for(var e,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];const c=z(o);return n(c),null!==(e=null==r?void 0:r(...o))&&void 0!==e&&e},t.onerror.__POSTHOG_INSTRUMENTED__=!0,()=>{var e;null===(e=t.onerror)||void 0===e||delete e.__POSTHOG_INSTRUMENTED__,t.onerror=r}},wrapUnhandledRejection:n=>{const t=e;t||i.info("window not available, cannot wrap onUnhandledRejection");const r=t.onunhandledrejection;return t.onunhandledrejection=function(){for(var e,o=arguments.length,i=new Array(o),c=0;c<o;c++)i[c]=arguments[c];const l=q(i);return n(l),null!==(e=null==r?void 0:r.apply(t,i))&&void 0!==e&&e},t.onunhandledrejection.__POSTHOG_INSTRUMENTED__=!0,()=>{var e;null===(e=t.onunhandledrejection)||void 0===e||delete e.__POSTHOG_INSTRUMENTED__,t.onunhandledrejection=r}}};r.__PosthogExtensions__=r.__PosthogExtensions__||{},r.__PosthogExtensions__.errorWrappingFunctions=L,r.__PosthogExtensions__.parseErrorAsProperties=z,r.posthogErrorWrappingFunctions=L,r.parseErrorAsProperties=z}();
1
+ !function(){"use strict";function e(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function r(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach((function(e){n(r,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function n(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var t="undefined"!=typeof window?window:void 0,o="undefined"!=typeof globalThis?globalThis:t,i=null==o?void 0:o.navigator;null==o||o.document,null==o||o.location,null==o||o.fetch,null!=o&&o.XMLHttpRequest&&"withCredentials"in new o.XMLHttpRequest&&o.XMLHttpRequest,null==o||o.AbortController,null==i||i.userAgent;var a,c=null!=t?t:{},l="[PostHog.js]",u={_log:function(e){if(t&&c.POSTHOG_DEBUG&&!h(t.console)&&t.console){for(var r=("__rrweb_original__"in t.console[e]?t.console[e].__rrweb_original__:t.console[e]),n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];r(l,...o)}},info:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];u._log("log",...r)},warn:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];u._log("warn",...r)},error:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];u._log("error",...r)},critical:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];console.error(l,...r)},uninitializedWarning:e=>{u.error("You must initialize PostHog before calling ".concat(e))}};!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(a||(a={}));var s=["fatal","error","warning","log","info","debug"],d=Array.isArray,v=Object.prototype.toString,f=d||function(e){return"[object Array]"===v.call(e)},p=e=>"function"==typeof e,g=e=>e===Object(e)&&!f(e),h=e=>void 0===e,y=e=>"[object String]"==v.call(e),E=e=>y(e)&&0===e.trim().length,x=e=>null===e;function _(e){return!h(Event)&&O(e,Event)}function O(e,r){try{return e instanceof r}catch(e){return!1}}function b(e){return x(e)||!g(e)&&!p(e)}function w(e,r){return Object.prototype.toString.call(e)==="[object ".concat(r,"]")}function j(e){return w(e,"DOMError")}var m=/\(error: (.*)\)/,M=50,T="?";function S(e,r,n,t){var o={platform:"javascript",filename:e,function:"<anonymous>"===r?T:r,in_app:!0};return h(n)||(o.lineno=n),h(t)||(o.colno=t),o}var P=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,D=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,A=/\((\S*)(?::(\d+))(?::(\d+))\)/,R=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,$=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,k=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var o=n.sort(((e,r)=>e[0]-r[0])).map((e=>e[1]));return function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=[],i=e.split("\n"),a=n;a<i.length;a++){var c=i[a];if(!(c.length>1024)){var l=m.test(c)?c.replace(m,"$1"):c;if(!l.match(/\S*Error: /)){for(var u of o){var s=u(l);if(s){t.push(s);break}}if(t.length>=M)break}}}return function(e){if(!e.length)return[];var n=Array.from(e);return n.reverse(),n.slice(0,M).map((e=>r(r({},e),{},{filename:e.filename||U(n).filename,function:e.function||T})))}(t)}}(...[[30,e=>{var r=P.exec(e);if(r){var[,n,t,o]=r;return S(n,T,+t,+o)}var i=D.exec(e);if(i){if(i[2]&&0===i[2].indexOf("eval")){var a=A.exec(i[2]);a&&(i[2]=a[1],i[3]=a[2],i[4]=a[3])}var[c,l]=H(i[1]||T,i[2]);return S(l,c,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,e=>{var r=R.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){var n=$.exec(r[3]);n&&(r[1]=r[1]||"eval",r[3]=n[1],r[4]=n[2],r[5]="")}var t=r[3],o=r[1]||T;return[o,t]=H(o,t),S(t,o,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}}]]);function U(e){return e[e.length-1]||{}}var H=(e,r)=>{var n=-1!==e.indexOf("safari-extension"),t=-1!==e.indexOf("safari-web-extension");return n||t?[-1!==e.indexOf("@")?e.split("@")[0]:T,n?"safari-extension:".concat(r):"safari-web-extension:".concat(r)]:[e,r]},N=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function G(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e.stacktrace||e.stack||"",t=function(e){if(e&&I.test(e.message))return 1;return 0}(e);try{var o=k(n,t);return o.slice(0,o.length-r)}catch(e){}return[]}var I=/Minified React error #\d+;/i;function z(e,r){var n,t,o=G(e),i=null===(n=null==r?void 0:r.handled)||void 0===n||n,a=null!==(t=null==r?void 0:r.synthetic)&&void 0!==t&&t;return{$exception_list:[{type:null!=r&&r.overrideExceptionType?r.overrideExceptionType:e.name,value:null!=r&&r.overrideExceptionMessage?r.overrideExceptionMessage:function(e){var r=e.message;if(r.error&&"string"==typeof r.error.message)return r.error.message;return r}(e),stacktrace:{frames:o,type:"raw"},mechanism:{handled:i,synthetic:a}}],$exception_level:"error"}}function q(e,r){var n,t,o,i=null===(n=null==r?void 0:r.handled)||void 0===n||n,a=null===(t=null==r?void 0:r.synthetic)||void 0===t||t,c={type:null!=r&&r.overrideExceptionType?r.overrideExceptionType:null!==(o=null==r?void 0:r.defaultExceptionType)&&void 0!==o?o:"Error",value:null!=r&&r.overrideExceptionMessage?r.overrideExceptionMessage:e||(null==r?void 0:r.defaultExceptionMessage),mechanism:{handled:i,synthetic:a}};if(null!=r&&r.syntheticException){var l=G(r.syntheticException,1);l.length&&(c.stacktrace={frames:l,type:"raw"})}return{$exception_list:[c],$exception_level:"error"}}function L(e,r){var n,t,o,i=null===(n=null==r?void 0:r.handled)||void 0===n||n,a=null===(t=null==r?void 0:r.synthetic)||void 0===t||t,c=null!=r&&r.overrideExceptionType?r.overrideExceptionType:_(e)?e.constructor.name:"Error",l=null!=r&&r.overrideExceptionMessage?r.overrideExceptionMessage:"Non-Error ".concat("exception"," captured with keys: ",function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:40,n=Object.keys(e);if(n.sort(),!n.length)return"[object has no keys]";for(var t=n.length;t>0;t--){var o=n.slice(0,t).join(", ");if(!(o.length>r))return t===n.length||o.length<=r?o:"".concat(o.slice(0,r),"...")}return""}(e)),u={type:c,value:l,mechanism:{handled:i,synthetic:a}};if(null!=r&&r.syntheticException){var d=G(null==r?void 0:r.syntheticException,1);d.length&&(u.stacktrace={frames:d,type:"raw"})}return{$exception_list:[u],$exception_level:(o=e.level,y(o)&&!E(o)&&s.indexOf(o)>=0?e.level:"error")}}function W(e,n){var[t,o,i,a,c]=e,l={$exception_list:[]},u=c||t;if(j(u)||function(e){return w(e,"DOMException")}(u)){var s=u;if(function(e){return"stack"in e}(u))l=z(u,n);else{var d=s.name||(j(s)?"DOMError":"DOMException"),v=s.message?"".concat(d,": ").concat(s.message):d,f=j(s)?"DOMError":"DOMException";l=q(v,r(r({},n),{},{overrideExceptionType:f,defaultExceptionMessage:v}))}return"code"in s&&(l.$exception_DOMException_code="".concat(s.code)),l}if(function(e){return w(e,"ErrorEvent")}(u)&&u.error)return z(u.error,n);if(function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return O(e,Error)}}(u))return z(u,n);if(function(e){return w(e,"Object")}(u)||_(u))return L(u,n);if(h(c)&&y(t)){var p="Error",g=t,E=t.match(N);return E&&(p=E[1],g=E[2]),q(g,r(r({},n),{},{overrideExceptionType:p,defaultExceptionMessage:g}))}return q(u,n)}function X(e){var[r]=e,n=function(e){if(b(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}(r);return b(n)?q("Non-Error promise rejection captured with value: ".concat(String(n)),{handled:!1,synthetic:!1,overrideExceptionType:"UnhandledRejection"}):W([n],{handled:!1,overrideExceptionType:"UnhandledRejection",defaultExceptionMessage:String(n)})}var B={wrapOnError:e=>{var r=t;r||u.info("window not available, cannot wrap onerror");var n=r.onerror;return r.onerror=function(){for(var r,t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];var a=W(o);return e(a),null!==(r=null==n?void 0:n(...o))&&void 0!==r&&r},r.onerror.__POSTHOG_INSTRUMENTED__=!0,()=>{var e;null===(e=r.onerror)||void 0===e||delete e.__POSTHOG_INSTRUMENTED__,r.onerror=n}},wrapUnhandledRejection:e=>{var r=t;r||u.info("window not available, cannot wrap onUnhandledRejection");var n=r.onunhandledrejection;return r.onunhandledrejection=function(){for(var t,o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];var c=X(i);return e(c),null!==(t=null==n?void 0:n.apply(r,i))&&void 0!==t&&t},r.onunhandledrejection.__POSTHOG_INSTRUMENTED__=!0,()=>{var e;null===(e=r.onunhandledrejection)||void 0===e||delete e.__POSTHOG_INSTRUMENTED__,r.onunhandledrejection=n}}};c.__PosthogExtensions__=c.__PosthogExtensions__||{},c.__PosthogExtensions__.errorWrappingFunctions=B,c.__PosthogExtensions__.parseErrorAsProperties=W,c.posthogErrorWrappingFunctions=B,c.parseErrorAsProperties=W}();
2
2
  //# sourceMappingURL=exception-autocapture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exception-autocapture.js","sources":["../src/utils/globals.ts","../src/utils/logger.ts","../src/types.ts","../src/utils/type-utils.ts","../src/extensions/exception-autocapture/type-checking.ts","../src/extensions/exception-autocapture/stack-trace.ts","../src/extensions/exception-autocapture/error-conversion.ts","../src/entrypoints/exception-autocapture.ts"],"sourcesContent":["import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion'\nimport type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport { DeadClicksAutoCaptureConfig, ErrorEventArgs, ErrorMetadata, Properties } from '../types'\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 Record<string, any> & {\n __PosthogExtensions__?: PostHogExtensions\n }\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 PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'dead-clicks-autocapture'\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 parseErrorAsProperties?: (\n [event, source, lineno, colno, error]: ErrorEventArgs,\n metadata?: ErrorMetadata\n ) => ErrorProperties\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: Properties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: Properties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n canActivateRepeatedly?: (survey: any) => boolean\n generateSurveys?: (posthog: PostHog) => 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: (sessionManager: SessionIdManager) => () => void\n _patchXHR: (sessionManager: any) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\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 Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nconst LOGGER_PREFIX = '[PostHog.js]'\nexport const logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG) &&\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(LOGGER_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(LOGGER_PREFIX, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n}\n","import { PostHog } from './posthog-core'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { recordOptions } from './extensions/replay/sessionrecording-utils'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\nexport const knownUnsafeEditableEvent = [\n '$snapshot',\n '$pageview',\n '$pageleave',\n '$set',\n 'survey dismissed',\n 'survey sent',\n 'survey shown',\n '$identify',\n '$groupidentify',\n '$create_alias',\n '$$client_ingestion_warning',\n '$web_experiment_applied',\n '$feature_enrollment_update',\n '$feature_flag_called',\n] as const\n\n/**\n * These events can be processed by the `beforeCapture` function\n * but can cause unexpected confusion in data.\n *\n * Some features of PostHog rely on receiving 100% of these events\n */\nexport type KnownUnsafeEditableEvent = typeof knownUnsafeEditableEvent[number]\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * if the allowlist has button then we allow the capture when the button or the svg is the click target\n * but not if either of the divs are detected as the click target\n */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * and allow list config `['[id]']`\n * we will capture the click if the click-target or its parents has any id\n */\n css_selector_allowlist?: string[]\n\n /**\n * Exclude certain element attributes from autocapture\n * E.g. ['aria-label'] or [data-attr-pii]\n */\n element_attribute_ignorelist?: string[]\n\n capture_copied_text?: boolean\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\n\nexport interface PerformanceCaptureConfig {\n /** works with session replay to use the browser's native performance observer to capture performance metrics */\n network_timing?: boolean\n /** use chrome's web vitals library to wrap fetch and capture web vitals */\n web_vitals?: boolean\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n * if not set this defaults to 15 minutes\n */\n __web_vitals_max_value?: number\n /**\n * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n /**\n * we delay flushing web vitals metrics to reduce the number of events we send\n * this is the maximum time we will wait before sending the metrics\n * if not set it defaults to 5 seconds\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n // by default if a click is followed by a sroll within 100ms it is not a dead click\n scroll_threshold_ms?: number\n // by default if a click is followed by a selection change within 100ms it is not a dead click\n selection_change_threshold_ms?: number\n // by default if a click is followed by a mutation within 2500ms it is not a dead click\n mutation_threshold_ms?: number\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by the SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\n\nexport interface HeatmapConfig {\n /*\n * how often to send batched data in $$heatmap_data events\n * if set to 0 or not set, sends using the default interval of 1 second\n * */\n flush_interval_milliseconds: number\n}\n\nexport type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\n\nexport interface PostHogConfig {\n api_host: string\n /** @deprecated - This property is no longer supported */\n api_method?: string\n api_transport?: 'XHR' | 'fetch'\n ui_host: string | null\n token: string\n autocapture: boolean | AutocaptureConfig\n rageclick: boolean\n cross_subdomain_cookie: boolean\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n persistence_name: string\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n loaded: (posthog_instance: PostHog) => void\n store_google: boolean\n custom_campaign_params: string[]\n // a list of strings to be tested against navigator.userAgent to determine if the source is a bot\n // this is **added to** the default list of bots that we check\n // defaults to the empty array\n custom_blocked_useragents: string[]\n save_referrer: boolean\n verbose: boolean\n capture_pageview: boolean\n capture_pageleave: boolean | 'if_capture_pageview'\n debug: boolean\n cookie_expiration: number\n upgrade: boolean\n disable_session_recording: boolean\n disable_persistence: boolean\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n disable_surveys: boolean\n disable_web_experiments: boolean\n /** If set, posthog-js will never load external scripts such as those needed for Session Replay or Surveys. */\n disable_external_dependency_loading?: boolean\n enable_recording_console_log?: boolean\n secure_cookie: boolean\n ip: boolean\n /** Starts the SDK in an opted out state requiring opt_in_capturing() to be called before events will b captured */\n opt_out_capturing_by_default: boolean\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n /** If set to true this will disable persistence if the user is opted out of capturing. @default false */\n opt_out_persistence_by_default?: boolean\n /** Opt out of user agent filtering such as googlebot or other bots. Defaults to `false` */\n opt_out_useragent_filter: boolean\n\n opt_out_capturing_cookie_prefix: string | null\n opt_in_site_apps: boolean\n respect_dnt: boolean\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n property_denylist: string[]\n request_headers: { [header_name: string]: string }\n on_request_error?: (error: RequestResponse) => void\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n inapp_protocol: string\n inapp_link_new_window: boolean\n request_batching: boolean\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n properties_string_max_length: number\n session_recording: SessionRecordingOptions\n session_idle_timeout_seconds: number\n mask_all_element_attributes: boolean\n mask_all_text: boolean\n advanced_disable_decide: boolean\n advanced_disable_feature_flags: boolean\n advanced_disable_feature_flags_on_first_load: boolean\n advanced_disable_toolbar_metrics: boolean\n feature_flag_request_timeout_ms: number\n get_device_id: (uuid: string) => string\n name: string\n /**\n * this is a read-only function that can be used to react to event capture\n * @deprecated - use `before_send` instead - NB before_send is not read only\n */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\n capture_performance?: boolean | PerformanceCaptureConfig\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: BootstrapConfig\n segment?: SegmentAnalytics\n __preview_send_client_session_params?: boolean\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n capture_heatmaps?: boolean | HeatmapConfig\n capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\n disable_scroll_properties?: boolean\n // Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n scroll_root_selector?: string | string[]\n\n /** You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting. There are three options:\n * - `person_profiles: 'always'` _(default)_ - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` - we will only process persons when you call `posthog.identify`, `posthog.alias`, `posthog.setPersonProperties`, `posthog.group`, `posthog.setPersonPropertiesForFlags` or `posthog.setGroupPropertiesForFlags` Anonymous users won't get person profiles.\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /** Client side rate limiting */\n rate_limiting?: {\n /** The average number of events per second that should be permitted (defaults to 10) */\n events_per_second?: number\n /** How many events can be captured in a burst. This defaults to 10 times the events_per_second count */\n events_burst_limit?: number\n }\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * whether to wrap fetch and add tracing headers to the request\n * */\n __add_tracing_headers?: boolean\n}\n\nexport interface OptInOutCapturingOptions {\n capture: (event: string, properties: Properties, options: CaptureOptions) => void\n capture_event_name: string\n capture_properties: Properties\n enable_persistence: boolean\n clear_persistence: boolean\n persistence_type: 'cookie' | 'localStorage' | 'localStorage+cookie'\n cookie_prefix: string\n cookie_expiration: number\n cross_subdomain_cookie: boolean\n secure_cookie: boolean\n}\n\nexport interface IsFeatureEnabledOptions {\n send_event: boolean\n}\n\nexport interface SessionRecordingOptions {\n blockClass?: string | RegExp\n blockSelector?: string | null\n ignoreClass?: string\n maskTextClass?: string | RegExp\n maskTextSelector?: string | null\n maskTextFn?: ((text: string, element: HTMLElement | null) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: recordOptions['maskInputOptions']\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: recordOptions['slimDOMOptions']\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /**\n * Allows local config to override remote canvas recording settings from the decide response\n */\n captureCanvas?: SessionRecordingCanvasOptions\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // our settings here only support a subset of those proposed for rrweb's network capture plugin\n recordHeaders?: boolean\n recordBody?: boolean\n // ADVANCED: while a user is active we take a full snapshot of the browser every interval. For very few sites playback performance might be better with different interval. Set to 0 to disable\n full_snapshot_interval_millis?: number\n /*\n ADVANCED: whether to partially compress rrweb events before sending them to the server,\n defaults to true, can be set to false to disable partial compression\n NB requests are still compressed when sent to the server regardless of this setting\n */\n compress_events?: boolean\n /*\n ADVANCED: alters the threshold before a recording considers a user has become idle.\n Normally only altered alongside changes to session_idle_timeout_ms.\n Default is 5 minutes.\n */\n session_idle_threshold_ms?: number\n /*\n ADVANCED: alters the refill rate for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 10.\n */\n __mutationRateLimiterRefillRate?: number\n /*\n ADVANCED: alters the bucket size for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 100.\n */\n __mutationRateLimiterBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\nexport interface RequestOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestOptions extends RequestOptions {\n batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestOptions extends QueuedRequestOptions {\n retriesPerformedSoFar?: number\n}\n\nexport interface CaptureOptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _url?: string /** Used to override the desired endpoint for the captured event */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n send_instantly?: boolean /** if set skips the batched queue */\n skip_client_rate_limiting?: boolean /** if set skips the client side rate limiting */\n transport?: RequestOptions['transport'] /** if set, overrides the desired transport method */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport type SessionRecordingCanvasOptions = {\n recordCanvas?: boolean | null\n canvasFps?: number | null\n // the API returns a decimal between 0 and 1 as a string\n canvasQuality?: string | null\n}\n\nexport interface DecideResponse {\n supportedCompression: Compression[]\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n analytics?: {\n endpoint?: string\n }\n elementsChainAsString?: boolean\n // this is currently in development and may have breaking changes without a major version bump\n autocaptureExceptions?:\n | boolean\n | {\n endpoint?: string\n }\n sessionRecording?: SessionRecordingCanvasOptions & {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n heatmaps?: boolean\n defaultIdentifiedOnly?: boolean\n captureDeadClicks?: boolean\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport interface PersistentStore {\n is_supported: () => boolean\n error: (error: any) => void\n parse: (name: string) => any\n get: (name: string) => any\n set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | JsonRecord | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined\n]\n\nexport type ErrorMetadata = {\n handled?: boolean\n synthetic?: boolean\n syntheticException?: Error\n overrideExceptionType?: string\n overrideExceptionMessage?: string\n defaultExceptionType?: string\n defaultExceptionMessage?: string\n}\n\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = typeof severityLevels[number]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_level: SeverityLevel\n $exception_source?: string\n $exception_lineno?: number\n $exception_colno?: number\n $exception_DOMException_code?: string\n $exception_is_synthetic?: boolean\n $exception_stack_trace_raw?: string\n $exception_handled?: boolean\n $exception_personURL?: string\n}\n\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n","import { includes } from '.'\nimport { knownUnsafeEditableEvent, KnownUnsafeEditableEvent } from '../types'\n\n// eslint-disable-next-line posthog-js/no-direct-array-check\nconst nativeIsArray = Array.isArray\nconst ObjProto = Object.prototype\nexport const hasOwnProperty = ObjProto.hasOwnProperty\nconst toString = ObjProto.toString\n\nexport const isArray =\n nativeIsArray ||\n function (obj: any): obj is any[] {\n return toString.call(obj) === '[object Array]'\n }\n\n// from a comment on http://dbj.org/dbj/?p=286\n// fails on only one very rare and deliberate custom object:\n// let bomb = { toString : undefined, valueOf: function(o) { return \"function BOMBA!\"; }};\nexport const isFunction = (x: unknown): x is (...args: any[]) => any => {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof x === 'function'\n}\n\nexport const isNativeFunction = (x: unknown): x is (...args: any[]) => any =>\n isFunction(x) && x.toString().indexOf('[native code]') !== -1\n\n// When angular patches functions they pass the above `isNativeFunction` check\nexport const isAngularZonePatchedFunction = (x: unknown): boolean => {\n if (!isFunction(x)) {\n return false\n }\n const prototypeKeys = Object.getOwnPropertyNames(x.prototype || {})\n return prototypeKeys.some((key) => key.indexOf('__zone'))\n}\n\n// Underscore Addons\nexport const isObject = (x: unknown): x is Record<string, any> => {\n // eslint-disable-next-line posthog-js/no-direct-object-check\n return x === Object(x) && !isArray(x)\n}\nexport const isEmptyObject = (x: unknown): x is Record<string, any> => {\n if (isObject(x)) {\n for (const key in x) {\n if (hasOwnProperty.call(x, key)) {\n return false\n }\n }\n return true\n }\n return false\n}\nexport const isUndefined = (x: unknown): x is undefined => x === void 0\n\nexport const isString = (x: unknown): x is string => {\n // eslint-disable-next-line posthog-js/no-direct-string-check\n return toString.call(x) == '[object String]'\n}\n\nexport const isEmptyString = (x: unknown): boolean => isString(x) && x.trim().length === 0\n\nexport const isNull = (x: unknown): x is null => {\n // eslint-disable-next-line posthog-js/no-direct-null-check\n return x === null\n}\n\n/*\n sometimes you want to check if something is null or undefined\n that's what this is for\n */\nexport const isNullish = (x: unknown): x is null | undefined => isUndefined(x) || isNull(x)\n\nexport const isNumber = (x: unknown): x is number => {\n // eslint-disable-next-line posthog-js/no-direct-number-check\n return toString.call(x) == '[object Number]'\n}\nexport const isBoolean = (x: unknown): x is boolean => {\n // eslint-disable-next-line posthog-js/no-direct-boolean-check\n return toString.call(x) === '[object Boolean]'\n}\n\nexport const isDocument = (x: unknown): x is Document => {\n // eslint-disable-next-line posthog-js/no-direct-document-check\n return x instanceof Document\n}\n\nexport const isFormData = (x: unknown): x is FormData => {\n // eslint-disable-next-line posthog-js/no-direct-form-data-check\n return x instanceof FormData\n}\n\nexport const isFile = (x: unknown): x is File => {\n // eslint-disable-next-line posthog-js/no-direct-file-check\n return x instanceof File\n}\n\nexport const isKnownUnsafeEditableEvent = (x: unknown): x is KnownUnsafeEditableEvent => {\n return includes(knownUnsafeEditableEvent as unknown as string[], x)\n}\n","import { isFunction, isNull, isObject, isUndefined } from '../../utils/type-utils'\n\nexport function isEvent(candidate: unknown): candidate is Event {\n return !isUndefined(Event) && isInstanceOf(candidate, Event)\n}\n\nexport function isPlainObject(candidate: unknown): candidate is Record<string, unknown> {\n return isBuiltin(candidate, 'Object')\n}\n\nexport function isInstanceOf(candidate: unknown, base: any): boolean {\n try {\n return candidate instanceof base\n } catch {\n return false\n }\n}\n\nexport function isPrimitive(\n candidate: unknown\n): candidate is number | string | boolean | bigint | symbol | null | undefined {\n return isNull(candidate) || (!isObject(candidate) && !isFunction(candidate))\n}\n\nexport function isError(candidate: unknown): candidate is Error {\n switch (Object.prototype.toString.call(candidate)) {\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n return true\n default:\n return isInstanceOf(candidate, Error)\n }\n}\n\nexport function isErrorEvent(event: string | Error | Event): event is ErrorEvent {\n return isBuiltin(event, 'ErrorEvent')\n}\n\nexport function isErrorWithStack(candidate: unknown): candidate is Error {\n return 'stack' in (candidate as Error)\n}\n\nexport function isBuiltin(candidate: unknown, className: string): boolean {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`\n}\n\nexport function isDOMException(candidate: unknown): boolean {\n return isBuiltin(candidate, 'DOMException')\n}\n\nexport function isDOMError(candidate: unknown): boolean {\n return isBuiltin(candidate, 'DOMError')\n}\n","// copied and adapted from https://github.com/getsentry/sentry-javascript/blob/41fef4b10f3a644179b77985f00f8696c908539f/packages/browser/src/stack-parsers.ts\n// 💖open source\n\n// This was originally forked from https://github.com/csnover/TraceKit, and was largely\n// re-written as part of raven - js.\n//\n// This code was later copied to the JavaScript mono - repo and further modified and\n// refactored over the years.\n\n// Copyright (c) 2013 Onur Can Cakmak onur.cakmak@gmail.com and all TraceKit contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this\n// software and associated documentation files(the 'Software'), to deal in the Software\n// without restriction, including without limitation the rights to use, copy, modify,\n// merge, publish, distribute, sublicense, and / or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following\n// conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies\n// or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\n// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nimport { isUndefined } from '../../utils/type-utils'\n\nexport type StackParser = (stack: string, skipFirstLines?: number) => StackFrame[]\nexport type StackLineParserFn = (line: string) => StackFrame | undefined\nexport type StackLineParser = [number, StackLineParserFn]\n\nexport interface StackFrame {\n platform: string\n filename?: string\n function?: string\n module?: string\n lineno?: number\n colno?: number\n abs_path?: string\n context_line?: string\n pre_context?: string[]\n post_context?: string[]\n in_app?: boolean\n instruction_addr?: string\n addr_mode?: string\n vars?: { [key: string]: any }\n debug_id?: string\n}\n\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/\nconst STACKTRACE_FRAME_LIMIT = 50\n\nconst UNKNOWN_FUNCTION = '?'\n\nconst OPERA10_PRIORITY = 10\nconst OPERA11_PRIORITY = 20\nconst CHROME_PRIORITY = 30\nconst WINJS_PRIORITY = 40\nconst GECKO_PRIORITY = 50\n\nfunction createFrame(filename: string, func: string, lineno?: number, colno?: number): StackFrame {\n const frame: StackFrame = {\n platform: 'javascript',\n filename,\n function: func === '<anonymous>' ? UNKNOWN_FUNCTION : func,\n in_app: true, // All browser frames are considered in_app\n }\n\n if (!isUndefined(lineno)) {\n frame.lineno = lineno\n }\n\n if (!isUndefined(colno)) {\n frame.colno = colno\n }\n\n return frame\n}\n\n// This regex matches frames that have no function name (ie. are at the top level of a module).\n// For example \"at http://localhost:5000//script.js:1:126\"\n// Frames _with_ function names usually look as follows: \"at commitLayoutEffects (react-dom.development.js:23426:1)\"\nconst chromeRegexNoFnName = /^\\s*at (\\S+?)(?::(\\d+))(?::(\\d+))\\s*$/i\n\n// This regex matches all the frames that have a function name.\nconst chromeRegex =\n /^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i\n\nconst chromeEvalRegex = /\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/\n\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\n// We cannot call this variable `chrome` because it can conflict with global `chrome` variable in certain environments\n// See: https://github.com/getsentry/sentry-javascript/issues/6880\nconst chromeStackParserFn: StackLineParserFn = (line) => {\n // If the stack line has no function name, we need to parse it differently\n const noFnParts = chromeRegexNoFnName.exec(line) as null | [string, string, string, string]\n\n if (noFnParts) {\n const [, filename, line, col] = noFnParts\n return createFrame(filename, UNKNOWN_FUNCTION, +line, +col)\n }\n\n const parts = chromeRegex.exec(line) as null | [string, string, string, string, string]\n\n if (parts) {\n const isEval = parts[2] && parts[2].indexOf('eval') === 0 // start of line\n\n if (isEval) {\n const subMatch = chromeEvalRegex.exec(parts[2]) as null | [string, string, string, string]\n\n if (subMatch) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = subMatch[1] // url\n parts[3] = subMatch[2] // line\n parts[4] = subMatch[3] // column\n }\n }\n\n // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now\n // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)\n const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2])\n\n return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined)\n }\n\n return\n}\n\nexport const chromeStackLineParser: StackLineParser = [CHROME_PRIORITY, chromeStackParserFn]\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\nconst geckoREgex =\n /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i\nconst geckoEvalRegex = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i\n\nconst gecko: StackLineParserFn = (line) => {\n const parts = geckoREgex.exec(line) as null | [string, string, string, string, string, string]\n\n if (parts) {\n const isEval = parts[3] && parts[3].indexOf(' > eval') > -1\n if (isEval) {\n const subMatch = geckoEvalRegex.exec(parts[3]) as null | [string, string, string]\n\n if (subMatch) {\n // throw out eval line/column and use top-most line number\n parts[1] = parts[1] || 'eval'\n parts[3] = subMatch[1]\n parts[4] = subMatch[2]\n parts[5] = '' // no column when eval\n }\n }\n\n let filename = parts[3]\n let func = parts[1] || UNKNOWN_FUNCTION\n ;[func, filename] = extractSafariExtensionDetails(func, filename)\n\n return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined)\n }\n\n return\n}\n\nexport const geckoStackLineParser: StackLineParser = [GECKO_PRIORITY, gecko]\n\nconst winjsRegex = /^\\s*at (?:((?:\\[object object\\])?.+) )?\\(?((?:[-a-z]+):.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/i\n\nconst winjs: StackLineParserFn = (line) => {\n const parts = winjsRegex.exec(line) as null | [string, string, string, string, string]\n\n return parts\n ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)\n : undefined\n}\n\nexport const winjsStackLineParser: StackLineParser = [WINJS_PRIORITY, winjs]\n\nconst opera10Regex = / line (\\d+).*script (?:in )?(\\S+)(?:: in function (\\S+))?$/i\n\nconst opera10: StackLineParserFn = (line) => {\n const parts = opera10Regex.exec(line) as null | [string, string, string, string]\n return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined\n}\n\nexport const opera10StackLineParser: StackLineParser = [OPERA10_PRIORITY, opera10]\n\nconst opera11Regex = / line (\\d+), column (\\d+)\\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\\(.*\\))? in (.*):\\s*$/i\n\nconst opera11: StackLineParserFn = (line) => {\n const parts = opera11Regex.exec(line) as null | [string, string, string, string, string, string]\n return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined\n}\n\nexport const opera11StackLineParser: StackLineParser = [OPERA11_PRIORITY, opera11]\n\nexport const defaultStackLineParsers = [chromeStackLineParser, geckoStackLineParser]\n\nexport const defaultStackParser = createStackParser(...defaultStackLineParsers)\n\nexport function reverseAndStripFrames(stack: ReadonlyArray<StackFrame>): StackFrame[] {\n if (!stack.length) {\n return []\n }\n\n const localStack = Array.from(stack)\n\n localStack.reverse()\n\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}\n\nfunction getLastStackFrame(arr: StackFrame[]): StackFrame {\n return arr[arr.length - 1] || {}\n}\n\nexport function createStackParser(...parsers: StackLineParser[]): StackParser {\n const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map((p) => p[1])\n\n return (stack: string, skipFirstLines: number = 0): StackFrame[] => {\n const frames: StackFrame[] = []\n const lines = stack.split('\\n')\n\n for (let i = skipFirstLines; i < lines.length; i++) {\n const line = lines[i] as string\n // Ignore lines over 1kb as they are unlikely to be stack frames.\n // Many of the regular expressions use backtracking which results in run time that increases exponentially with\n // input size. Huge strings can result in hangs/Denial of Service:\n // https://github.com/getsentry/sentry-javascript/issues/2286\n if (line.length > 1024) {\n continue\n }\n\n // https://github.com/getsentry/sentry-javascript/issues/5459\n // Remove webpack (error: *) wrappers\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line\n\n // https://github.com/getsentry/sentry-javascript/issues/7813\n // Skip Error: lines\n if (cleanedLine.match(/\\S*Error: /)) {\n continue\n }\n\n for (const parser of sortedParsers) {\n const frame = parser(cleanedLine)\n\n if (frame) {\n frames.push(frame)\n break\n }\n }\n\n if (frames.length >= STACKTRACE_FRAME_LIMIT) {\n break\n }\n }\n\n return reverseAndStripFrames(frames)\n }\n}\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (func: string, filename: string): [string, string] => {\n const isSafariExtension = func.indexOf('safari-extension') !== -1\n const isSafariWebExtension = func.indexOf('safari-web-extension') !== -1\n\n return isSafariExtension || isSafariWebExtension\n ? [\n func.indexOf('@') !== -1 ? (func.split('@')[0] as string) : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`,\n ]\n : [func, filename]\n}\n","import {\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isErrorWithStack,\n isEvent,\n isPlainObject,\n isPrimitive,\n} from './type-checking'\nimport { defaultStackParser, StackFrame } from './stack-trace'\n\nimport { isEmptyString, isString, isUndefined } from '../../utils/type-utils'\nimport { ErrorEventArgs, ErrorMetadata, SeverityLevel, severityLevels } from '../../types'\n\nexport interface ErrorProperties {\n $exception_list: Exception[]\n $exception_level?: SeverityLevel\n $exception_DOMException_code?: string\n $exception_personURL?: string\n}\n\nexport interface Exception {\n type?: string\n value?: string\n mechanism?: {\n /**\n * In theory, whether or not the exception has been handled by the user. In practice, whether or not we see it before\n * it hits the global error/rejection handlers, whether through explicit handling by the user or auto instrumentation.\n */\n handled?: boolean\n type?: string\n source?: string\n /**\n * True when `captureException` is called with anything other than an instance of `Error` (or, in the case of browser,\n * an instance of `ErrorEvent`, `DOMError`, or `DOMException`). causing us to create a synthetic error in an attempt\n * to recreate the stacktrace.\n */\n synthetic?: boolean\n }\n module?: string\n thread_id?: number\n stacktrace?: {\n frames?: StackFrame[]\n type: 'raw'\n }\n}\n\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs, metadata?: ErrorMetadata) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n/**\n * based on the very wonderful MIT licensed Sentry SDK\n */\n\nconst ERROR_TYPES_PATTERN =\n /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i\n\nexport function parseStackFrames(ex: Error & { stacktrace?: string }, framesToPop: number = 0): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || ''\n\n const skipLines = getSkipFirstStackStringLines(ex)\n\n try {\n const frames = defaultStackParser(stacktrace, skipLines)\n // frames are reversed so we remove the from the back of the array\n return frames.slice(0, frames.length - framesToPop)\n } catch {\n // no-empty\n }\n\n return []\n}\n\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i\n\n/**\n * Certain known React errors contain links that would be falsely\n * parsed as frames. This function check for these errors and\n * returns number of the stack string lines to skip.\n */\nfunction getSkipFirstStackStringLines(ex: Error): number {\n if (ex && reactMinifiedRegexp.test(ex.message)) {\n return 1\n }\n\n return 0\n}\n\nfunction errorPropertiesFromError(error: Error, metadata?: ErrorMetadata): ErrorProperties {\n const frames = parseStackFrames(error)\n\n const handled = metadata?.handled ?? true\n const synthetic = metadata?.synthetic ?? false\n\n const exceptionType = metadata?.overrideExceptionType ? metadata.overrideExceptionType : error.name\n const exceptionMessage = metadata?.overrideExceptionMessage\n ? metadata.overrideExceptionMessage\n : extractMessage(error)\n\n return {\n $exception_list: [\n {\n type: exceptionType,\n value: exceptionMessage,\n stacktrace: {\n frames,\n type: 'raw',\n },\n mechanism: {\n handled,\n synthetic,\n },\n },\n ],\n $exception_level: 'error',\n }\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nexport function extractMessage(err: Error & { message: { error?: Error } }): string {\n const message = err.message\n\n if (message.error && typeof message.error.message === 'string') {\n return message.error.message\n }\n\n return message\n}\n\nfunction errorPropertiesFromString(candidate: string, metadata?: ErrorMetadata): ErrorProperties {\n // Defaults for metadata are based on what the error candidate is.\n const handled = metadata?.handled ?? true\n const synthetic = metadata?.synthetic ?? true\n\n const exceptionType = metadata?.overrideExceptionType\n ? metadata.overrideExceptionType\n : metadata?.defaultExceptionType ?? 'Error'\n const exceptionMessage = metadata?.overrideExceptionMessage\n ? metadata.overrideExceptionMessage\n : candidate\n ? candidate\n : metadata?.defaultExceptionMessage\n\n const exception: Exception = {\n type: exceptionType,\n value: exceptionMessage,\n mechanism: {\n handled,\n synthetic,\n },\n }\n\n if (metadata?.syntheticException) {\n // Kludge: strip the last frame from a synthetically created error\n // so that it does not appear in a users stack trace\n const frames = parseStackFrames(metadata.syntheticException, 1)\n if (frames.length) {\n exception.stacktrace = { frames, type: 'raw' }\n }\n }\n\n return {\n $exception_list: [exception],\n $exception_level: 'error',\n }\n}\n\n/**\n * Given any captured exception, extract its keys and create a sorted\n * and truncated list that will be used inside the event message.\n * eg. `Non-error exception captured with keys: foo, bar, baz`\n */\nfunction extractExceptionKeysForMessage(exception: Record<string, unknown>, maxLength = 40): string {\n const keys = Object.keys(exception)\n keys.sort()\n\n if (!keys.length) {\n return '[object has no keys]'\n }\n\n for (let i = keys.length; i > 0; i--) {\n const serialized = keys.slice(0, i).join(', ')\n if (serialized.length > maxLength) {\n continue\n }\n if (i === keys.length) {\n return serialized\n }\n return serialized.length <= maxLength ? serialized : `${serialized.slice(0, maxLength)}...`\n }\n\n return ''\n}\n\nfunction isSeverityLevel(x: unknown): x is SeverityLevel {\n return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x as SeverityLevel) >= 0\n}\n\nfunction errorPropertiesFromObject(candidate: Record<string, unknown>, metadata?: ErrorMetadata): ErrorProperties {\n // Defaults for metadata are based on what the error candidate is.\n const handled = metadata?.handled ?? true\n const synthetic = metadata?.synthetic ?? true\n\n const exceptionType = metadata?.overrideExceptionType\n ? metadata.overrideExceptionType\n : isEvent(candidate)\n ? candidate.constructor.name\n : 'Error'\n const exceptionMessage = metadata?.overrideExceptionMessage\n ? metadata.overrideExceptionMessage\n : `Non-Error ${'exception'} captured with keys: ${extractExceptionKeysForMessage(candidate)}`\n\n const exception: Exception = {\n type: exceptionType,\n value: exceptionMessage,\n mechanism: {\n handled,\n synthetic,\n },\n }\n\n if (metadata?.syntheticException) {\n // Kludge: strip the last frame from a synthetically created error\n // so that it does not appear in a users stack trace\n const frames = parseStackFrames(metadata?.syntheticException, 1)\n if (frames.length) {\n exception.stacktrace = { frames, type: 'raw' }\n }\n }\n\n return {\n $exception_list: [exception],\n $exception_level: isSeverityLevel(candidate.level) ? candidate.level : 'error',\n }\n}\n\nexport function errorToProperties(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n [event, _, __, ___, error]: ErrorEventArgs,\n metadata?: ErrorMetadata\n): ErrorProperties {\n let errorProperties: ErrorProperties = { $exception_list: [] }\n\n const candidate = error || event\n\n if (isDOMError(candidate) || isDOMException(candidate)) {\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n\n const domException = candidate as unknown as DOMException\n\n if (isErrorWithStack(candidate)) {\n errorProperties = errorPropertiesFromError(candidate as Error, metadata)\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException')\n const message = domException.message ? `${name}: ${domException.message}` : name\n const exceptionType = isDOMError(domException) ? 'DOMError' : 'DOMException'\n errorProperties = errorPropertiesFromString(message, {\n ...metadata,\n overrideExceptionType: exceptionType,\n defaultExceptionMessage: message,\n })\n }\n if ('code' in domException) {\n errorProperties['$exception_DOMException_code'] = `${domException.code}`\n }\n return errorProperties\n } else if (isErrorEvent(candidate as ErrorEvent) && (candidate as ErrorEvent).error) {\n return errorPropertiesFromError((candidate as ErrorEvent).error as Error, metadata)\n } else if (isError(candidate)) {\n return errorPropertiesFromError(candidate, metadata)\n } else if (isPlainObject(candidate) || isEvent(candidate)) {\n // group these by using the keys available on the object\n const objectException = candidate as Record<string, unknown>\n return errorPropertiesFromObject(objectException, metadata)\n } else if (isUndefined(error) && isString(event)) {\n let name = 'Error'\n let message = event\n const groups = event.match(ERROR_TYPES_PATTERN)\n if (groups) {\n name = groups[1]\n message = groups[2]\n }\n\n return errorPropertiesFromString(message, {\n ...metadata,\n overrideExceptionType: name,\n defaultExceptionMessage: message,\n })\n } else {\n return errorPropertiesFromString(candidate as string, metadata)\n }\n}\n\nexport function unhandledRejectionToProperties([ev]: [ev: PromiseRejectionEvent]): ErrorProperties {\n const error = getUnhandledRejectionError(ev)\n\n if (isPrimitive(error)) {\n return errorPropertiesFromString(`Non-Error promise rejection captured with value: ${String(error)}`, {\n handled: false,\n synthetic: false,\n overrideExceptionType: 'UnhandledRejection',\n })\n }\n\n return errorToProperties([error as string | Event], {\n handled: false,\n overrideExceptionType: 'UnhandledRejection',\n defaultExceptionMessage: String(error),\n })\n}\n\nfunction getUnhandledRejectionError(error: unknown): unknown {\n if (isPrimitive(error)) {\n return error\n }\n\n // dig the object of the rejection out of known event types\n try {\n type ErrorWithReason = { reason: unknown }\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in (error as ErrorWithReason)) {\n return (error as ErrorWithReason).reason\n }\n\n type CustomEventWithDetail = { detail: { reason: unknown } }\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n if ('detail' in (error as CustomEventWithDetail) && 'reason' in (error as CustomEventWithDetail).detail) {\n return (error as CustomEventWithDetail).detail.reason\n }\n } catch {\n // no-empty\n }\n\n return error\n}\n","import { errorToProperties, unhandledRejectionToProperties } from '../extensions/exception-autocapture/error-conversion'\nimport { assignableWindow, window } from '../utils/globals'\nimport { ErrorEventArgs, Properties } from '../types'\nimport { logger } from '../utils/logger'\n\nconst wrapOnError = (captureFn: (props: Properties) => 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(args)\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: Properties) => 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 (...args: [ev: PromiseRejectionEvent]): boolean {\n const errorProperties = unhandledRejectionToProperties(args)\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, args) ?? 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 posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n}\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.errorWrappingFunctions = posthogErrorWrappingFunctions\nassignableWindow.__PosthogExtensions__.parseErrorAsProperties = errorToProperties\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\nassignableWindow.parseErrorAsProperties = errorToProperties\n\nexport default posthogErrorWrappingFunctions\n"],"names":["win","window","undefined","global","globalThis","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","LOGGER_PREFIX","logger","_log","level","isUndefined","console","consoleLog","_len","arguments","length","args","Array","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","Compression","severityLevels","nativeIsArray","isArray","toString","Object","prototype","obj","call","isFunction","x","isObject","isString","isEmptyString","trim","isNull","isEvent","candidate","Event","isInstanceOf","base","isPrimitive","isBuiltin","className","isDOMError","WEBPACK_ERROR_REGEXP","STACKTRACE_FRAME_LIMIT","UNKNOWN_FUNCTION","createFrame","filename","func","lineno","colno","frame","platform","function","in_app","chromeRegexNoFnName","chromeRegex","chromeEvalRegex","geckoREgex","geckoEvalRegex","defaultStackParser","parsers","sortedParsers","sort","a","b","map","p","stack","skipFirstLines","frames","lines","split","i","line","cleanedLine","test","replace","match","parser","push","localStack","from","reverse","slice","getLastStackFrame","reverseAndStripFrames","createStackParser","noFnParts","exec","col","parts","indexOf","subMatch","extractSafariExtensionDetails","arr","isSafariExtension","isSafariWebExtension","ERROR_TYPES_PATTERN","parseStackFrames","ex","framesToPop","stacktrace","skipLines","reactMinifiedRegexp","message","getSkipFirstStackStringLines","errorPropertiesFromError","metadata","_metadata$handled","_metadata$synthetic","handled","synthetic","$exception_list","type","overrideExceptionType","name","value","overrideExceptionMessage","err","extractMessage","mechanism","$exception_level","errorPropertiesFromString","_metadata$handled2","_metadata$synthetic2","_metadata$defaultExce","exception","defaultExceptionType","defaultExceptionMessage","syntheticException","errorPropertiesFromObject","_metadata$handled3","_metadata$synthetic3","exceptionType","constructor","exceptionMessage","maxLength","keys","serialized","join","extractExceptionKeysForMessage","errorToProperties","_ref","event","_","__","___","errorProperties","isDOMException","domException","isErrorWithStack","code","isErrorEvent","Error","isError","isPlainObject","groups","unhandledRejectionToProperties","_ref2","ev","reason","detail","getUnhandledRejectionError","String","posthogErrorWrappingFunctions","wrapOnError","captureFn","originalOnError","onerror","_originalOnError","__POSTHOG_INSTRUMENTED__","_win$onerror","wrapUnhandledRejection","originalOnUnhandledRejection","onunhandledrejection","_originalOnUnhandledR","apply","_win$onunhandledrejec","__PosthogExtensions__","errorWrappingFunctions","parseErrorAsProperties"],"mappings":"yBAgBA,MAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAgEzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAMlFK,EAAYF,aAAM,EAANA,EAAQE,UACTF,SAAAA,EAAQG,SACRH,SAAAA,EAAQI,SACXJ,SAAAA,EAAQK,MAEzBL,SAAAA,EAAQM,gBAAkB,oBAAqB,IAAIN,EAAOM,gBAAmBN,EAAOM,eACzDN,SAAAA,EAAQO,gBACdL,SAAAA,EAAWM,UAC7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AAA,GAEzDtM,EAAIqM,qBAAqBJ,0BAA2B,EAE7C,KAAM,IAAAO,EACsBA,QAA/BA,EAAOxM,EAAIqM,4BAAX,IAA+BG,UAAxBA,EAA0BP,yBACjCjM,EAAIqM,qBAAuBD,CAA4B,CAC1D,GAQLxL,EAAiB6L,sBAAwB7L,EAAiB6L,uBAAyB,GACnF7L,EAAiB6L,sBAAsBC,uBAAyBf,EAChE/K,EAAiB6L,sBAAsBE,uBAAyBvC,EAOhExJ,EAAiB+K,8BAAgCA,EACjD/K,EAAiB+L,uBAAyBvC"}
1
+ {"version":3,"file":"exception-autocapture.js","sources":["../src/utils/globals.ts","../src/types.ts","../src/utils/logger.ts","../src/utils/type-utils.ts","../src/extensions/exception-autocapture/type-checking.ts","../src/extensions/exception-autocapture/stack-trace.ts","../src/extensions/exception-autocapture/error-conversion.ts","../src/entrypoints/exception-autocapture.ts"],"sourcesContent":["import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion'\nimport type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport { DeadClicksAutoCaptureConfig, ErrorEventArgs, ErrorMetadata, Properties } from '../types'\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 Record<string, any> & {\n __PosthogExtensions__?: PostHogExtensions\n }\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 PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'dead-clicks-autocapture'\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 parseErrorAsProperties?: (\n [event, source, lineno, colno, error]: ErrorEventArgs,\n metadata?: ErrorMetadata\n ) => ErrorProperties\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: Properties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: Properties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n canActivateRepeatedly?: (survey: any) => boolean\n generateSurveys?: (posthog: PostHog) => 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: (sessionManager: SessionIdManager) => () => void\n _patchXHR: (sessionManager: any) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\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 { PostHog } from './posthog-core'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { recordOptions } from './extensions/replay/sessionrecording-utils'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\nexport const knownUnsafeEditableEvent = [\n '$snapshot',\n '$pageview',\n '$pageleave',\n '$set',\n 'survey dismissed',\n 'survey sent',\n 'survey shown',\n '$identify',\n '$groupidentify',\n '$create_alias',\n '$$client_ingestion_warning',\n '$web_experiment_applied',\n '$feature_enrollment_update',\n '$feature_flag_called',\n] as const\n\n/**\n * These events can be processed by the `beforeCapture` function\n * but can cause unexpected confusion in data.\n *\n * Some features of PostHog rely on receiving 100% of these events\n */\nexport type KnownUnsafeEditableEvent = typeof knownUnsafeEditableEvent[number]\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * if the allowlist has button then we allow the capture when the button or the svg is the click target\n * but not if either of the divs are detected as the click target\n */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * and allow list config `['[id]']`\n * we will capture the click if the click-target or its parents has any id\n */\n css_selector_allowlist?: string[]\n\n /**\n * Exclude certain element attributes from autocapture\n * E.g. ['aria-label'] or [data-attr-pii]\n */\n element_attribute_ignorelist?: string[]\n\n capture_copied_text?: boolean\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\n\nexport interface PerformanceCaptureConfig {\n /** works with session replay to use the browser's native performance observer to capture performance metrics */\n network_timing?: boolean\n /** use chrome's web vitals library to wrap fetch and capture web vitals */\n web_vitals?: boolean\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n * if not set this defaults to 15 minutes\n */\n __web_vitals_max_value?: number\n /**\n * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n /**\n * we delay flushing web vitals metrics to reduce the number of events we send\n * this is the maximum time we will wait before sending the metrics\n * if not set it defaults to 5 seconds\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n // by default if a click is followed by a sroll within 100ms it is not a dead click\n scroll_threshold_ms?: number\n // by default if a click is followed by a selection change within 100ms it is not a dead click\n selection_change_threshold_ms?: number\n // by default if a click is followed by a mutation within 2500ms it is not a dead click\n mutation_threshold_ms?: number\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by the SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\n\nexport interface HeatmapConfig {\n /*\n * how often to send batched data in $$heatmap_data events\n * if set to 0 or not set, sends using the default interval of 1 second\n * */\n flush_interval_milliseconds: number\n}\n\nexport type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\n\nexport interface PostHogConfig {\n api_host: string\n /** @deprecated - This property is no longer supported */\n api_method?: string\n api_transport?: 'XHR' | 'fetch'\n ui_host: string | null\n token: string\n autocapture: boolean | AutocaptureConfig\n rageclick: boolean\n cross_subdomain_cookie: boolean\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n persistence_name: string\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n loaded: (posthog_instance: PostHog) => void\n store_google: boolean\n custom_campaign_params: string[]\n // a list of strings to be tested against navigator.userAgent to determine if the source is a bot\n // this is **added to** the default list of bots that we check\n // defaults to the empty array\n custom_blocked_useragents: string[]\n save_referrer: boolean\n verbose: boolean\n capture_pageview: boolean\n capture_pageleave: boolean | 'if_capture_pageview'\n debug: boolean\n cookie_expiration: number\n upgrade: boolean\n disable_session_recording: boolean\n disable_persistence: boolean\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n disable_surveys: boolean\n disable_web_experiments: boolean\n /** If set, posthog-js will never load external scripts such as those needed for Session Replay or Surveys. */\n disable_external_dependency_loading?: boolean\n enable_recording_console_log?: boolean\n secure_cookie: boolean\n ip: boolean\n /** Starts the SDK in an opted out state requiring opt_in_capturing() to be called before events will b captured */\n opt_out_capturing_by_default: boolean\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n /** If set to true this will disable persistence if the user is opted out of capturing. @default false */\n opt_out_persistence_by_default?: boolean\n /** Opt out of user agent filtering such as googlebot or other bots. Defaults to `false` */\n opt_out_useragent_filter: boolean\n\n opt_out_capturing_cookie_prefix: string | null\n opt_in_site_apps: boolean\n respect_dnt: boolean\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n property_denylist: string[]\n request_headers: { [header_name: string]: string }\n on_request_error?: (error: RequestResponse) => void\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n inapp_protocol: string\n inapp_link_new_window: boolean\n request_batching: boolean\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n properties_string_max_length: number\n session_recording: SessionRecordingOptions\n session_idle_timeout_seconds: number\n mask_all_element_attributes: boolean\n mask_all_text: boolean\n advanced_disable_decide: boolean\n advanced_disable_feature_flags: boolean\n advanced_disable_feature_flags_on_first_load: boolean\n advanced_disable_toolbar_metrics: boolean\n feature_flag_request_timeout_ms: number\n get_device_id: (uuid: string) => string\n name: string\n /**\n * this is a read-only function that can be used to react to event capture\n * @deprecated - use `before_send` instead - NB before_send is not read only\n */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\n capture_performance?: boolean | PerformanceCaptureConfig\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: BootstrapConfig\n segment?: SegmentAnalytics\n __preview_send_client_session_params?: boolean\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n capture_heatmaps?: boolean | HeatmapConfig\n capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\n disable_scroll_properties?: boolean\n // Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n scroll_root_selector?: string | string[]\n\n /** You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting. There are three options:\n * - `person_profiles: 'always'` _(default)_ - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` - we will only process persons when you call `posthog.identify`, `posthog.alias`, `posthog.setPersonProperties`, `posthog.group`, `posthog.setPersonPropertiesForFlags` or `posthog.setGroupPropertiesForFlags` Anonymous users won't get person profiles.\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /** Client side rate limiting */\n rate_limiting?: {\n /** The average number of events per second that should be permitted (defaults to 10) */\n events_per_second?: number\n /** How many events can be captured in a burst. This defaults to 10 times the events_per_second count */\n events_burst_limit?: number\n }\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * whether to wrap fetch and add tracing headers to the request\n * */\n __add_tracing_headers?: boolean\n}\n\nexport interface OptInOutCapturingOptions {\n capture: (event: string, properties: Properties, options: CaptureOptions) => void\n capture_event_name: string\n capture_properties: Properties\n enable_persistence: boolean\n clear_persistence: boolean\n persistence_type: 'cookie' | 'localStorage' | 'localStorage+cookie'\n cookie_prefix: string\n cookie_expiration: number\n cross_subdomain_cookie: boolean\n secure_cookie: boolean\n}\n\nexport interface IsFeatureEnabledOptions {\n send_event: boolean\n}\n\nexport interface SessionRecordingOptions {\n blockClass?: string | RegExp\n blockSelector?: string | null\n ignoreClass?: string\n maskTextClass?: string | RegExp\n maskTextSelector?: string | null\n maskTextFn?: ((text: string, element: HTMLElement | null) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: recordOptions['maskInputOptions']\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: recordOptions['slimDOMOptions']\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /**\n * Allows local config to override remote canvas recording settings from the decide response\n */\n captureCanvas?: SessionRecordingCanvasOptions\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // our settings here only support a subset of those proposed for rrweb's network capture plugin\n recordHeaders?: boolean\n recordBody?: boolean\n // ADVANCED: while a user is active we take a full snapshot of the browser every interval. For very few sites playback performance might be better with different interval. Set to 0 to disable\n full_snapshot_interval_millis?: number\n /*\n ADVANCED: whether to partially compress rrweb events before sending them to the server,\n defaults to true, can be set to false to disable partial compression\n NB requests are still compressed when sent to the server regardless of this setting\n */\n compress_events?: boolean\n /*\n ADVANCED: alters the threshold before a recording considers a user has become idle.\n Normally only altered alongside changes to session_idle_timeout_ms.\n Default is 5 minutes.\n */\n session_idle_threshold_ms?: number\n /*\n ADVANCED: alters the refill rate for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 10.\n */\n __mutationRateLimiterRefillRate?: number\n /*\n ADVANCED: alters the bucket size for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 100.\n */\n __mutationRateLimiterBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\nexport interface RequestOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestOptions extends RequestOptions {\n batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestOptions extends QueuedRequestOptions {\n retriesPerformedSoFar?: number\n}\n\nexport interface CaptureOptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _url?: string /** Used to override the desired endpoint for the captured event */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n send_instantly?: boolean /** if set skips the batched queue */\n skip_client_rate_limiting?: boolean /** if set skips the client side rate limiting */\n transport?: RequestOptions['transport'] /** if set, overrides the desired transport method */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport type SessionRecordingCanvasOptions = {\n recordCanvas?: boolean | null\n canvasFps?: number | null\n // the API returns a decimal between 0 and 1 as a string\n canvasQuality?: string | null\n}\n\nexport interface DecideResponse {\n supportedCompression: Compression[]\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n analytics?: {\n endpoint?: string\n }\n elementsChainAsString?: boolean\n // this is currently in development and may have breaking changes without a major version bump\n autocaptureExceptions?:\n | boolean\n | {\n endpoint?: string\n }\n sessionRecording?: SessionRecordingCanvasOptions & {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n heatmaps?: boolean\n defaultIdentifiedOnly?: boolean\n captureDeadClicks?: boolean\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport interface PersistentStore {\n is_supported: () => boolean\n error: (error: any) => void\n parse: (name: string) => any\n get: (name: string) => any\n set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | JsonRecord | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined\n]\n\nexport type ErrorMetadata = {\n handled?: boolean\n synthetic?: boolean\n syntheticException?: Error\n overrideExceptionType?: string\n overrideExceptionMessage?: string\n defaultExceptionType?: string\n defaultExceptionMessage?: string\n}\n\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = typeof severityLevels[number]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_level: SeverityLevel\n $exception_source?: string\n $exception_lineno?: number\n $exception_colno?: number\n $exception_DOMException_code?: string\n $exception_is_synthetic?: boolean\n $exception_stack_trace_raw?: string\n $exception_handled?: boolean\n $exception_personURL?: string\n}\n\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nconst LOGGER_PREFIX = '[PostHog.js]'\nexport const logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG) &&\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(LOGGER_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(LOGGER_PREFIX, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n}\n","import { includes } from '.'\nimport { knownUnsafeEditableEvent, KnownUnsafeEditableEvent } from '../types'\n\n// eslint-disable-next-line posthog-js/no-direct-array-check\nconst nativeIsArray = Array.isArray\nconst ObjProto = Object.prototype\nexport const hasOwnProperty = ObjProto.hasOwnProperty\nconst toString = ObjProto.toString\n\nexport const isArray =\n nativeIsArray ||\n function (obj: any): obj is any[] {\n return toString.call(obj) === '[object Array]'\n }\n\n// from a comment on http://dbj.org/dbj/?p=286\n// fails on only one very rare and deliberate custom object:\n// let bomb = { toString : undefined, valueOf: function(o) { return \"function BOMBA!\"; }};\nexport const isFunction = (x: unknown): x is (...args: any[]) => any => {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof x === 'function'\n}\n\nexport const isNativeFunction = (x: unknown): x is (...args: any[]) => any =>\n isFunction(x) && x.toString().indexOf('[native code]') !== -1\n\n// When angular patches functions they pass the above `isNativeFunction` check\nexport const isAngularZonePatchedFunction = (x: unknown): boolean => {\n if (!isFunction(x)) {\n return false\n }\n const prototypeKeys = Object.getOwnPropertyNames(x.prototype || {})\n return prototypeKeys.some((key) => key.indexOf('__zone'))\n}\n\n// Underscore Addons\nexport const isObject = (x: unknown): x is Record<string, any> => {\n // eslint-disable-next-line posthog-js/no-direct-object-check\n return x === Object(x) && !isArray(x)\n}\nexport const isEmptyObject = (x: unknown): x is Record<string, any> => {\n if (isObject(x)) {\n for (const key in x) {\n if (hasOwnProperty.call(x, key)) {\n return false\n }\n }\n return true\n }\n return false\n}\nexport const isUndefined = (x: unknown): x is undefined => x === void 0\n\nexport const isString = (x: unknown): x is string => {\n // eslint-disable-next-line posthog-js/no-direct-string-check\n return toString.call(x) == '[object String]'\n}\n\nexport const isEmptyString = (x: unknown): boolean => isString(x) && x.trim().length === 0\n\nexport const isNull = (x: unknown): x is null => {\n // eslint-disable-next-line posthog-js/no-direct-null-check\n return x === null\n}\n\n/*\n sometimes you want to check if something is null or undefined\n that's what this is for\n */\nexport const isNullish = (x: unknown): x is null | undefined => isUndefined(x) || isNull(x)\n\nexport const isNumber = (x: unknown): x is number => {\n // eslint-disable-next-line posthog-js/no-direct-number-check\n return toString.call(x) == '[object Number]'\n}\nexport const isBoolean = (x: unknown): x is boolean => {\n // eslint-disable-next-line posthog-js/no-direct-boolean-check\n return toString.call(x) === '[object Boolean]'\n}\n\nexport const isDocument = (x: unknown): x is Document => {\n // eslint-disable-next-line posthog-js/no-direct-document-check\n return x instanceof Document\n}\n\nexport const isFormData = (x: unknown): x is FormData => {\n // eslint-disable-next-line posthog-js/no-direct-form-data-check\n return x instanceof FormData\n}\n\nexport const isFile = (x: unknown): x is File => {\n // eslint-disable-next-line posthog-js/no-direct-file-check\n return x instanceof File\n}\n\nexport const isKnownUnsafeEditableEvent = (x: unknown): x is KnownUnsafeEditableEvent => {\n return includes(knownUnsafeEditableEvent as unknown as string[], x)\n}\n","import { isFunction, isNull, isObject, isUndefined } from '../../utils/type-utils'\n\nexport function isEvent(candidate: unknown): candidate is Event {\n return !isUndefined(Event) && isInstanceOf(candidate, Event)\n}\n\nexport function isPlainObject(candidate: unknown): candidate is Record<string, unknown> {\n return isBuiltin(candidate, 'Object')\n}\n\nexport function isInstanceOf(candidate: unknown, base: any): boolean {\n try {\n return candidate instanceof base\n } catch {\n return false\n }\n}\n\nexport function isPrimitive(\n candidate: unknown\n): candidate is number | string | boolean | bigint | symbol | null | undefined {\n return isNull(candidate) || (!isObject(candidate) && !isFunction(candidate))\n}\n\nexport function isError(candidate: unknown): candidate is Error {\n switch (Object.prototype.toString.call(candidate)) {\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n return true\n default:\n return isInstanceOf(candidate, Error)\n }\n}\n\nexport function isErrorEvent(event: string | Error | Event): event is ErrorEvent {\n return isBuiltin(event, 'ErrorEvent')\n}\n\nexport function isErrorWithStack(candidate: unknown): candidate is Error {\n return 'stack' in (candidate as Error)\n}\n\nexport function isBuiltin(candidate: unknown, className: string): boolean {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`\n}\n\nexport function isDOMException(candidate: unknown): boolean {\n return isBuiltin(candidate, 'DOMException')\n}\n\nexport function isDOMError(candidate: unknown): boolean {\n return isBuiltin(candidate, 'DOMError')\n}\n","// copied and adapted from https://github.com/getsentry/sentry-javascript/blob/41fef4b10f3a644179b77985f00f8696c908539f/packages/browser/src/stack-parsers.ts\n// 💖open source\n\n// This was originally forked from https://github.com/csnover/TraceKit, and was largely\n// re-written as part of raven - js.\n//\n// This code was later copied to the JavaScript mono - repo and further modified and\n// refactored over the years.\n\n// Copyright (c) 2013 Onur Can Cakmak onur.cakmak@gmail.com and all TraceKit contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this\n// software and associated documentation files(the 'Software'), to deal in the Software\n// without restriction, including without limitation the rights to use, copy, modify,\n// merge, publish, distribute, sublicense, and / or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following\n// conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies\n// or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\n// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nimport { isUndefined } from '../../utils/type-utils'\n\nexport type StackParser = (stack: string, skipFirstLines?: number) => StackFrame[]\nexport type StackLineParserFn = (line: string) => StackFrame | undefined\nexport type StackLineParser = [number, StackLineParserFn]\n\nexport interface StackFrame {\n platform: string\n filename?: string\n function?: string\n module?: string\n lineno?: number\n colno?: number\n abs_path?: string\n context_line?: string\n pre_context?: string[]\n post_context?: string[]\n in_app?: boolean\n instruction_addr?: string\n addr_mode?: string\n vars?: { [key: string]: any }\n debug_id?: string\n}\n\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/\nconst STACKTRACE_FRAME_LIMIT = 50\n\nconst UNKNOWN_FUNCTION = '?'\n\nconst OPERA10_PRIORITY = 10\nconst OPERA11_PRIORITY = 20\nconst CHROME_PRIORITY = 30\nconst WINJS_PRIORITY = 40\nconst GECKO_PRIORITY = 50\n\nfunction createFrame(filename: string, func: string, lineno?: number, colno?: number): StackFrame {\n const frame: StackFrame = {\n platform: 'javascript',\n filename,\n function: func === '<anonymous>' ? UNKNOWN_FUNCTION : func,\n in_app: true, // All browser frames are considered in_app\n }\n\n if (!isUndefined(lineno)) {\n frame.lineno = lineno\n }\n\n if (!isUndefined(colno)) {\n frame.colno = colno\n }\n\n return frame\n}\n\n// This regex matches frames that have no function name (ie. are at the top level of a module).\n// For example \"at http://localhost:5000//script.js:1:126\"\n// Frames _with_ function names usually look as follows: \"at commitLayoutEffects (react-dom.development.js:23426:1)\"\nconst chromeRegexNoFnName = /^\\s*at (\\S+?)(?::(\\d+))(?::(\\d+))\\s*$/i\n\n// This regex matches all the frames that have a function name.\nconst chromeRegex =\n /^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i\n\nconst chromeEvalRegex = /\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/\n\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\n// We cannot call this variable `chrome` because it can conflict with global `chrome` variable in certain environments\n// See: https://github.com/getsentry/sentry-javascript/issues/6880\nconst chromeStackParserFn: StackLineParserFn = (line) => {\n // If the stack line has no function name, we need to parse it differently\n const noFnParts = chromeRegexNoFnName.exec(line) as null | [string, string, string, string]\n\n if (noFnParts) {\n const [, filename, line, col] = noFnParts\n return createFrame(filename, UNKNOWN_FUNCTION, +line, +col)\n }\n\n const parts = chromeRegex.exec(line) as null | [string, string, string, string, string]\n\n if (parts) {\n const isEval = parts[2] && parts[2].indexOf('eval') === 0 // start of line\n\n if (isEval) {\n const subMatch = chromeEvalRegex.exec(parts[2]) as null | [string, string, string, string]\n\n if (subMatch) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = subMatch[1] // url\n parts[3] = subMatch[2] // line\n parts[4] = subMatch[3] // column\n }\n }\n\n // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now\n // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)\n const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2])\n\n return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined)\n }\n\n return\n}\n\nexport const chromeStackLineParser: StackLineParser = [CHROME_PRIORITY, chromeStackParserFn]\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\nconst geckoREgex =\n /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i\nconst geckoEvalRegex = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i\n\nconst gecko: StackLineParserFn = (line) => {\n const parts = geckoREgex.exec(line) as null | [string, string, string, string, string, string]\n\n if (parts) {\n const isEval = parts[3] && parts[3].indexOf(' > eval') > -1\n if (isEval) {\n const subMatch = geckoEvalRegex.exec(parts[3]) as null | [string, string, string]\n\n if (subMatch) {\n // throw out eval line/column and use top-most line number\n parts[1] = parts[1] || 'eval'\n parts[3] = subMatch[1]\n parts[4] = subMatch[2]\n parts[5] = '' // no column when eval\n }\n }\n\n let filename = parts[3]\n let func = parts[1] || UNKNOWN_FUNCTION\n ;[func, filename] = extractSafariExtensionDetails(func, filename)\n\n return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined)\n }\n\n return\n}\n\nexport const geckoStackLineParser: StackLineParser = [GECKO_PRIORITY, gecko]\n\nconst winjsRegex = /^\\s*at (?:((?:\\[object object\\])?.+) )?\\(?((?:[-a-z]+):.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/i\n\nconst winjs: StackLineParserFn = (line) => {\n const parts = winjsRegex.exec(line) as null | [string, string, string, string, string]\n\n return parts\n ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)\n : undefined\n}\n\nexport const winjsStackLineParser: StackLineParser = [WINJS_PRIORITY, winjs]\n\nconst opera10Regex = / line (\\d+).*script (?:in )?(\\S+)(?:: in function (\\S+))?$/i\n\nconst opera10: StackLineParserFn = (line) => {\n const parts = opera10Regex.exec(line) as null | [string, string, string, string]\n return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined\n}\n\nexport const opera10StackLineParser: StackLineParser = [OPERA10_PRIORITY, opera10]\n\nconst opera11Regex = / line (\\d+), column (\\d+)\\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\\(.*\\))? in (.*):\\s*$/i\n\nconst opera11: StackLineParserFn = (line) => {\n const parts = opera11Regex.exec(line) as null | [string, string, string, string, string, string]\n return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined\n}\n\nexport const opera11StackLineParser: StackLineParser = [OPERA11_PRIORITY, opera11]\n\nexport const defaultStackLineParsers = [chromeStackLineParser, geckoStackLineParser]\n\nexport const defaultStackParser = createStackParser(...defaultStackLineParsers)\n\nexport function reverseAndStripFrames(stack: ReadonlyArray<StackFrame>): StackFrame[] {\n if (!stack.length) {\n return []\n }\n\n const localStack = Array.from(stack)\n\n localStack.reverse()\n\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}\n\nfunction getLastStackFrame(arr: StackFrame[]): StackFrame {\n return arr[arr.length - 1] || {}\n}\n\nexport function createStackParser(...parsers: StackLineParser[]): StackParser {\n const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map((p) => p[1])\n\n return (stack: string, skipFirstLines: number = 0): StackFrame[] => {\n const frames: StackFrame[] = []\n const lines = stack.split('\\n')\n\n for (let i = skipFirstLines; i < lines.length; i++) {\n const line = lines[i] as string\n // Ignore lines over 1kb as they are unlikely to be stack frames.\n // Many of the regular expressions use backtracking which results in run time that increases exponentially with\n // input size. Huge strings can result in hangs/Denial of Service:\n // https://github.com/getsentry/sentry-javascript/issues/2286\n if (line.length > 1024) {\n continue\n }\n\n // https://github.com/getsentry/sentry-javascript/issues/5459\n // Remove webpack (error: *) wrappers\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line\n\n // https://github.com/getsentry/sentry-javascript/issues/7813\n // Skip Error: lines\n if (cleanedLine.match(/\\S*Error: /)) {\n continue\n }\n\n for (const parser of sortedParsers) {\n const frame = parser(cleanedLine)\n\n if (frame) {\n frames.push(frame)\n break\n }\n }\n\n if (frames.length >= STACKTRACE_FRAME_LIMIT) {\n break\n }\n }\n\n return reverseAndStripFrames(frames)\n }\n}\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (func: string, filename: string): [string, string] => {\n const isSafariExtension = func.indexOf('safari-extension') !== -1\n const isSafariWebExtension = func.indexOf('safari-web-extension') !== -1\n\n return isSafariExtension || isSafariWebExtension\n ? [\n func.indexOf('@') !== -1 ? (func.split('@')[0] as string) : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`,\n ]\n : [func, filename]\n}\n","import {\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isErrorWithStack,\n isEvent,\n isPlainObject,\n isPrimitive,\n} from './type-checking'\nimport { defaultStackParser, StackFrame } from './stack-trace'\n\nimport { isEmptyString, isString, isUndefined } from '../../utils/type-utils'\nimport { ErrorEventArgs, ErrorMetadata, SeverityLevel, severityLevels } from '../../types'\n\nexport interface ErrorProperties {\n $exception_list: Exception[]\n $exception_level?: SeverityLevel\n $exception_DOMException_code?: string\n $exception_personURL?: string\n}\n\nexport interface Exception {\n type?: string\n value?: string\n mechanism?: {\n /**\n * In theory, whether or not the exception has been handled by the user. In practice, whether or not we see it before\n * it hits the global error/rejection handlers, whether through explicit handling by the user or auto instrumentation.\n */\n handled?: boolean\n type?: string\n source?: string\n /**\n * True when `captureException` is called with anything other than an instance of `Error` (or, in the case of browser,\n * an instance of `ErrorEvent`, `DOMError`, or `DOMException`). causing us to create a synthetic error in an attempt\n * to recreate the stacktrace.\n */\n synthetic?: boolean\n }\n module?: string\n thread_id?: number\n stacktrace?: {\n frames?: StackFrame[]\n type: 'raw'\n }\n}\n\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs, metadata?: ErrorMetadata) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n/**\n * based on the very wonderful MIT licensed Sentry SDK\n */\n\nconst ERROR_TYPES_PATTERN =\n /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i\n\nexport function parseStackFrames(ex: Error & { stacktrace?: string }, framesToPop: number = 0): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || ''\n\n const skipLines = getSkipFirstStackStringLines(ex)\n\n try {\n const frames = defaultStackParser(stacktrace, skipLines)\n // frames are reversed so we remove the from the back of the array\n return frames.slice(0, frames.length - framesToPop)\n } catch {\n // no-empty\n }\n\n return []\n}\n\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i\n\n/**\n * Certain known React errors contain links that would be falsely\n * parsed as frames. This function check for these errors and\n * returns number of the stack string lines to skip.\n */\nfunction getSkipFirstStackStringLines(ex: Error): number {\n if (ex && reactMinifiedRegexp.test(ex.message)) {\n return 1\n }\n\n return 0\n}\n\nfunction errorPropertiesFromError(error: Error, metadata?: ErrorMetadata): ErrorProperties {\n const frames = parseStackFrames(error)\n\n const handled = metadata?.handled ?? true\n const synthetic = metadata?.synthetic ?? false\n\n const exceptionType = metadata?.overrideExceptionType ? metadata.overrideExceptionType : error.name\n const exceptionMessage = metadata?.overrideExceptionMessage\n ? metadata.overrideExceptionMessage\n : extractMessage(error)\n\n return {\n $exception_list: [\n {\n type: exceptionType,\n value: exceptionMessage,\n stacktrace: {\n frames,\n type: 'raw',\n },\n mechanism: {\n handled,\n synthetic,\n },\n },\n ],\n $exception_level: 'error',\n }\n}\n\n/**\n * There are cases where stacktrace.message is an Event object\n * https://github.com/getsentry/sentry-javascript/issues/1949\n * In this specific case we try to extract stacktrace.message.error.message\n */\nexport function extractMessage(err: Error & { message: { error?: Error } }): string {\n const message = err.message\n\n if (message.error && typeof message.error.message === 'string') {\n return message.error.message\n }\n\n return message\n}\n\nfunction errorPropertiesFromString(candidate: string, metadata?: ErrorMetadata): ErrorProperties {\n // Defaults for metadata are based on what the error candidate is.\n const handled = metadata?.handled ?? true\n const synthetic = metadata?.synthetic ?? true\n\n const exceptionType = metadata?.overrideExceptionType\n ? metadata.overrideExceptionType\n : metadata?.defaultExceptionType ?? 'Error'\n const exceptionMessage = metadata?.overrideExceptionMessage\n ? metadata.overrideExceptionMessage\n : candidate\n ? candidate\n : metadata?.defaultExceptionMessage\n\n const exception: Exception = {\n type: exceptionType,\n value: exceptionMessage,\n mechanism: {\n handled,\n synthetic,\n },\n }\n\n if (metadata?.syntheticException) {\n // Kludge: strip the last frame from a synthetically created error\n // so that it does not appear in a users stack trace\n const frames = parseStackFrames(metadata.syntheticException, 1)\n if (frames.length) {\n exception.stacktrace = { frames, type: 'raw' }\n }\n }\n\n return {\n $exception_list: [exception],\n $exception_level: 'error',\n }\n}\n\n/**\n * Given any captured exception, extract its keys and create a sorted\n * and truncated list that will be used inside the event message.\n * eg. `Non-error exception captured with keys: foo, bar, baz`\n */\nfunction extractExceptionKeysForMessage(exception: Record<string, unknown>, maxLength = 40): string {\n const keys = Object.keys(exception)\n keys.sort()\n\n if (!keys.length) {\n return '[object has no keys]'\n }\n\n for (let i = keys.length; i > 0; i--) {\n const serialized = keys.slice(0, i).join(', ')\n if (serialized.length > maxLength) {\n continue\n }\n if (i === keys.length) {\n return serialized\n }\n return serialized.length <= maxLength ? serialized : `${serialized.slice(0, maxLength)}...`\n }\n\n return ''\n}\n\nfunction isSeverityLevel(x: unknown): x is SeverityLevel {\n return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x as SeverityLevel) >= 0\n}\n\nfunction errorPropertiesFromObject(candidate: Record<string, unknown>, metadata?: ErrorMetadata): ErrorProperties {\n // Defaults for metadata are based on what the error candidate is.\n const handled = metadata?.handled ?? true\n const synthetic = metadata?.synthetic ?? true\n\n const exceptionType = metadata?.overrideExceptionType\n ? metadata.overrideExceptionType\n : isEvent(candidate)\n ? candidate.constructor.name\n : 'Error'\n const exceptionMessage = metadata?.overrideExceptionMessage\n ? metadata.overrideExceptionMessage\n : `Non-Error ${'exception'} captured with keys: ${extractExceptionKeysForMessage(candidate)}`\n\n const exception: Exception = {\n type: exceptionType,\n value: exceptionMessage,\n mechanism: {\n handled,\n synthetic,\n },\n }\n\n if (metadata?.syntheticException) {\n // Kludge: strip the last frame from a synthetically created error\n // so that it does not appear in a users stack trace\n const frames = parseStackFrames(metadata?.syntheticException, 1)\n if (frames.length) {\n exception.stacktrace = { frames, type: 'raw' }\n }\n }\n\n return {\n $exception_list: [exception],\n $exception_level: isSeverityLevel(candidate.level) ? candidate.level : 'error',\n }\n}\n\nexport function errorToProperties(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n [event, _, __, ___, error]: ErrorEventArgs,\n metadata?: ErrorMetadata\n): ErrorProperties {\n let errorProperties: ErrorProperties = { $exception_list: [] }\n\n const candidate = error || event\n\n if (isDOMError(candidate) || isDOMException(candidate)) {\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n\n const domException = candidate as unknown as DOMException\n\n if (isErrorWithStack(candidate)) {\n errorProperties = errorPropertiesFromError(candidate as Error, metadata)\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException')\n const message = domException.message ? `${name}: ${domException.message}` : name\n const exceptionType = isDOMError(domException) ? 'DOMError' : 'DOMException'\n errorProperties = errorPropertiesFromString(message, {\n ...metadata,\n overrideExceptionType: exceptionType,\n defaultExceptionMessage: message,\n })\n }\n if ('code' in domException) {\n errorProperties['$exception_DOMException_code'] = `${domException.code}`\n }\n return errorProperties\n } else if (isErrorEvent(candidate as ErrorEvent) && (candidate as ErrorEvent).error) {\n return errorPropertiesFromError((candidate as ErrorEvent).error as Error, metadata)\n } else if (isError(candidate)) {\n return errorPropertiesFromError(candidate, metadata)\n } else if (isPlainObject(candidate) || isEvent(candidate)) {\n // group these by using the keys available on the object\n const objectException = candidate as Record<string, unknown>\n return errorPropertiesFromObject(objectException, metadata)\n } else if (isUndefined(error) && isString(event)) {\n let name = 'Error'\n let message = event\n const groups = event.match(ERROR_TYPES_PATTERN)\n if (groups) {\n name = groups[1]\n message = groups[2]\n }\n\n return errorPropertiesFromString(message, {\n ...metadata,\n overrideExceptionType: name,\n defaultExceptionMessage: message,\n })\n } else {\n return errorPropertiesFromString(candidate as string, metadata)\n }\n}\n\nexport function unhandledRejectionToProperties([ev]: [ev: PromiseRejectionEvent]): ErrorProperties {\n const error = getUnhandledRejectionError(ev)\n\n if (isPrimitive(error)) {\n return errorPropertiesFromString(`Non-Error promise rejection captured with value: ${String(error)}`, {\n handled: false,\n synthetic: false,\n overrideExceptionType: 'UnhandledRejection',\n })\n }\n\n return errorToProperties([error as string | Event], {\n handled: false,\n overrideExceptionType: 'UnhandledRejection',\n defaultExceptionMessage: String(error),\n })\n}\n\nfunction getUnhandledRejectionError(error: unknown): unknown {\n if (isPrimitive(error)) {\n return error\n }\n\n // dig the object of the rejection out of known event types\n try {\n type ErrorWithReason = { reason: unknown }\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in (error as ErrorWithReason)) {\n return (error as ErrorWithReason).reason\n }\n\n type CustomEventWithDetail = { detail: { reason: unknown } }\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n if ('detail' in (error as CustomEventWithDetail) && 'reason' in (error as CustomEventWithDetail).detail) {\n return (error as CustomEventWithDetail).detail.reason\n }\n } catch {\n // no-empty\n }\n\n return error\n}\n","import { errorToProperties, unhandledRejectionToProperties } from '../extensions/exception-autocapture/error-conversion'\nimport { assignableWindow, window } from '../utils/globals'\nimport { ErrorEventArgs, Properties } from '../types'\nimport { logger } from '../utils/logger'\n\nconst wrapOnError = (captureFn: (props: Properties) => 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(args)\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: Properties) => 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 (...args: [ev: PromiseRejectionEvent]): boolean {\n const errorProperties = unhandledRejectionToProperties(args)\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, args) ?? 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 posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n}\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.errorWrappingFunctions = posthogErrorWrappingFunctions\nassignableWindow.__PosthogExtensions__.parseErrorAsProperties = errorToProperties\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\nassignableWindow.parseErrorAsProperties = errorToProperties\n\nexport default posthogErrorWrappingFunctions\n"],"names":["win","window","undefined","global","globalThis","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","Compression","assignableWindow","LOGGER_PREFIX","logger","_log","level","isUndefined","console","consoleLog","_len","arguments","length","args","Array","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","concat","severityLevels","nativeIsArray","isArray","toString","Object","prototype","obj","call","isFunction","x","isObject","isString","isEmptyString","trim","isNull","isEvent","candidate","Event","isInstanceOf","base","_unused","isPrimitive","isBuiltin","className","isDOMError","WEBPACK_ERROR_REGEXP","STACKTRACE_FRAME_LIMIT","UNKNOWN_FUNCTION","createFrame","filename","func","lineno","colno","frame","platform","function","in_app","chromeRegexNoFnName","chromeRegex","chromeEvalRegex","geckoREgex","geckoEvalRegex","defaultStackParser","parsers","sortedParsers","sort","a","b","map","p","stack","skipFirstLines","frames","lines","split","i","line","cleanedLine","test","replace","match","parser","push","localStack","from","reverse","slice","_objectSpread","getLastStackFrame","reverseAndStripFrames","createStackParser","noFnParts","exec","col","parts","indexOf","subMatch","extractSafariExtensionDetails","arr","isSafariExtension","isSafariWebExtension","ERROR_TYPES_PATTERN","parseStackFrames","ex","framesToPop","stacktrace","skipLines","reactMinifiedRegexp","message","getSkipFirstStackStringLines","errorPropertiesFromError","metadata","_metadata$handled","_metadata$synthetic","handled","synthetic","$exception_list","type","overrideExceptionType","name","value","overrideExceptionMessage","err","extractMessage","mechanism","$exception_level","errorPropertiesFromString","_metadata$handled2","_metadata$synthetic2","_metadata$defaultExce","exception","defaultExceptionType","defaultExceptionMessage","syntheticException","errorPropertiesFromObject","_metadata$handled3","_metadata$synthetic3","exceptionType","constructor","exceptionMessage","maxLength","keys","serialized","join","extractExceptionKeysForMessage","errorToProperties","_ref","event","_","__","___","errorProperties","isDOMException","domException","isErrorWithStack","code","isErrorEvent","Error","isError","isPlainObject","groups","unhandledRejectionToProperties","_ref2","ev","reason","detail","_unused2","getUnhandledRejectionError","String","posthogErrorWrappingFunctions","wrapOnError","captureFn","originalOnError","onerror","_originalOnError","__POSTHOG_INSTRUMENTED__","_win$onerror","wrapUnhandledRejection","originalOnUnhandledRejection","onunhandledrejection","_originalOnUnhandledR","apply","_win$onunhandledrejec","__PosthogExtensions__","errorWrappingFunctions","parseErrorAsProperties"],"mappings":"gtBAgBA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAgEzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAMlFK,EAAYF,aAAM,EAANA,EAAQE,UACTF,SAAAA,EAAQG,SACRH,SAAAA,EAAQI,SACXJ,SAAAA,EAAQK,MAEzBL,SAAAA,EAAQM,gBAAkB,oBAAqB,IAAIN,EAAOM,gBAAmBN,EAAOM,eACzDN,SAAAA,EAAQO,gBACdL,SAAAA,EAAWM,UAC7B,ICsUKC,EDtUCC,EAAqCb,QAAAA,EAAQ,CAAU,EE1F9Dc,EAAgB,eACTC,EAAS,CAClBC,KAAM,SAACC,GACH,GACIhB,GACiBY,EAA8B,gBAC9CK,EAAYjB,EAAOkB,UACpBlB,EAAOkB,QACT,CAME,IALA,IAAMC,GACF,uBAAwBnB,EAAOkB,QAAQF,GAChChB,EAAOkB,QAAQF,GAAmC,mBACnDhB,EAAOkB,QAAQF,IAEzBI,EAAAC,UAAAC,OAZmCC,MAAIC,MAAAJ,EAAAA,EAAAA,OAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAJF,EAAIE,EAAAJ,GAAAA,UAAAI,GA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BgM,sBAAsBE,uBAAyBxC,EAOhE1J,EAAiBkL,8BAAgCA,EACjDlL,EAAiBkM,uBAAyBxC"}
@@ -1,2 +1,2 @@
1
- !function(){"use strict";const n="undefined"!=typeof window?window:void 0,o="undefined"!=typeof globalThis?globalThis:n,e=null==o?void 0:o.navigator,t=null==o?void 0:o.document;null==o||o.location,null==o||o.fetch,null!=o&&o.XMLHttpRequest&&"withCredentials"in new o.XMLHttpRequest&&o.XMLHttpRequest,null==o||o.AbortController,null==e||e.userAgent;const r=null!=n?n:{};let i;!function(n){n.GZipJS="gzip-js",n.Base64="base64"}(i||(i={}));const l="[PostHog.js]",s={_log:function(o){if(n&&r.POSTHOG_DEBUG&&void 0!==n.console&&n.console){const r="__rrweb_original__"in n.console[o]?n.console[o].__rrweb_original__:n.console[o];for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];r(l,...t)}},info:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];s._log("log",...o)},warn:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];s._log("warn",...o)},error:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];s._log("error",...o)},critical:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];console.error(l,...o)},uninitializedWarning:n=>{s.error(`You must initialize PostHog before calling ${n}`)}},a=(n,o,e)=>{if(n.config.disable_external_dependency_loading)return s.warn(`${o} was requested but loading of external scripts is disabled.`),e("Loading of external scripts is disabled");const r=()=>{if(!t)return e("document not found");const n=t.createElement("script");n.type="text/javascript",n.crossOrigin="anonymous",n.src=o,n.onload=n=>e(void 0,n),n.onerror=n=>e(n);const r=t.querySelectorAll("body > script");var i;r.length>0?null===(i=r[0].parentNode)||void 0===i||i.insertBefore(n,r[0]):t.body.appendChild(n)};null!=t&&t.body?r():null==t||t.addEventListener("DOMContentLoaded",r)};r.__PosthogExtensions__=r.__PosthogExtensions__||{},r.__PosthogExtensions__.loadExternalDependency=(n,o,e)=>{let t=`/static/${o}.js?v=${n.version}`;if("toolbar"===o){const n=3e5;t=`${t}&t=${Math.floor(Date.now()/n)*n}`}const r=n.requestRouter.endpointFor("assets",t);a(n,r,e)},r.__PosthogExtensions__.loadSiteApp=(n,o,e)=>{const t=n.requestRouter.endpointFor("api",o);a(n,t,e)}}();
1
+ !function(){"use strict";var n="undefined"!=typeof window?window:void 0,o="undefined"!=typeof globalThis?globalThis:n,e=null==o?void 0:o.navigator,r=null==o?void 0:o.document;null==o||o.location,null==o||o.fetch,null!=o&&o.XMLHttpRequest&&"withCredentials"in new o.XMLHttpRequest&&o.XMLHttpRequest,null==o||o.AbortController,null==e||e.userAgent;var t,i=null!=n?n:{};!function(n){n.GZipJS="gzip-js",n.Base64="base64"}(t||(t={}));var l="[PostHog.js]",a={_log:function(o){if(n&&i.POSTHOG_DEBUG&&void 0!==n.console&&n.console){for(var e=("__rrweb_original__"in n.console[o]?n.console[o].__rrweb_original__:n.console[o]),r=arguments.length,t=new Array(r>1?r-1:0),a=1;a<r;a++)t[a-1]=arguments[a];e(l,...t)}},info:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];a._log("log",...o)},warn:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];a._log("warn",...o)},error:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];a._log("error",...o)},critical:function(){for(var n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];console.error(l,...o)},uninitializedWarning:n=>{a.error("You must initialize PostHog before calling ".concat(n))}},s=(n,o,e)=>{if(n.config.disable_external_dependency_loading)return a.warn("".concat(o," was requested but loading of external scripts is disabled.")),e("Loading of external scripts is disabled");var t=()=>{if(!r)return e("document not found");var n=r.createElement("script");n.type="text/javascript",n.crossOrigin="anonymous",n.src=o,n.onload=n=>e(void 0,n),n.onerror=n=>e(n);var t,i=r.querySelectorAll("body > script");i.length>0?null===(t=i[0].parentNode)||void 0===t||t.insertBefore(n,i[0]):r.body.appendChild(n)};null!=r&&r.body?t():null==r||r.addEventListener("DOMContentLoaded",t)};i.__PosthogExtensions__=i.__PosthogExtensions__||{},i.__PosthogExtensions__.loadExternalDependency=(n,o,e)=>{var r="/static/".concat(o,".js")+"?v=".concat(n.version);if("toolbar"===o){var t=3e5,i=Math.floor(Date.now()/t)*t;r="".concat(r,"&t=").concat(i)}var l=n.requestRouter.endpointFor("assets",r);s(n,l,e)},i.__PosthogExtensions__.loadSiteApp=(n,o,e)=>{var r=n.requestRouter.endpointFor("api",o);s(n,r,e)}}();
2
2
  //# sourceMappingURL=external-scripts-loader.js.map