@launchdarkly/browser-telemetry 1.0.9 → 1.0.11

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.11](https://github.com/launchdarkly/js-core/compare/browser-telemetry-v1.0.10...browser-telemetry-v1.0.11) (2025-07-23)
4
+
5
+
6
+ ### Dependencies
7
+
8
+ * The following workspace dependencies were updated
9
+ * devDependencies
10
+ * @launchdarkly/js-client-sdk bumped from 0.8.0 to 0.8.1
11
+
12
+ ## [1.0.10](https://github.com/launchdarkly/js-core/compare/browser-telemetry-v1.0.9...browser-telemetry-v1.0.10) (2025-06-17)
13
+
14
+
15
+ ### Dependencies
16
+
17
+ * The following workspace dependencies were updated
18
+ * devDependencies
19
+ * @launchdarkly/js-client-sdk bumped from 0.7.1 to 0.8.0
20
+
3
21
  ## [1.0.9](https://github.com/launchdarkly/js-core/compare/browser-telemetry-v1.0.8...browser-telemetry-v1.0.9) (2025-06-03)
4
22
 
5
23
 
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
- "use strict";var ne=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var Pe=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ce(t))!Me.call(e,i)&&i!==r&&ne(e,i,{get:()=>t[i],enumerable:!(n=De(t,i))||n.enumerable});return e};var Ue=e=>Ne(ne({},"__esModule",{value:!0}),e);var Pt={};Pe(Pt,{addBreadcrumb:()=>Rt,captureError:()=>Bt,captureErrorEvent:()=>It,close:()=>Ct,getTelemetryInstance:()=>O,initTelemetry:()=>wt,initTelemetryInstance:()=>Mt,inspectors:()=>Ot,register:()=>Dt,resetTelemetryInstance:()=>Ft});module.exports=Ue(Pt);function H(e){try{return e.target}catch(t){return}}var $e=">",He=` ${$e} `;function Ae(e){let t=e;return typeof t=="object"&&t!=null&&t.parentNode}function Xe(e){if(typeof e.className!="string")return;let t=e.className;if(e.className.includes(" ")&&(t=e.className.replace(" ",".")),t!=="")return`.${t}`}function je(e){if(!e.tagName)return"";let t=[];t.push(e.tagName.toLowerCase()),e.id&&t.push(`#${e.id}`);let r=Xe(e);return r&&t.push(r),t.join("")}function A(e,t={maxDepth:10}){let r=[],n=e;for(;Ae(n)&&n.parentNode&&r.length<t.maxDepth;){let i=je(n);if(i==="html")break;r.push(i),n=n.parentNode}return r.reverse().join(He)}var X=class{constructor(){window.addEventListener("click",t=>{var n;let r=H(t);if(r){let i={class:"ui",type:"click",level:"info",timestamp:Date.now(),message:A(r)};(n=this._destination)==null||n.addBreadcrumb(i)}},!0)}register(t,r){this._destination=t}unregister(){this._destination=void 0}};var qe=1e3,Ke=["INPUT","TEXTAREA"],j=class{constructor(){window.addEventListener("keypress",t=>{var i;let r=H(t),n=r;if(r&&(Ke.includes(r.tagName)||n!=null&&n.isContentEditable)){let f={class:"ui",type:"input",level:"info",timestamp:Date.now(),message:A(r)};this._shouldDeduplicate(f)||((i=this._destination)==null||i.addBreadcrumb(f),this._lastEvent=f)}},!0)}register(t,r){this._destination=t}unregister(){this._destination=void 0}_shouldDeduplicate(t){return this._lastEvent?Math.abs(t.timestamp-this._lastEvent.timestamp)<=qe&&this._lastEvent.message===t.message:!1}};var q=class{constructor(){window.addEventListener("error",t=>{var r;(r=this._destination)==null||r.captureErrorEvent(t)},!0),window.addEventListener("unhandledrejection",t=>{var r;t.reason&&((r=this._destination)==null||r.captureError(t.reason))},!0)}register(t){this._destination=t}unregister(){this._destination=void 0}};function ie(e,t){return t?e.reduce((r,n)=>n(r),t):""}function K(e,t){var r;(r=e.data)!=null&&r.url&&(e.data.url=ie(t.urlFilters,e.data.url))}var We="__LaunchDarkly_original_fetch",W=window.fetch;function Ge(e,t){var i;let r="",n="GET";return typeof e=="string"&&(r=e),typeof Request!="undefined"&&e instanceof Request&&(r=e.url,n=e.method),typeof URL!="undefined"&&e instanceof URL&&(r=e.toString()),t&&(n=(i=t.method)!=null?i:n),{url:r,method:n}}function se(e){function t(...r){let n=Date.now();return W.apply(this,r).then(i=>{let f={class:"http",timestamp:n,level:i.ok?"info":"error",type:"fetch",data:{...Ge(r[0],r[1]),statusCode:i.status,statusText:i.statusText}};return e(f),i})}t.prototype=W==null?void 0:W.prototype;try{Object.defineProperty(t,We,{value:W,writable:!0,configurable:!0})}catch(r){}window.fetch=t}var G=class{constructor(t){this._loggedIssue=!1;se(r=>{var i,f,x;let n=!1;try{K(r,t),n=!0}catch(k){this._loggedIssue||((f=(i=t.getLogger)==null?void 0:i.call(t))==null||f.warn("Error filtering http breadcrumb",k),this._loggedIssue=!0)}n&&((x=this._destination)==null||x.addBreadcrumb(r))})}register(t,r){this._destination=t}unregister(){this._destination=void 0}};var ve="__LaunchDarkly_original_xhr",ze=`${ve}_open`,Ve=`${ve}_send`,ee="__LaunchDarkly_data_xhr",ye=window.XMLHttpRequest.prototype.open,Le=window.XMLHttpRequest.prototype.send;function ae(e){function t(...n){this.addEventListener("error",function(i){let f=this[ee];f.error=!0}),this.addEventListener("loadend",function(i){let f=this[ee];f&&f.timestamp&&e({class:"http",timestamp:f.timestamp,level:f.error?"error":"info",type:"xhr",data:{url:f.url,method:f.method,statusCode:this.status,statusText:this.statusText}})},!0),ye.apply(this,n);try{let i={method:n==null?void 0:n[0],url:n==null?void 0:n[1]};Object.defineProperty(this,ee,{value:i,writable:!0,configurable:!0})}catch(i){}}function r(...n){Le.apply(this,n);let i=this[ee];i&&(i.timestamp=Date.now())}window.XMLHttpRequest.prototype.open=t,window.XMLHttpRequest.prototype.send=r;try{Object.defineProperties(window.XMLHttpRequest,{[ze]:{value:ye,writable:!0,configurable:!0},[Ve]:{value:Le,writable:!0,configurable:!0}})}catch(n){}}var z=class{constructor(t){this._loggedIssue=!1;ae(r=>{var i,f,x;let n=!1;try{K(r,t),n=!0}catch(k){this._loggedIssue||((f=(i=t.getLogger)==null?void 0:i.call(t))==null||f.warn("Error filtering http breadcrumb",k),this._loggedIssue=!0)}n&&((x=this._destination)==null||x.addBreadcrumb(r))})}register(t,r){this._destination=t}unregister(){this._destination=void 0}};var Ye=/sdk\/evalx\/[^/]+\/contexts\/(?<context>[^/?]*)\??.*?/,Ze=/\/eval\/[^/]+\/(?<context>[^/?]*)\??.*?/;function Je(e){try{if(e.includes("://")){let t=new URL(e),r=!1;if(t.username&&(t.username="redacted",r=!0),t.password&&(t.password="redacted",r=!0),r)return t.toString()}}catch(t){}return e}function Qe(e){var t,r;if(e.includes("/sdk/evalx")){let n=e.match(Ye),i=(t=n==null?void 0:n.groups)==null?void 0:t.context;if(i)return e.replace(i,"*".repeat(i.length))}if(e.includes("/eval/")){let n=e.match(Ze),i=(r=n==null?void 0:n.groups)==null?void 0:r.context;if(i)return e.replace(i,"*".repeat(i.length))}return e}function oe(e){return Qe(Je(e))}function ce(e,t,r){e.breadcrumbs.evaluations&&t.push({type:"flag-used",name:"launchdarkly-browser-telemetry-flag-used",synchronous:!0,method(n,i,f){r.handleFlagUsed(n,i,f)}}),e.breadcrumbs.flagChange&&t.push({type:"flag-detail-changed",name:"launchdarkly-browser-telemetry-flag-used",synchronous:!0,method(n,i){r.handleFlagDetailChanged(n,i)}})}var S={warn:console.warn},et="LaunchDarkly - Browser Telemetry:";function T(e){return`${et} ${e}`}function P(e){return{warn:(...t)=>{if(!e){S.warn(...t);return}try{e.warn(...t)}catch(r){S.warn(...t),S.warn(T("The provided logger threw an exception, using fallback logger."))}}}}var tt={start:0,end:3},rt={start:4,end:5},ue={start:6,end:7},le={start:8,end:8},nt={start:9,end:9},it={start:10,end:15};function st(){if(crypto&&crypto.getRandomValues){let t=new Uint8Array(16);return crypto.getRandomValues(t),[...t.values()]}let e=[];for(let t=0;t<16;t+=1)e.push(Math.floor(Math.random()*256));return e}function N(e,t){let r="";for(let n=t.start;n<=t.end;n+=1)r+=e[n].toString(16).padStart(2,"0");return r}function at(e){return e[le.start]=(e[le.start]|128)&191,e[ue.start]=e[ue.start]&15|64,`${N(e,tt)}-${N(e,rt)}-${N(e,ue)}-${N(e,le)}${N(e,nt)}-${N(e,it)}`}function ot(){let e=st();return at(e)}function fe(){return typeof crypto!==void 0&&typeof crypto.randomUUID=="function"?crypto.randomUUID():ot()}var y={};(function(e,t){if(!e)return;let r=[].slice,n="?",i=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function f(k,B){return Object.prototype.hasOwnProperty.call(k,B)}function x(k){return typeof k=="undefined"}y.wrap=function(B){function I(){try{return B.apply(this,arguments)}catch(Z){throw y.report(Z),Z}}return I},y.computeStackTrace=function(){let I={};function Z(a){if(!y.remoteFetching)return"";try{let u=function(){try{return new e.XMLHttpRequest}catch(p){return new e.ActiveXObject("Microsoft.XMLHTTP")}}();return u.open("GET",a,!1),u.send(""),u.responseText}catch(c){return""}}function D(a){if(typeof a!="string")return[];if(!f(I,a)){let c="",u="";try{u=e.document.domain}catch(o){}let p=/(.*)\:\/\/([^:\/]+)([:\d]*)\/{0,1}([\s\S]*)/.exec(a);p&&p[2]===u&&(c=Z(a)),I[a]=c?c.split(`
1
+ "use strict";var ne=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var Pe=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ce(t))!Me.call(e,i)&&i!==r&&ne(e,i,{get:()=>t[i],enumerable:!(n=De(t,i))||n.enumerable});return e};var Ue=e=>Ne(ne({},"__esModule",{value:!0}),e);var Ct={};Pe(Ct,{addBreadcrumb:()=>Bt,captureError:()=>Ot,captureErrorEvent:()=>Ft,close:()=>Rt,getTelemetryInstance:()=>F,initTelemetry:()=>Tt,initTelemetryInstance:()=>Dt,inspectors:()=>wt,register:()=>It,resetTelemetryInstance:()=>St});module.exports=Ue(Ct);function H(e){try{return e.target}catch(t){return}}function $e(e){let t=e;return typeof t=="object"&&t!=null&&t.parentNode}function He(e){if(typeof e.className!="string")return;let t=e.className;if(e.className.includes(" ")&&(t=e.className.replace(" ",".")),t!=="")return`.${t}`}function Ae(e){if(!e.tagName)return"";let t=[];t.push(e.tagName.toLowerCase()),e.id&&t.push(`#${e.id}`);let r=He(e);return r&&t.push(r),t.join("")}function A(e,t={maxDepth:10}){let r=[],n=e;for(;$e(n)&&n.parentNode&&r.length<t.maxDepth;){let i=Ae(n);if(i==="html")break;r.push(i),n=n.parentNode}return r.reverse().join(" > ")}var X=class{constructor(){window.addEventListener("click",t=>{var n;let r=H(t);if(r){let i={class:"ui",type:"click",level:"info",timestamp:Date.now(),message:A(r)};(n=this._destination)==null||n.addBreadcrumb(i)}},!0)}register(t,r){this._destination=t}unregister(){this._destination=void 0}};var Xe=1e3,je=["INPUT","TEXTAREA"],j=class{constructor(){window.addEventListener("keypress",t=>{var i;let r=H(t),n=r;if(r&&(je.includes(r.tagName)||n!=null&&n.isContentEditable)){let f={class:"ui",type:"input",level:"info",timestamp:Date.now(),message:A(r)};this._shouldDeduplicate(f)||((i=this._destination)==null||i.addBreadcrumb(f),this._lastEvent=f)}},!0)}register(t,r){this._destination=t}unregister(){this._destination=void 0}_shouldDeduplicate(t){return this._lastEvent?Math.abs(t.timestamp-this._lastEvent.timestamp)<=Xe&&this._lastEvent.message===t.message:!1}};var q=class{constructor(){window.addEventListener("error",t=>{var r;(r=this._destination)==null||r.captureErrorEvent(t)},!0),window.addEventListener("unhandledrejection",t=>{var r;t.reason&&((r=this._destination)==null||r.captureError(t.reason))},!0)}register(t){this._destination=t}unregister(){this._destination=void 0}};function ie(e,t){return t?e.reduce((r,n)=>n(r),t):""}function K(e,t){var r;(r=e.data)!=null&&r.url&&(e.data.url=ie(t.urlFilters,e.data.url))}var qe="__LaunchDarkly_original_fetch",W=window.fetch;function Ke(e,t){var i;let r="",n="GET";return typeof e=="string"&&(r=e),typeof Request!="undefined"&&e instanceof Request&&(r=e.url,n=e.method),typeof URL!="undefined"&&e instanceof URL&&(r=e.toString()),t&&(n=(i=t.method)!=null?i:n),{url:r,method:n}}function se(e){function t(...r){let n=Date.now();return W.apply(this,r).then(i=>{let f={class:"http",timestamp:n,level:i.ok?"info":"error",type:"fetch",data:{...Ke(r[0],r[1]),statusCode:i.status,statusText:i.statusText}};return e(f),i})}t.prototype=W==null?void 0:W.prototype;try{Object.defineProperty(t,qe,{value:W,writable:!0,configurable:!0})}catch(r){}window.fetch=t}var G=class{constructor(t){this._loggedIssue=!1;se(r=>{var i,f,x;let n=!1;try{K(r,t),n=!0}catch(k){this._loggedIssue||((f=(i=t.getLogger)==null?void 0:i.call(t))==null||f.warn("Error filtering http breadcrumb",k),this._loggedIssue=!0)}n&&((x=this._destination)==null||x.addBreadcrumb(r))})}register(t,r){this._destination=t}unregister(){this._destination=void 0}};var ve="__LaunchDarkly_original_xhr",We=`${ve}_open`,Ge=`${ve}_send`,ee="__LaunchDarkly_data_xhr",ye=window.XMLHttpRequest.prototype.open,Le=window.XMLHttpRequest.prototype.send;function ae(e){function t(...n){this.addEventListener("error",function(i){let f=this[ee];f.error=!0}),this.addEventListener("loadend",function(i){let f=this[ee];f&&f.timestamp&&e({class:"http",timestamp:f.timestamp,level:f.error?"error":"info",type:"xhr",data:{url:f.url,method:f.method,statusCode:this.status,statusText:this.statusText}})},!0),ye.apply(this,n);try{let i={method:n==null?void 0:n[0],url:n==null?void 0:n[1]};Object.defineProperty(this,ee,{value:i,writable:!0,configurable:!0})}catch(i){}}function r(...n){Le.apply(this,n);let i=this[ee];i&&(i.timestamp=Date.now())}window.XMLHttpRequest.prototype.open=t,window.XMLHttpRequest.prototype.send=r;try{Object.defineProperties(window.XMLHttpRequest,{[We]:{value:ye,writable:!0,configurable:!0},[Ge]:{value:Le,writable:!0,configurable:!0}})}catch(n){}}var z=class{constructor(t){this._loggedIssue=!1;ae(r=>{var i,f,x;let n=!1;try{K(r,t),n=!0}catch(k){this._loggedIssue||((f=(i=t.getLogger)==null?void 0:i.call(t))==null||f.warn("Error filtering http breadcrumb",k),this._loggedIssue=!0)}n&&((x=this._destination)==null||x.addBreadcrumb(r))})}register(t,r){this._destination=t}unregister(){this._destination=void 0}};var ze=/sdk\/evalx\/[^/]+\/contexts\/(?<context>[^/?]*)\??.*?/,Ve=/\/eval\/[^/]+\/(?<context>[^/?]*)\??.*?/;function Ye(e){try{if(e.includes("://")){let t=new URL(e),r=!1;if(t.username&&(t.username="redacted",r=!0),t.password&&(t.password="redacted",r=!0),r)return t.toString()}}catch(t){}return e}function Ze(e){var t,r;if(e.includes("/sdk/evalx")){let n=e.match(ze),i=(t=n==null?void 0:n.groups)==null?void 0:t.context;if(i)return e.replace(i,"*".repeat(i.length))}if(e.includes("/eval/")){let n=e.match(Ve),i=(r=n==null?void 0:n.groups)==null?void 0:r.context;if(i)return e.replace(i,"*".repeat(i.length))}return e}function oe(e){return Ze(Ye(e))}function ce(e,t,r){e.breadcrumbs.evaluations&&t.push({type:"flag-used",name:"launchdarkly-browser-telemetry-flag-used",synchronous:!0,method(n,i,f){r.handleFlagUsed(n,i,f)}}),e.breadcrumbs.flagChange&&t.push({type:"flag-detail-changed",name:"launchdarkly-browser-telemetry-flag-used",synchronous:!0,method(n,i){r.handleFlagDetailChanged(n,i)}})}var S={warn:console.warn},Je="LaunchDarkly - Browser Telemetry:";function T(e){return`${Je} ${e}`}function P(e){return{warn:(...t)=>{if(!e){S.warn(...t);return}try{e.warn(...t)}catch(r){S.warn(...t),S.warn(T("The provided logger threw an exception, using fallback logger."))}}}}var Qe={start:0,end:3},et={start:4,end:5},ue={start:6,end:7},le={start:8,end:8},tt={start:9,end:9},rt={start:10,end:15};function nt(){if(crypto&&crypto.getRandomValues){let t=new Uint8Array(16);return crypto.getRandomValues(t),[...t.values()]}let e=[];for(let t=0;t<16;t+=1)e.push(Math.floor(Math.random()*256));return e}function N(e,t){let r="";for(let n=t.start;n<=t.end;n+=1)r+=e[n].toString(16).padStart(2,"0");return r}function it(e){return e[le.start]=(e[le.start]|128)&191,e[ue.start]=e[ue.start]&15|64,`${N(e,Qe)}-${N(e,et)}-${N(e,ue)}-${N(e,le)}${N(e,tt)}-${N(e,rt)}`}function st(){let e=nt();return it(e)}function fe(){return typeof crypto!==void 0&&typeof crypto.randomUUID=="function"?crypto.randomUUID():st()}var y={};(function(e,t){if(!e)return;let r=[].slice,n="?",i=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function f(k,B){return Object.prototype.hasOwnProperty.call(k,B)}function x(k){return typeof k=="undefined"}y.wrap=function(B){function I(){try{return B.apply(this,arguments)}catch(Z){throw y.report(Z),Z}}return I},y.computeStackTrace=function(){let I={};function Z(a){if(!y.remoteFetching)return"";try{let u=function(){try{return new e.XMLHttpRequest}catch(p){return new e.ActiveXObject("Microsoft.XMLHTTP")}}();return u.open("GET",a,!1),u.send(""),u.responseText}catch(c){return""}}function D(a){if(typeof a!="string")return[];if(!f(I,a)){let c="",u="";try{u=e.document.domain}catch(o){}let p=/(.*)\:\/\/([^:\/]+)([:\d]*)\/{0,1}([\s\S]*)/.exec(a);p&&p[2]===u&&(c=Z(a)),I[a]=c?c.split(`
2
2
  `):[]}return I[a]}function C(a,c){typeof c!="number"&&(c=Number(c));let u=/function ([^(]*)\(([^)]*)\)/,p=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,o="",b=10,g=D(a),d;if(!g.length)return n;for(let l=0;l<b;++l)if(o=g[c-l]+o,!x(o)&&((d=p.exec(o))||(d=u.exec(o))))return d[1];return n}function $(a,c){typeof c!="number"&&(c=Number(c));let u=D(a);if(!u.length)return null;let p=[],o=Math.floor(y.linesOfContext/2),b=o+y.linesOfContext%2,g=Math.max(0,c-o-1),d=Math.min(u.length,c+b-1);c-=1;for(let l=g;l<d;++l)x(u[l])||p.push(u[l]);return p.length>0?{contextLines:p,startFromSource:g+1}:null}function J(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function pe(a){return J(a).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function Q(a,c){let u,p;for(let o=0,b=c.length;o<b;++o)if((u=D(c[o])).length&&(u=u.join(`
3
3
  `),p=a.exec(u)))return{url:c[o],line:u.substring(0,p.index).split(`
4
4
  `).length,column:p.index-u.lastIndexOf(`
5
- `,p.index)-1};return null}function re(a,c,u){typeof u!="number"&&(u=Number(u));let p=D(c),o=new RegExp(`\\b${J(a)}\\b`),b;return u-=1,p&&p.length>u&&(b=o.exec(p[u]))?b.index:null}function Fe(a){if(x(e&&e.document))return;let c=[e.location.href],u=e.document.getElementsByTagName("script"),p,o=`${a}`,b=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,g=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,d,l,m;for(let s=0;s<u.length;++s){let h=u[s];h.src&&c.push(h.src)}if(!(l=b.exec(o)))d=new RegExp(J(o).replace(/\s+/g,"\\s+"));else{let s=l[1]?`\\s+${l[1]}`:"",h=l[2].split(",").join("\\s*,\\s*");p=J(l[3]).replace(/;$/,";?"),d=new RegExp(`function${s}\\s*\\(\\s*${h}\\s*\\)\\s*{\\s*${p}\\s*}`)}if(m=Q(d,c))return m;if(l=g.exec(o)){let s=l[1];if(p=pe(l[2]),d=new RegExp(`on${s}=[\\'"]\\s*${p}\\s*[\\'"]`,"i"),(m=Q(d,c[0]))||(d=new RegExp(p),m=Q(d,c)))return m}return null}function ge(a){var L;if(!a.stack)return null;let c=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,u=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,p=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,o,b=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,g=/\((\S*)(?::(\d+))(?::(\d+))\)/,d=a.stack.split(`
6
- `),l=[],m,s,h,E=/^(.*) is undefined$/.exec(a.message);for(let F=0,Re=d.length;F<Re;++F){if(s=c.exec(d[F])){let xe=s[2]&&s[2].indexOf("native")===0;o=s[2]&&s[2].indexOf("eval")===0,o&&(m=g.exec(s[2]))&&(s[2]=m[1],s[3]=m[2],s[4]=m[3]),h={url:xe?null:s[2],func:s[1]||n,args:xe?[s[2]]:[],line:s[3]?+s[3]:null,column:s[4]?+s[4]:null}}else if(s=p.exec(d[F]))h={url:s[2],func:s[1]||n,args:[],line:+s[3],column:s[4]?+s[4]:null};else if(s=u.exec(d[F]))o=s[3]&&s[3].indexOf(" > eval")>-1,o&&(m=b.exec(s[3]))?(s[3]=m[1],s[4]=m[2],s[5]=null):F===0&&!s[5]&&!x(a.columnNumber)&&(l[0].column=a.columnNumber+1),h={url:s[3],func:s[1]||n,args:s[2]?s[2].split(","):[],line:s[4]?+s[4]:null,column:s[5]?+s[5]:null};else continue;!h.func&&h.line&&(h.func=C(h.url,h.line));let M=$(h.url,h.line);h.context=h.line&&(L=M==null?void 0:M.contextLines)!=null?L:null,h.srcStart=M==null?void 0:M.startFromSource,l.push(h)}return l.length?(l[0]&&l[0].line&&!l[0].column&&E&&(l[0].column=re(E[1],l[0].url,l[0].line)),{mode:"stack",name:a.name,message:a.message,stack:l}):null}function Oe(a){var d;let{stacktrace:c}=a;if(!c)return null;let u=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,p=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,o=c.split(`
5
+ `,p.index)-1};return null}function re(a,c,u){typeof u!="number"&&(u=Number(u));let p=D(c),o=new RegExp(`\\b${J(a)}\\b`),b;return u-=1,p&&p.length>u&&(b=o.exec(p[u]))?b.index:null}function Oe(a){if(x(e&&e.document))return;let c=[e.location.href],u=e.document.getElementsByTagName("script"),p,o=`${a}`,b=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,g=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,d,l,m;for(let s=0;s<u.length;++s){let h=u[s];h.src&&c.push(h.src)}if(!(l=b.exec(o)))d=new RegExp(J(o).replace(/\s+/g,"\\s+"));else{let s=l[1]?`\\s+${l[1]}`:"",h=l[2].split(",").join("\\s*,\\s*");p=J(l[3]).replace(/;$/,";?"),d=new RegExp(`function${s}\\s*\\(\\s*${h}\\s*\\)\\s*{\\s*${p}\\s*}`)}if(m=Q(d,c))return m;if(l=g.exec(o)){let s=l[1];if(p=pe(l[2]),d=new RegExp(`on${s}=[\\'"]\\s*${p}\\s*[\\'"]`,"i"),(m=Q(d,c[0]))||(d=new RegExp(p),m=Q(d,c)))return m}return null}function ge(a){var L;if(!a.stack)return null;let c=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,u=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,p=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,o,b=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,g=/\((\S*)(?::(\d+))(?::(\d+))\)/,d=a.stack.split(`
6
+ `),l=[],m,s,h,E=/^(.*) is undefined$/.exec(a.message);for(let O=0,Re=d.length;O<Re;++O){if(s=c.exec(d[O])){let xe=s[2]&&s[2].indexOf("native")===0;o=s[2]&&s[2].indexOf("eval")===0,o&&(m=g.exec(s[2]))&&(s[2]=m[1],s[3]=m[2],s[4]=m[3]),h={url:xe?null:s[2],func:s[1]||n,args:xe?[s[2]]:[],line:s[3]?+s[3]:null,column:s[4]?+s[4]:null}}else if(s=p.exec(d[O]))h={url:s[2],func:s[1]||n,args:[],line:+s[3],column:s[4]?+s[4]:null};else if(s=u.exec(d[O]))o=s[3]&&s[3].indexOf(" > eval")>-1,o&&(m=b.exec(s[3]))?(s[3]=m[1],s[4]=m[2],s[5]=null):O===0&&!s[5]&&!x(a.columnNumber)&&(l[0].column=a.columnNumber+1),h={url:s[3],func:s[1]||n,args:s[2]?s[2].split(","):[],line:s[4]?+s[4]:null,column:s[5]?+s[5]:null};else continue;!h.func&&h.line&&(h.func=C(h.url,h.line));let M=$(h.url,h.line);h.context=h.line&&(L=M==null?void 0:M.contextLines)!=null?L:null,h.srcStart=M==null?void 0:M.startFromSource,l.push(h)}return l.length?(l[0]&&l[0].line&&!l[0].column&&E&&(l[0].column=re(E[1],l[0].url,l[0].line)),{mode:"stack",name:a.name,message:a.message,stack:l}):null}function Fe(a){var d;let{stacktrace:c}=a;if(!c)return null;let u=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,p=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,o=c.split(`
7
7
  `),b=[],g;for(let l=0;l<o.length;l+=2){let m=null;if((g=u.exec(o[l]))?m={url:g[2],line:+g[1],column:null,func:g[3],args:[]}:(g=p.exec(o[l]))&&(m={url:g[6],line:+g[1],column:+g[2],func:g[3]||g[4],args:g[5]?g[5].split(","):[]}),m){if(!m.func&&m.line&&(m.func=C(m.url,m.line)),m.line)try{let s=$(m.url,m.line);m.srcStart=s==null?void 0:s.startFromSource,m.context=m.line&&(d=s==null?void 0:s.contextLines)!=null?d:null}catch(s){}m.context||(m.context=[o[l+1]]),b.push(m)}}return b.length?{mode:"stacktrace",name:a.name,message:a.message,stack:b}:null}function Be(a){let c=a.message.split(`
8
8
  `);if(c.length<4)return null;let u=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,p=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,o=/^\s*Line (\d+) of function script\s*$/i,b=[],g=e&&e.document&&e.document.getElementsByTagName("script"),d=[],l;for(let m in g)f(g,m)&&!g[m].src&&d.push(g[m]);for(let m=2;m<c.length;m+=2){let s=null;if(l=u.exec(c[m]))s={url:l[2],func:l[3],args:[],line:+l[1],column:null};else if(l=p.exec(c[m])){s={url:l[3],func:l[4],args:[],line:+l[1],column:null};let h=+l[1],E=d[l[2]-1];if(E){let L=D(s.url);if(L){L=L.join(`
9
- `);let F=L.indexOf(E.innerText);F>=0&&(s.line=h+L.substring(0,F).split(`
10
- `).length)}}}else if(l=o.exec(c[m])){let h=e.location.href.replace(/#.*$/,""),E=new RegExp(pe(c[m+1])),L=Q(E,[h]);s={url:h,func:"",args:[],line:L?L.line:l[1],column:null}}if(s){s.func||(s.func=C(s.url,s.line));let h=$(s.url,s.line);s.srcStart=h==null?void 0:h.startFromSource;let E=h==null?void 0:h.contextLines,L=E?E[Math.floor(E.length/2)]:null;E&&L&&L.replace(/^\s*/,"")===c[m+1].replace(/^\s*/,"")?s.context=E:s.context=[c[m+1]],b.push(s)}}return b.length?{mode:"multiline",name:a.name,message:c[0],stack:b}:null}function he(a,c,u,p){var b;let o={url:c,line:u};if(o.url&&o.line){if(a.incomplete=!1,o.func||(o.func=C(o.url,o.line)),!o.context){let d=$(o.url,o.line);o.context=(b=d==null?void 0:d.contextLines)!=null?b:null,o.srcStart=d==null?void 0:d.startFromSource}let g=/ '([^']+)' /.exec(p);if(g&&(o.column=re(g[1],o.url,o.line)),a.stack.length>0&&a.stack[0].url===o.url){if(a.stack[0].line===o.line)return!1;if(!a.stack[0].line&&a.stack[0].func===o.func)return a.stack[0].line=o.line,a.stack[0].context=o.context,!1}return a.stack.unshift(o),a.partial=!0,!0}return a.incomplete=!0,!1}function be(a,c){let u=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,p=[],o={},b=!1,g,d,l;for(let s=be.caller;s&&!b;s=s.caller)if(!(s===w||s===y.report)){if(d={url:null,func:n,args:[],line:null,column:null},s.name?d.func=s.name:(g=u.exec(s.toString()))&&(d.func=g[1]),typeof d.func=="undefined")try{d.func=g.input.substring(0,g.input.indexOf("{"))}catch(h){}if(l=Fe(s)){d.url=l.url,d.line=l.line,d.func===n&&(d.func=C(d.url,d.line));let h=/ '([^']+)' /.exec(a.message||a.description);h&&(d.column=re(h[1],l.url,l.line))}o[`${s}`]?b=!0:o[`${s}`]=!0,p.push(d)}c&&p.splice(0,c);let m={mode:"callers",name:a.name,message:a.message,stack:p};return he(m,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description),m}function w(a,c){let u=null;c=c==null?0:+c;try{if(u=Oe(a),u)return u}catch(p){}try{if(u=ge(a),u)return u}catch(p){}try{if(u=Be(a),u)return u}catch(p){}try{if(u=be(a,c+1),u)return u}catch(p){}return{name:a.name,message:a.message,mode:"failed",stack:[]}}function Ie(a){a=(a==null?0:+a)+1;try{throw new Error}catch(c){return w(c,a+1)}}return w.augmentStackTraceWithInitialElement=he,w.computeStackTraceFromStackProp=ge,w.guessFunctionName=C,w.gatherContext=$,w.ofCaller=Ie,w.getSource=D,w}(),y.remoteFetching||(y.remoteFetching=!0),y.collectWindowErrors||(y.collectWindowErrors=!0),(!y.linesOfContext||y.linesOfContext<1)&&(y.linesOfContext=11)})(typeof window!="undefined"?window:global);function te(){return y}var Ee="(index)";function ct(e,t){let r=e;if(e.startsWith(t)){if(r=e.slice(t.length),r.startsWith("/")&&(r=r.slice(1)),r==="")return Ee;r.endsWith("/")&&(r+=Ee)}return r}function ut(e,t,r){return Math.min(t,Math.max(e,r))}function _e(e,t,r){if(t.length<=e.maxLength)return t;let n=Math.max(0,r-e.beforeColumnCharacters),i=Math.min(t.length,n+e.maxLength);return t.slice(n,i)}function ke(e,t,r,n){let i=e<0?0:e,f=t>r.length?r.length:t;return i<f?r.slice(i,f).map(n):[]}function lt(e,t){var k,B;let{context:r}=e;if(!r)return{};let{maxLineLength:n}=t.source,i=Math.floor(n/2),f=I=>_e({maxLength:t.source.maxLineLength,beforeColumnCharacters:i},I,0),x=ut(0,r.length-1,((k=e==null?void 0:e.line)!=null?k:0)-((B=e.srcStart)!=null?B:0));return{srcBefore:ke(x-t.source.beforeLines,x,r,f),srcLine:_e({maxLength:n,beforeColumnCharacters:i},r[x],e.column||0),srcAfter:ke(x+1,x+1+t.source.afterLines,r,f)}}function me(e,t){return t.enabled?{frames:te().computeStackTrace(e).stack.reverse().map(i=>{var f,x;return{fileName:ct(i.url,window.location.origin),function:i.func,line:(f=i.line)!=null?f:void 0,col:(x=i.column)!=null?x:void 0,...lt(i,t)}})}:{frames:[]}}var we="$ld:telemetry",ft=`${we}:error`,mt=`${we}:session:init`,Te="generic",dt="exception was null or undefined",pt="exception had no message",gt=5;function Se(e){switch(typeof e){case"string":case"boolean":case"number":return e;default:return}}function ht(e,t){return e===void 0?void 0:t(e)}function bt(e){if(!e.enabled)return;let t=te(),r=Math.max(e.source.afterLines,e.source.beforeLines),n=t;n.linesOfContext=r*2+1}function xt(e){return e.logger!==void 0}function yt(e){return e.waitForInitialization!==void 0}var R=class{constructor(t){this._options=t;this._pendingEvents=[];this._breadcrumbs=[];this._inspectorInstances=[];this._collectors=[];this._sessionId=fe();this._registrationComplete=!1;this._eventsDropped=!1;this._breadcrumbFilterError=!1;this._errorFilterError=!1;var f;bt(t.stack),this._collectors.push(new q),this._collectors.push(...t.collectors),this._maxPendingEvents=t.maxPendingEvents,this._maxBreadcrumbs=t.breadcrumbs.maxBreadcrumbs,this._logger=(f=this._options.logger)!=null?f:S;let r=[oe];t.breadcrumbs.http.customUrlFilter&&r.push(t.breadcrumbs.http.customUrlFilter),t.breadcrumbs.http.instrumentFetch&&this._collectors.push(new G({urlFilters:r,getLogger:()=>this._logger})),t.breadcrumbs.http.instrumentXhr&&this._collectors.push(new z({urlFilters:r,getLogger:()=>this._logger})),t.breadcrumbs.click&&this._collectors.push(new X),t.breadcrumbs.keyboardInput&&this._collectors.push(new j),this._collectors.forEach(x=>x.register(this,this._sessionId));let n=this,i=[];ce(t,i,n),this._inspectorInstances.push(...i)}register(t){if(this._client!==void 0)return;this._client=t,this._setLogger();let r=()=>{var n;(n=this._client)==null||n.track(mt,{sessionId:this._sessionId}),this._pendingEvents.forEach(i=>{var f;(f=this._client)==null||f.track(i.type,i.data)}),this._pendingEvents=[],this._registrationComplete=!0};yt(t)?(async()=>{try{await t.waitForInitialization(gt)}catch(n){}r()})():r()}_setLogger(){this._options.logger?this._logger=this._options.logger:xt(this._client)?this._logger=this._client.logger:this._logger=S}inspectors(){return this._inspectorInstances}_capture(t,r){var i;let n=this._applyFilters(r,this._options.errorFilters,f=>{this._errorFilterError||(this._errorFilterError=!0,this._logger.warn(T(`Error applying error filters: ${f}`)))});n!==void 0&&(this._registrationComplete?(i=this._client)==null||i.track(t,n):(this._pendingEvents.push({type:t,data:n}),this._pendingEvents.length>this._maxPendingEvents&&(this._eventsDropped||(this._eventsDropped=!0,this._logger.warn(T("Maximum pending events reached. Old events will be dropped until the SDK client is registered."))),this._pendingEvents.shift())))}captureError(t){var i,f;let n=t!=null?{type:t.name||((i=t.constructor)==null?void 0:i.name)||Te,message:(f=t.message)!=null?f:pt,stack:me(t,this._options.stack),breadcrumbs:[...this._breadcrumbs],sessionId:this._sessionId}:{type:Te,message:dt,stack:{frames:[]},breadcrumbs:[...this._breadcrumbs],sessionId:this._sessionId};this._capture(ft,n)}captureErrorEvent(t){this.captureError(t.error)}_applyFilters(t,r,n){try{return r.reduce((i,f)=>ht(i,f),t)}catch(i){n(i);return}}addBreadcrumb(t){let r=this._applyFilters(t,this._options.breadcrumbs.filters,n=>{this._breadcrumbFilterError||(this._breadcrumbFilterError=!0,this._logger.warn(T(`Error applying breadcrumb filters: ${n}`)))});r!==void 0&&(this._breadcrumbs.push(r),this._breadcrumbs.length>this._maxBreadcrumbs&&this._breadcrumbs.shift())}close(){this._collectors.forEach(t=>t.unregister())}handleFlagUsed(t,r,n){let i={type:"flag-evaluated",data:{key:t,value:Se(r.value)},timestamp:new Date().getTime(),class:"feature-management",level:"info"};this.addBreadcrumb(i)}handleFlagDetailChanged(t,r){let n={type:"flag-detail-changed",data:{key:t,value:Se(r.value)},timestamp:new Date().getTime(),class:"feature-management",level:"info"};this.addBreadcrumb(n)}};var Lt={maxBreadcrumbs:0,evaluations:!1,flagChange:!1,click:!1,keyboardInput:!1,http:{instrumentFetch:!1,instrumentXhr:!1,customUrlFilter:void 0},filters:[]},vt={enabled:!1,source:{beforeLines:0,afterLines:0,maxLineLength:0}};function Et(){return{breadcrumbs:{maxBreadcrumbs:50,evaluations:!0,flagChange:!0,click:!0,keyboardInput:!0,http:{instrumentFetch:!0,instrumentXhr:!0},filters:[]},stack:{enabled:!0,source:{beforeLines:3,afterLines:3,maxLineLength:280}},maxPendingEvents:100,collectors:[],errorFilters:[]}}function U(e,t,r){return T(`Config option "${e}" should be of type ${t}, got ${r}, using default value`)}function _(e,t,r){return n=>{let i=typeof n;return i===e?!0:(r==null||r.warn(U(t,e,i)),!1)}}function v(e,t,r){return e!=null&&(!r||r(e))?e:t}function _t(e,t,r){if(e!==void 0&&e!==!1&&typeof e!="object")return r==null||r.warn(U("breadcrumbs.http","HttpBreadCrumbOptions | false",typeof e)),t;if(e===!1)return{instrumentFetch:!1,instrumentXhr:!1};e!=null&&e.customUrlFilter&&typeof e.customUrlFilter!="function"&&(r==null||r.warn(T(`The "breadcrumbs.http.customUrlFilter" must be a function. Received ${typeof e.customUrlFilter}`)));let n=e!=null&&e.customUrlFilter&&typeof(e==null?void 0:e.customUrlFilter)=="function"?e.customUrlFilter:void 0;return{instrumentFetch:v(e==null?void 0:e.instrumentFetch,t.instrumentFetch,_("boolean","breadcrumbs.http.instrumentFetch",r)),instrumentXhr:v(e==null?void 0:e.instrumentXhr,t.instrumentXhr,_("boolean","breadcrumbs.http.instrumentXhr",r)),customUrlFilter:n}}function kt(e){if(e.logger){let{logger:t}=e;if(typeof t=="object"&&t!==null&&"warn"in t)return P(t);S.warn(U("logger","MinLogger or LDLogger",typeof t))}}function Tt(e,t,r){var n,i,f;return e===!1?vt:{enabled:!0,source:{beforeLines:v((n=e==null?void 0:e.source)==null?void 0:n.beforeLines,t.source.beforeLines,_("number","stack.beforeLines",r)),afterLines:v((i=e==null?void 0:e.source)==null?void 0:i.afterLines,t.source.afterLines,_("number","stack.afterLines",r)),maxLineLength:v((f=e==null?void 0:e.source)==null?void 0:f.maxLineLength,t.source.maxLineLength,_("number","stack.maxLineLength",r))}}}function St(e,t,r){return e===!1?Lt:{maxBreadcrumbs:v(e==null?void 0:e.maxBreadcrumbs,t.maxBreadcrumbs,_("number","breadcrumbs.maxBreadcrumbs",r)),evaluations:v(e==null?void 0:e.evaluations,t.evaluations,_("boolean","breadcrumbs.evaluations",r)),flagChange:v(e==null?void 0:e.flagChange,t.flagChange,_("boolean","breadcrumbs.flagChange",r)),click:v(e==null?void 0:e.click,t.click,_("boolean","breadcrumbs.click",r)),keyboardInput:v(e==null?void 0:e.keyboardInput,t.keyboardInput,_("boolean","breadcrumbs.keyboardInput",r)),http:_t(e==null?void 0:e.http,t.http,r),filters:v(e==null?void 0:e.filters,t.filters,n=>Array.isArray(n)?!0:(r==null||r.warn(U("breadcrumbs.filters","BreadcrumbFilter[]",typeof n)),!1))}}function V(e,t){let r=Et();return e.breadcrumbs&&_("object","breadcrumbs",t)(e.breadcrumbs),e.stack&&_("object","stack",t)(e.stack),{breadcrumbs:St(e.breadcrumbs,r.breadcrumbs,t),stack:Tt(e.stack,r.stack,t),maxPendingEvents:v(e.maxPendingEvents,r.maxPendingEvents,_("number","maxPendingEvents",t)),collectors:[...v(e.collectors,r.collectors,n=>Array.isArray(n)?!0:(t==null||t.warn(U("collectors","Collector[]",typeof n)),!1))],logger:kt(e),errorFilters:v(e.errorFilters,r.errorFilters,n=>Array.isArray(n)?!0:(t==null||t.warn(U("errorFilters","ErrorDataFilter[]",typeof n)),!1))}}var Y,de=!1;function wt(e){let t=P(e==null?void 0:e.logger);if(Y){t.warn(T("Telemetry has already been initialized. Ignoring new options."));return}let r=V(e||{},t);Y=new R(r)}function O(){if(!Y){if(de)return;S.warn(T("Telemetry has not been initialized")),de=!0;return}return Y}function Ft(){Y=void 0,de=!1}function Ot(){var e;return((e=O())==null?void 0:e.inspectors())||[]}function Bt(e){var t;(t=O())==null||t.captureError(e)}function It(e){var t;(t=O())==null||t.captureErrorEvent(e)}function Rt(e){var t;(t=O())==null||t.addBreadcrumb(e)}function Dt(e){var t;(t=O())==null||t.register(e)}function Ct(){var e;(e=O())==null||e.close()}function Mt(e){let t=V(e||{},P(e==null?void 0:e.logger));return new R(t)}0&&(module.exports={addBreadcrumb,captureError,captureErrorEvent,close,getTelemetryInstance,initTelemetry,initTelemetryInstance,inspectors,register,resetTelemetryInstance});
9
+ `);let O=L.indexOf(E.innerText);O>=0&&(s.line=h+L.substring(0,O).split(`
10
+ `).length)}}}else if(l=o.exec(c[m])){let h=e.location.href.replace(/#.*$/,""),E=new RegExp(pe(c[m+1])),L=Q(E,[h]);s={url:h,func:"",args:[],line:L?L.line:l[1],column:null}}if(s){s.func||(s.func=C(s.url,s.line));let h=$(s.url,s.line);s.srcStart=h==null?void 0:h.startFromSource;let E=h==null?void 0:h.contextLines,L=E?E[Math.floor(E.length/2)]:null;E&&L&&L.replace(/^\s*/,"")===c[m+1].replace(/^\s*/,"")?s.context=E:s.context=[c[m+1]],b.push(s)}}return b.length?{mode:"multiline",name:a.name,message:c[0],stack:b}:null}function he(a,c,u,p){var b;let o={url:c,line:u};if(o.url&&o.line){if(a.incomplete=!1,o.func||(o.func=C(o.url,o.line)),!o.context){let d=$(o.url,o.line);o.context=(b=d==null?void 0:d.contextLines)!=null?b:null,o.srcStart=d==null?void 0:d.startFromSource}let g=/ '([^']+)' /.exec(p);if(g&&(o.column=re(g[1],o.url,o.line)),a.stack.length>0&&a.stack[0].url===o.url){if(a.stack[0].line===o.line)return!1;if(!a.stack[0].line&&a.stack[0].func===o.func)return a.stack[0].line=o.line,a.stack[0].context=o.context,!1}return a.stack.unshift(o),a.partial=!0,!0}return a.incomplete=!0,!1}function be(a,c){let u=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,p=[],o={},b=!1,g,d,l;for(let s=be.caller;s&&!b;s=s.caller)if(!(s===w||s===y.report)){if(d={url:null,func:n,args:[],line:null,column:null},s.name?d.func=s.name:(g=u.exec(s.toString()))&&(d.func=g[1]),typeof d.func=="undefined")try{d.func=g.input.substring(0,g.input.indexOf("{"))}catch(h){}if(l=Oe(s)){d.url=l.url,d.line=l.line,d.func===n&&(d.func=C(d.url,d.line));let h=/ '([^']+)' /.exec(a.message||a.description);h&&(d.column=re(h[1],l.url,l.line))}o[`${s}`]?b=!0:o[`${s}`]=!0,p.push(d)}c&&p.splice(0,c);let m={mode:"callers",name:a.name,message:a.message,stack:p};return he(m,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description),m}function w(a,c){let u=null;c=c==null?0:+c;try{if(u=Fe(a),u)return u}catch(p){}try{if(u=ge(a),u)return u}catch(p){}try{if(u=Be(a),u)return u}catch(p){}try{if(u=be(a,c+1),u)return u}catch(p){}return{name:a.name,message:a.message,mode:"failed",stack:[]}}function Ie(a){a=(a==null?0:+a)+1;try{throw new Error}catch(c){return w(c,a+1)}}return w.augmentStackTraceWithInitialElement=he,w.computeStackTraceFromStackProp=ge,w.guessFunctionName=C,w.gatherContext=$,w.ofCaller=Ie,w.getSource=D,w}(),y.remoteFetching||(y.remoteFetching=!0),y.collectWindowErrors||(y.collectWindowErrors=!0),(!y.linesOfContext||y.linesOfContext<1)&&(y.linesOfContext=11)})(typeof window!="undefined"?window:global);function te(){return y}var Ee="(index)";function at(e,t){let r=e;if(e.startsWith(t)){if(r=e.slice(t.length),r.startsWith("/")&&(r=r.slice(1)),r==="")return Ee;r.endsWith("/")&&(r+=Ee)}return r}function ot(e,t,r){return Math.min(t,Math.max(e,r))}function _e(e,t,r){if(t.length<=e.maxLength)return t;let n=Math.max(0,r-e.beforeColumnCharacters),i=Math.min(t.length,n+e.maxLength);return t.slice(n,i)}function ke(e,t,r,n){let i=e<0?0:e,f=t>r.length?r.length:t;return i<f?r.slice(i,f).map(n):[]}function ct(e,t){var k,B;let{context:r}=e;if(!r)return{};let{maxLineLength:n}=t.source,i=Math.floor(n/2),f=I=>_e({maxLength:t.source.maxLineLength,beforeColumnCharacters:i},I,0),x=ot(0,r.length-1,((k=e==null?void 0:e.line)!=null?k:0)-((B=e.srcStart)!=null?B:0));return{srcBefore:ke(x-t.source.beforeLines,x,r,f),srcLine:_e({maxLength:n,beforeColumnCharacters:i},r[x],e.column||0),srcAfter:ke(x+1,x+1+t.source.afterLines,r,f)}}function me(e,t){return t.enabled?{frames:te().computeStackTrace(e).stack.reverse().map(i=>{var f,x;return{fileName:at(i.url,window.location.origin),function:i.func,line:(f=i.line)!=null?f:void 0,col:(x=i.column)!=null?x:void 0,...ct(i,t)}})}:{frames:[]}}var we="$ld:telemetry",ut=`${we}:error`,lt=`${we}:session:init`,Te="generic",ft="exception was null or undefined",mt="exception had no message",dt=5;function Se(e){switch(typeof e){case"string":case"boolean":case"number":return e;default:return}}function pt(e,t){return e===void 0?void 0:t(e)}function gt(e){if(!e.enabled)return;let t=te(),r=Math.max(e.source.afterLines,e.source.beforeLines),n=t;n.linesOfContext=r*2+1}function ht(e){return e.logger!==void 0}function bt(e){return e.waitForInitialization!==void 0}var R=class{constructor(t){this._options=t;this._pendingEvents=[];this._breadcrumbs=[];this._inspectorInstances=[];this._collectors=[];this._sessionId=fe();this._registrationComplete=!1;this._eventsDropped=!1;this._breadcrumbFilterError=!1;this._errorFilterError=!1;var f;gt(t.stack),this._collectors.push(new q),this._collectors.push(...t.collectors),this._maxPendingEvents=t.maxPendingEvents,this._maxBreadcrumbs=t.breadcrumbs.maxBreadcrumbs,this._logger=(f=this._options.logger)!=null?f:S;let r=[oe];t.breadcrumbs.http.customUrlFilter&&r.push(t.breadcrumbs.http.customUrlFilter),t.breadcrumbs.http.instrumentFetch&&this._collectors.push(new G({urlFilters:r,getLogger:()=>this._logger})),t.breadcrumbs.http.instrumentXhr&&this._collectors.push(new z({urlFilters:r,getLogger:()=>this._logger})),t.breadcrumbs.click&&this._collectors.push(new X),t.breadcrumbs.keyboardInput&&this._collectors.push(new j),this._collectors.forEach(x=>x.register(this,this._sessionId));let n=this,i=[];ce(t,i,n),this._inspectorInstances.push(...i)}register(t){if(this._client!==void 0)return;this._client=t,this._setLogger();let r=()=>{var n;(n=this._client)==null||n.track(lt,{sessionId:this._sessionId}),this._pendingEvents.forEach(i=>{var f;(f=this._client)==null||f.track(i.type,i.data)}),this._pendingEvents=[],this._registrationComplete=!0};bt(t)?(async()=>{try{await t.waitForInitialization(dt)}catch(n){}r()})():r()}_setLogger(){this._options.logger?this._logger=this._options.logger:ht(this._client)?this._logger=this._client.logger:this._logger=S}inspectors(){return this._inspectorInstances}_capture(t,r){var i;let n=this._applyFilters(r,this._options.errorFilters,f=>{this._errorFilterError||(this._errorFilterError=!0,this._logger.warn(T(`Error applying error filters: ${f}`)))});n!==void 0&&(this._registrationComplete?(i=this._client)==null||i.track(t,n):(this._pendingEvents.push({type:t,data:n}),this._pendingEvents.length>this._maxPendingEvents&&(this._eventsDropped||(this._eventsDropped=!0,this._logger.warn(T("Maximum pending events reached. Old events will be dropped until the SDK client is registered."))),this._pendingEvents.shift())))}captureError(t){var i,f;let n=t!=null?{type:t.name||((i=t.constructor)==null?void 0:i.name)||Te,message:(f=t.message)!=null?f:mt,stack:me(t,this._options.stack),breadcrumbs:[...this._breadcrumbs],sessionId:this._sessionId}:{type:Te,message:ft,stack:{frames:[]},breadcrumbs:[...this._breadcrumbs],sessionId:this._sessionId};this._capture(ut,n)}captureErrorEvent(t){this.captureError(t.error)}_applyFilters(t,r,n){try{return r.reduce((i,f)=>pt(i,f),t)}catch(i){n(i);return}}addBreadcrumb(t){let r=this._applyFilters(t,this._options.breadcrumbs.filters,n=>{this._breadcrumbFilterError||(this._breadcrumbFilterError=!0,this._logger.warn(T(`Error applying breadcrumb filters: ${n}`)))});r!==void 0&&(this._breadcrumbs.push(r),this._breadcrumbs.length>this._maxBreadcrumbs&&this._breadcrumbs.shift())}close(){this._collectors.forEach(t=>t.unregister())}handleFlagUsed(t,r,n){let i={type:"flag-evaluated",data:{key:t,value:Se(r.value)},timestamp:new Date().getTime(),class:"feature-management",level:"info"};this.addBreadcrumb(i)}handleFlagDetailChanged(t,r){let n={type:"flag-detail-changed",data:{key:t,value:Se(r.value)},timestamp:new Date().getTime(),class:"feature-management",level:"info"};this.addBreadcrumb(n)}};var xt={maxBreadcrumbs:0,evaluations:!1,flagChange:!1,click:!1,keyboardInput:!1,http:{instrumentFetch:!1,instrumentXhr:!1,customUrlFilter:void 0},filters:[]},yt={enabled:!1,source:{beforeLines:0,afterLines:0,maxLineLength:0}};function Lt(){return{breadcrumbs:{maxBreadcrumbs:50,evaluations:!0,flagChange:!0,click:!0,keyboardInput:!0,http:{instrumentFetch:!0,instrumentXhr:!0},filters:[]},stack:{enabled:!0,source:{beforeLines:3,afterLines:3,maxLineLength:280}},maxPendingEvents:100,collectors:[],errorFilters:[]}}function U(e,t,r){return T(`Config option "${e}" should be of type ${t}, got ${r}, using default value`)}function _(e,t,r){return n=>{let i=typeof n;return i===e?!0:(r==null||r.warn(U(t,e,i)),!1)}}function v(e,t,r){return e!=null&&(!r||r(e))?e:t}function vt(e,t,r){if(e!==void 0&&e!==!1&&typeof e!="object")return r==null||r.warn(U("breadcrumbs.http","HttpBreadCrumbOptions | false",typeof e)),t;if(e===!1)return{instrumentFetch:!1,instrumentXhr:!1};e!=null&&e.customUrlFilter&&typeof e.customUrlFilter!="function"&&(r==null||r.warn(T(`The "breadcrumbs.http.customUrlFilter" must be a function. Received ${typeof e.customUrlFilter}`)));let n=e!=null&&e.customUrlFilter&&typeof(e==null?void 0:e.customUrlFilter)=="function"?e.customUrlFilter:void 0;return{instrumentFetch:v(e==null?void 0:e.instrumentFetch,t.instrumentFetch,_("boolean","breadcrumbs.http.instrumentFetch",r)),instrumentXhr:v(e==null?void 0:e.instrumentXhr,t.instrumentXhr,_("boolean","breadcrumbs.http.instrumentXhr",r)),customUrlFilter:n}}function Et(e){if(e.logger){let{logger:t}=e;if(typeof t=="object"&&t!==null&&"warn"in t)return P(t);S.warn(U("logger","MinLogger or LDLogger",typeof t))}}function _t(e,t,r){var n,i,f;return e===!1?yt:{enabled:!0,source:{beforeLines:v((n=e==null?void 0:e.source)==null?void 0:n.beforeLines,t.source.beforeLines,_("number","stack.beforeLines",r)),afterLines:v((i=e==null?void 0:e.source)==null?void 0:i.afterLines,t.source.afterLines,_("number","stack.afterLines",r)),maxLineLength:v((f=e==null?void 0:e.source)==null?void 0:f.maxLineLength,t.source.maxLineLength,_("number","stack.maxLineLength",r))}}}function kt(e,t,r){return e===!1?xt:{maxBreadcrumbs:v(e==null?void 0:e.maxBreadcrumbs,t.maxBreadcrumbs,_("number","breadcrumbs.maxBreadcrumbs",r)),evaluations:v(e==null?void 0:e.evaluations,t.evaluations,_("boolean","breadcrumbs.evaluations",r)),flagChange:v(e==null?void 0:e.flagChange,t.flagChange,_("boolean","breadcrumbs.flagChange",r)),click:v(e==null?void 0:e.click,t.click,_("boolean","breadcrumbs.click",r)),keyboardInput:v(e==null?void 0:e.keyboardInput,t.keyboardInput,_("boolean","breadcrumbs.keyboardInput",r)),http:vt(e==null?void 0:e.http,t.http,r),filters:v(e==null?void 0:e.filters,t.filters,n=>Array.isArray(n)?!0:(r==null||r.warn(U("breadcrumbs.filters","BreadcrumbFilter[]",typeof n)),!1))}}function V(e,t){let r=Lt();return e.breadcrumbs&&_("object","breadcrumbs",t)(e.breadcrumbs),e.stack&&_("object","stack",t)(e.stack),{breadcrumbs:kt(e.breadcrumbs,r.breadcrumbs,t),stack:_t(e.stack,r.stack,t),maxPendingEvents:v(e.maxPendingEvents,r.maxPendingEvents,_("number","maxPendingEvents",t)),collectors:[...v(e.collectors,r.collectors,n=>Array.isArray(n)?!0:(t==null||t.warn(U("collectors","Collector[]",typeof n)),!1))],logger:Et(e),errorFilters:v(e.errorFilters,r.errorFilters,n=>Array.isArray(n)?!0:(t==null||t.warn(U("errorFilters","ErrorDataFilter[]",typeof n)),!1))}}var Y,de=!1;function Tt(e){let t=P(e==null?void 0:e.logger);if(Y){t.warn(T("Telemetry has already been initialized. Ignoring new options."));return}let r=V(e||{},t);Y=new R(r)}function F(){if(!Y){if(de)return;S.warn(T("Telemetry has not been initialized")),de=!0;return}return Y}function St(){Y=void 0,de=!1}function wt(){var e;return((e=F())==null?void 0:e.inspectors())||[]}function Ot(e){var t;(t=F())==null||t.captureError(e)}function Ft(e){var t;(t=F())==null||t.captureErrorEvent(e)}function Bt(e){var t;(t=F())==null||t.addBreadcrumb(e)}function It(e){var t;(t=F())==null||t.register(e)}function Rt(){var e;(e=F())==null||e.close()}function Dt(e){let t=V(e||{},P(e==null?void 0:e.logger));return new R(t)}0&&(module.exports={addBreadcrumb,captureError,captureErrorEvent,close,getTelemetryInstance,initTelemetry,initTelemetryInstance,inspectors,register,resetTelemetryInstance});
11
11
  /**
12
12
  * https://github.com/csnover/TraceKit
13
13
  * @license MIT