@sailfish-ai/sf-veritas 0.1.17 → 0.1.19

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/README.md CHANGED
@@ -10,7 +10,7 @@ To install from our repository, you need to configure your `npm` or `yarn` regis
10
10
 
11
11
  ```bash
12
12
  // Add this to your .npmrc
13
- @sailfishai:registry=https://us-npm.pkg.dev/futureself-world/sailfishai-npm/
13
+ @sailfishai:registry=https://us-npm.pkg.dev/sailfish-ai/sailfishai-npm/
14
14
  ```
15
15
 
16
16
  #### Install the Package
@@ -81,6 +81,7 @@ export async function register() {
81
81
  const { setupInterceptors } = await import("@sailfish/sf-veritas");
82
82
 
83
83
  setupInterceptors({
84
+ apiKey: "test-api-key",
84
85
  serviceIdentifier: "your-service-name",
85
86
  serviceVersion: "1.0.0",
86
87
  serviceAdditionalMetadata: {
@@ -102,5 +103,4 @@ export async function register() {
102
103
  }
103
104
  }
104
105
  }
105
-
106
106
  ```
@@ -1,4 +1,4 @@
1
- "use strict";var E=Object.defineProperty;var L=(r,e,i)=>e in r?E(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i;var g=(r,e,i)=>L(r,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("async_hooks"),F=require("worker_threads"),p=[];for(let r=0;r<256;++r)p.push((r+256).toString(16).slice(1));let Y;const z=new Uint8Array(16),X={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function J(r,e,i){if(X.randomUUID&&!r)return X.randomUUID();const t=(r=r||{}).random??r.rng?.()??function(){if(!Y){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Y=crypto.getRandomValues.bind(crypto)}return Y(z)}();if(t.length<16)throw new Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(n,s=0){return(p[n[s+0]]+p[n[s+1]]+p[n[s+2]]+p[n[s+3]]+"-"+p[n[s+4]]+p[n[s+5]]+"-"+p[n[s+6]]+p[n[s+7]]+"-"+p[n[s+8]]+p[n[s+9]]+"-"+p[n[s+10]]+p[n[s+11]]+p[n[s+12]]+p[n[s+13]]+p[n[s+14]]+p[n[s+15]]).toLowerCase()}(t)}class T{constructor(e){g(this,"apiKey");g(this,"apiGraphqlEndpoint");g(this,"sfDebug");g(this,"serviceIdentifier");g(this,"serviceVersion");g(this,"serviceUUID");g(this,"serviceAdditionalMetadata");g(this,"profilingModeEnabled");g(this,"profilingMaxDepth");g(this,"profilingMaxVariableSizeKb");g(this,"domainsToNotPropagateHeadersTo");g(this,"nodeModulesToCollectLocalVariablesOn");g(this,"printConfigurationStatuses");g(this,"logLevel");g(this,"stackDepthLocals");g(this,"stackDepthCodeTraceDepth");g(this,"packageLibraryType");g(this,"version");g(this,"_serviceIdentificationReceived",!1);this.apiKey=e?.apiKey||process.env.SAILFISH_API_KEY,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=J(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||[],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="NEXT JS/TS",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}let f;function o(){if(!f)throw new Error("Configuration has not been initialized. Please call initializeConfig() before using getConfig().");return f}new U.AsyncLocalStorage;const H=new U.AsyncLocalStorage,R={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1},y=class y{constructor(){}static getInstance(){return y.instance||(y.instance=new y),y.instance}getCurrentContext(){return H.getStore()||R}setCurrentContext(e){const i=H.getStore()||R;H.enterWith({...i,...e})}getTraceId(){return this.getCurrentContext().traceId}setTraceId(e){this.setCurrentContext({traceId:e})}getOrSetSfTraceId(e,i=!1){let t=this.getTraceId();return t||(t=e||(i?J():`nonsession-applogs-v3/${o().apiKey}/${J()}`),this.setTraceId(t),o().sfDebug&&console.log(" Created new trace ID:",t),t)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const i=this.getHandledExceptions();i.add(e),this.setCurrentContext({handledExceptions:i})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}};g(y,"instance");let W=y;class B{constructor(){g(this,"apiKey");g(this,"endpoint");g(this,"queryType","mutation");g(this,"operationName","");g(this,"serviceUUID",o().serviceUUID);g(this,"contextManager");this.apiKey=o().apiKey,this.endpoint=o().apiGraphqlEndpoint,this.contextManager=W.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const e=Date.now().toString(),i=this.contextManager.getOrSetSfTraceId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:i,timestampMs:e}}getVariables(e={}){return{...this.getDefaultVariables(),...e}}setOperationName(e){this.operationName=e}setEndpoint(e){this.endpoint=e}setServiceUUID(e){this.serviceUUID=e}}const $=fetch;async function Z(r,e,i,t){try{const n=o();let s;try{s=JSON.stringify({query:i,variables:t,operationName:e})}catch{s=JSON.stringify({query:i,operationName:e})}$(r,{method:"POST",headers:{"Content-Type":"application/json"},body:s}).then(async c=>{if(!c.ok)return void(n.sfDebug&&console.error(`GraphQL request failed with status ${c.status} for ${e}`));const l=await c.json();l.errors?.length?function(a,A,C){const d=a&&typeof a=="object"&&!Array.isArray(a)?Object.keys(a)[0]:void 0;console.error(d==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${C.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(A)} for operation key ${d}`)}(l.data,l.errors,n):n.sfDebug&&function(a,A,C){const d=a&&typeof a=="object"&&!Array.isArray(a)?Object.keys(a)[0]:void 0,I=a[d]||!1;d==="identifyServiceDetails"&&(C.setServiceIdentificationReceived(I),o().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${C.serviceUUID}; serviceIdentificationReceived=${d==="identifyServiceDetails"?I:"N/A"}`))}(l.data,0,n)}).catch(c=>{n.sfDebug&&console.error("Fetch error:",c)})}catch(n){o().sfDebug&&console.error("Error sending data to GraphQL server:",n)}}class w extends B{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(e){if(!o().serviceIdentificationReceived)try{this.send()}catch(i){o().sfDebug&&console.error(" Error during service identification:",i)}}async send(){const e=`
1
+ "use strict";var E=Object.defineProperty;var L=(o,e,i)=>e in o?E(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i;var c=(o,e,i)=>L(o,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("async_hooks"),F=require("worker_threads"),A=[];for(let o=0;o<256;++o)A.push((o+256).toString(16).slice(1));let Y;const T=new Uint8Array(16),X={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function J(o,e,i){if(X.randomUUID&&!o)return X.randomUUID();const t=(o=o||{}).random??o.rng?.()??function(){if(!Y){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Y=crypto.getRandomValues.bind(crypto)}return Y(T)}();if(t.length<16)throw new Error("Random bytes length must be >= 16");return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(n,s=0){return(A[n[s+0]]+A[n[s+1]]+A[n[s+2]]+A[n[s+3]]+"-"+A[n[s+4]]+A[n[s+5]]+"-"+A[n[s+6]]+A[n[s+7]]+"-"+A[n[s+8]]+A[n[s+9]]+"-"+A[n[s+10]]+A[n[s+11]]+A[n[s+12]]+A[n[s+13]]+A[n[s+14]]+A[n[s+15]]).toLowerCase()}(t)}class z{constructor(e){c(this,"apiKey");c(this,"apiGraphqlEndpoint");c(this,"sfDebug");c(this,"serviceIdentifier");c(this,"serviceVersion");c(this,"serviceUUID");c(this,"serviceAdditionalMetadata");c(this,"profilingModeEnabled");c(this,"profilingMaxDepth");c(this,"profilingMaxVariableSizeKb");c(this,"domainsToNotPropagateHeadersTo");c(this,"nodeModulesToCollectLocalVariablesOn");c(this,"printConfigurationStatuses");c(this,"logLevel");c(this,"stackDepthLocals");c(this,"stackDepthCodeTraceDepth");c(this,"packageLibraryType");c(this,"version");c(this,"_serviceIdentificationReceived",!1);this.apiKey=e.apiKey,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=J(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||[],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="NEXT JS/TS",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}let G;function r(){if(!G)throw new Error("Configuration has not been initialized.");return G}new U.AsyncLocalStorage;const H=new U.AsyncLocalStorage,R={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1},y=class y{constructor(){}static getInstance(){return y.instance||(y.instance=new y),y.instance}getCurrentContext(){return H.getStore()||R}setCurrentContext(e){const i=H.getStore()||R;H.enterWith({...i,...e})}getTraceId(){return this.getCurrentContext().traceId}setTraceId(e){this.setCurrentContext({traceId:e})}getOrSetSfTraceId(e,i=!1){let t=this.getTraceId();return t||(t=e||(i?J():`nonsession-applogs-v3/${r().apiKey}/${J()}`),this.setTraceId(t),r().sfDebug&&console.log(" Created new trace ID:",t),t)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const i=this.getHandledExceptions();i.add(e),this.setCurrentContext({handledExceptions:i})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}};c(y,"instance");let W=y;class S{constructor(){c(this,"apiKey");c(this,"endpoint");c(this,"queryType","mutation");c(this,"operationName","");c(this,"serviceUUID",r().serviceUUID);c(this,"contextManager");this.apiKey=r().apiKey,this.endpoint=r().apiGraphqlEndpoint,this.contextManager=W.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const e=Date.now().toString(),i=this.contextManager.getOrSetSfTraceId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:i,timestampMs:e}}getVariables(e={}){return{...this.getDefaultVariables(),...e}}setOperationName(e){this.operationName=e}setEndpoint(e){this.endpoint=e}setServiceUUID(e){this.serviceUUID=e}}const $=fetch;async function Z(o,e,i,t){try{const n=r();let s;try{s=JSON.stringify({query:i,variables:t,operationName:e})}catch{s=JSON.stringify({query:i,operationName:e})}$(o,{method:"POST",headers:{"Content-Type":"application/json"},body:s}).then(async a=>{if(!a.ok)return void(n.sfDebug&&console.error(`GraphQL request failed with status ${a.status} for ${e}`));const d=await a.json();d.errors?.length?function(I,C,l){const g=I&&typeof I=="object"&&!Array.isArray(I)?Object.keys(I)[0]:void 0;console.error(g==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${l.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(C)} for operation key ${g}`)}(d.data,d.errors,n):n.sfDebug&&function(I,C,l){const g=I&&typeof I=="object"&&!Array.isArray(I)?Object.keys(I)[0]:void 0,p=I[g]||!1;g==="identifyServiceDetails"&&(l.setServiceIdentificationReceived(p),r().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${l.serviceUUID}; serviceIdentificationReceived=${g==="identifyServiceDetails"?p:"N/A"}`))}(d.data,0,n)}).catch(a=>{n.sfDebug&&console.error("Fetch error:",a)})}catch(n){r().sfDebug&&console.error("Error sending data to GraphQL server:",n)}}class w extends S{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(e){if(!r().serviceIdentificationReceived)try{this.send()}catch(i){r().sfDebug&&console.error(" Error during service identification:",i)}}async send(){const e=`
2
2
  ${this.queryType} ${this.operationName}(
3
3
  $apiKey: String!,
4
4
  $timestampMs: String!,
@@ -20,17 +20,17 @@
20
20
  version: $version,
21
21
  )
22
22
  }
23
- `,i=this.getVariables({serviceIdentifier:o().serviceIdentifier,serviceVersion:o().serviceVersion,library:o().packageLibraryType,version:o().version,serviceAdditionalMetadata:o().serviceAdditionalMetadata});Z(this.endpoint,this.operationName,e,i)}}function k(r){try{return JSON.stringify(r),!0}catch{return!1}}class O extends B{constructor(){super();g(this,"serviceIdentifier",new w);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(i,t,n,s){this.sendAppIdentifier(),this.send(i,t,n,s)}async send(i,t,n,s){if(!t&&!s)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let c=[];if(!s){const a=function(A){const C={},d=[];if(A)for(const[I,u]of Object.entries(A))k(u)?C[I]=u:d.push(I);return{traitsJson:JSON.stringify(C),excludedFields:d}}(t);s=a.traitsJson,c=a.excludedFields}const l=this.getVariables({userId:i,traitsJson:s,excludedFields:c,override:n,library:o().packageLibraryType,version:o().version});Z(this.endpoint,this.operationName,this.getQuery(),l)}getQuery(){return`
23
+ `,i=this.getVariables({serviceIdentifier:r().serviceIdentifier,serviceVersion:r().serviceVersion,library:r().packageLibraryType,version:r().version,serviceAdditionalMetadata:r().serviceAdditionalMetadata});Z(this.endpoint,this.operationName,e,i)}}function k(o){try{return JSON.stringify(o),!0}catch{return!1}}class O extends S{constructor(){super();c(this,"serviceIdentifier",new w);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(i,t,n,s){this.sendAppIdentifier(),this.send(i,t,n,s)}async send(i,t,n,s){if(!t&&!s)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let a=[];if(!s){const I=function(C){const l={},g=[];if(C)for(const[p,h]of Object.entries(C))k(h)?l[p]=h:g.push(p);return{traitsJson:JSON.stringify(l),excludedFields:g}}(t);s=I.traitsJson,a=I.excludedFields}const d=this.getVariables({userId:i,traitsJson:s,excludedFields:a,override:n,library:r().packageLibraryType,version:r().version});Z(this.endpoint,this.operationName,this.getQuery(),d)}getQuery(){return`
24
24
  mutation ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $userId: String!, $traitsJson: String!, $excludedFields: [String!]!, $library: String!, $timestampMs: String!, $version: String!, $override: Boolean!) {
25
25
  ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, userId: $userId, traitsJson: $traitsJson, excludedFields: $excludedFields, library: $library, timestampMs: $timestampMs, version: $version, override: $override)
26
26
  }
27
- `}}class D{constructor(e){g(this,"metadataTransmitter");this.apiKey=e,this.metadataTransmitter=new O}identify(e,i,t,n=!1){i||t?this.addOrUpdateMetadata(e,i,t,n):this.addOrUpdateMetadata(e,{},void 0,n)}addOrUpdateMetadata(e,i={},t,n=!1){if(!i&&!t)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');o().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),o().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",e,i,t),this.metadataTransmitter.doSend(e,i,n,t)}}class K extends B{constructor(){super();g(this,"serviceIdentifier",new w)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(i){this.sendAppIdentifier(),this.send(i)}async send(i){try{const t=Array.isArray(i)?i:[i,"default"],n=this.getVariables({contents:t[0],level:t[1]});Z(this.endpoint,this.operationName,this.getQuery(),n)}catch(t){o().sfDebug&&console.error("🚨 Error in send():",t)}}getQuery(){return`
27
+ `}}class D{constructor(e){c(this,"metadataTransmitter");this.apiKey=e,this.metadataTransmitter=new O}identify(e,i,t,n=!1){i||t?this.addOrUpdateMetadata(e,i,t,n):this.addOrUpdateMetadata(e,{},void 0,n)}addOrUpdateMetadata(e,i={},t,n=!1){if(!i&&!t)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');r().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),r().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",e,i,t),this.metadataTransmitter.doSend(e,i,n,t)}}class K extends S{constructor(){super();c(this,"serviceIdentifier",new w)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(i){this.sendAppIdentifier(),this.send(i)}async send(i){try{const t=Array.isArray(i)?i:[i,"default"],n=this.getVariables({contents:t[0],level:t[1]});Z(this.endpoint,this.operationName,this.getQuery(),n)}catch(t){r().sfDebug&&console.error("🚨 Error in send():",t)}}getQuery(){return`
28
28
  ${this.queryType} ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $timestampMs: String!, $level: String!, $contents: String!) {
29
29
  ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, timestampMs: $timestampMs, level: $level, contents: $contents)
30
30
  }
31
- `}}class N{constructor({file:e,line:i,function:t,code:n,locals:s={},offender:c=!1}){g(this,"file");g(this,"line");g(this,"function");g(this,"code");g(this,"locals");g(this,"offender");this.file=e,this.line=i,this.function=t,this.code=n,this.locals=s,this.offender=c}toDict(){const e={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([i,t])=>[i,String(t)]))};return this.offender&&(e.offender=this.offender),e}toJson(){return JSON.stringify(this.toDict())}}class S{static encode(e){return e instanceof N?e.toDict():Array.isArray(e)?e.map(i=>S.encode(i)):typeof e=="object"&&e!==null?JSON.stringify(e):e}static stringify(e){return JSON.stringify(S.encode(e),(i,t)=>t instanceof N?t.toDict():t)}}let v=0;function M(r){o().sfDebug&&console.log("Initializing Exception Interceptor...");const e=new F.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5lcnJvcklkID0gdW5kZWZpbmVkOwpnbG9iYWwubm9kZU1vZHVsZXNUb0NvbGxlY3RMb2NhbFZhcmlhYmxlc09uID0gdW5kZWZpbmVkOwoKLyoqCiAqIEhhbmRsZXMgdGhlICJwYXVzZWQiIHN0YXRlIG9mIHRoZSBkZWJ1Z2dlciBhbmQgcHJvY2Vzc2VzIGV4Y2VwdGlvbnMgb3IgcHJvbWlzZSByZWplY3Rpb25zLgogKiBAcGFyYW0ge1Nlc3Npb259IHNlc3Npb24gLSBUaGUgZGVidWdnaW5nIHNlc3Npb24gaW5zdGFuY2UuCiAqIEBwYXJhbSB7b2JqZWN0fSBwYXJhbXMgLSBQYXJhbWV0ZXJzIGZyb20gdGhlICJwYXVzZWQiIGV2ZW50LgogKi8KYXN5bmMgZnVuY3Rpb24gaGFuZGxlU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gICAgICAgICk7CiAgICAgICAgICAgIGNvbnN0IHNvdXJjZUxpbmVzID0gc2NyaXB0U291cmNlLnNwbGl0KCJcbiIpOwogICAgICAgICAgICBjb2RlID0gc291cmNlTGluZXNbbG9jYXRpb24ubGluZU51bWJlcl0gfHwgIjxub3QgY2FwdHVyZWQ+IjsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBGYWlsZWQgdG8gZmV0Y2ggc2NyaXB0IHNvdXJjZToiLCBlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBjb25zdCBsb2NhbHMgPSBsb2NhbFNjb3BlPy5vYmplY3Q/Lm9iamVjdElkCiAgICAgICAgICA/IGF3YWl0IGZldGNoTG9jYWxWYXJpYWJsZXMoc2Vzc2lvbiwgbG9jYWxTY29wZS5vYmplY3Qub2JqZWN0SWQpCiAgICAgICAgICA6IHt9OwoKICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246IGZ1bmN0aW9uTmFtZSB8fCAiPGFub255bW91cz4iLAogICAgICAgICAgbG9jYWxzLAogICAgICAgICAgZmlsZSwKICAgICAgICAgIGxpbmU6IGxvY2F0aW9uPy5saW5lTnVtYmVyIHx8IDAsCiAgICAgICAgICBjb2RlLAogICAgICAgIH07CiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBFcnJvciBwcm9jZXNzaW5nIGNhbGwgZnJhbWU6IiwgZXJyb3IpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246ICI8ZXJyb3I+IiwKICAgICAgICAgIGxvY2Fsczoge30sCiAgICAgICAgICBmaWxlOiAiPHVua25vd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wuc2ZEZWJ1ZykgewogICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIHN0YXJ0IGRlYnVnZ2VyOiIsIGVycm9yKTsKICB9Cn0pOwoKLy8gS2VlcCB0aGUgd29ya2VyIGFsaXZlCnNldEludGVydmFsKCgpID0+IHt9LCAxMDAwMCk7Cg=="),{workerData:{captureAllExceptions:!0}});let i=null;e.on("message",c=>{if(typeof c=="string"&&o().sfDebug&&console.log(`[Worker] ${c}`),c.readyToGetParameters&&e.postMessage({sfDebug:o().sfDebug,stackDepthLocals:o().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:o().nodeModulesToCollectLocalVariablesOn}),c.type==="exception"){const{frames:l}=c,a=i;if(!a)return;const A=function(C,d){const I=[];let u=-1,G=-1;for(let b=0;b<C.length;b++){const m=P(C[b].file);if(G=b,m!=="<unknown>"){for(let h=0;h<d.length;h++){const V=d[h];if(x(V,m)||typeof V.file=="string"&&V.file.includes(m)){u=h,v=0,o().sfDebug&&console.log(`✅ Matched Frame Found: ${m} @ Debugger Frame ${h}`);break}}if(u!==-1)break}}if(u===-1)return v===10?(v=0,C):(++v,o().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${v}"`),[]);o().sfDebug&&console.log(`🔄 Merging from matched index ${u} onward...`);for(let b=0;b<d.length;b++){const m=C[G+b],h=d[u+b];I.push(new N({function:h?.function||m?.function||"<anonymous>",locals:h?.locals||m?.locals||{},file:m?.file||h?.file||"<unknown>",line:h?.line||m?.line||0,code:m?.code||h?.code||"<not captured>"}))}return I}(function(C){return C?C.split(`
32
- `).slice(1).map(d=>{const I=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(d)||/at (.+):(\d+):(\d+)/.exec(d);if(I){const[,u,G,b]=I;return new N({function:u||"<anonymous>",locals:{},file:G||"<unknown>",line:parseInt(b,10)||0,code:"<not captured>"})}return new N({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>"})}):[]}(a.stack),l||[]);if(A.length!==0){i=null;const C=o().stackDepthCodeTraceDepth,d=C===-1?A:A.slice(0,C+1);r.setOperationName("CollectExceptions");const I=a.message?`${a.name}: ${a.message}`:a.name;o().sfDebug&&console.log("error message is : ",I),r.doSend(I,d)}}}),e.on("error",c=>{console.error("[Worker Error]",c)}),e.on("exit",c=>{console.error(`[Worker] Exited with code ${c}`)}),e.unref();const t=Error,n=new Set;function s(...c){const l=Reflect.construct(t,c);Reflect.setPrototypeOf(l,s.prototype),t.captureStackTrace&&t.captureStackTrace(l,s);const a=`${l.message}:${l.stack?.split(`
33
- `)[1]?.trim()}`;return n.has(a)||(n.add(a),i=l,e.postMessage({type:"processException",error:l.message})),l}s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(s,t),globalThis.Error=s}function P(r){return r?.split("/").pop()||"<unknown>"}function x(r,e){if(!r||typeof r!="object")return!1;for(const i of Object.values(r))if(typeof i=="string"&&i.includes(e)||typeof i=="object"&&x(i,e))return!0;return!1}class j extends B{constructor(){super();g(this,"serviceIdentifier",new w);this.setOperationName("CollectExceptions")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(i,t){this.sendAppIdentifier(),this.send(i,t)}async send(i,t){o().sfDebug&&console.log(" SENDING EXCEPTION...");const n=JSON.stringify(S.encode(t)),s=this.getVariables({exceptionMessage:i,traceJson:n,reentrancyGuardPreactive:!1,library:o().packageLibraryType,version:o().version});Z(this.endpoint,this.operationName,this.getQuery(),s)}getQuery(){return`
31
+ `}}class f{constructor({file:e,line:i,function:t,code:n,locals:s={},offender:a=!1}){c(this,"file");c(this,"line");c(this,"function");c(this,"code");c(this,"locals");c(this,"offender");this.file=e,this.line=i,this.function=t,this.code=n,this.locals=s,this.offender=a}toDict(){const e={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([i,t])=>[i,String(t)]))};return this.offender&&(e.offender=this.offender),e}toJson(){return JSON.stringify(this.toDict())}}class B{static encode(e){return e instanceof f?e.toDict():Array.isArray(e)?e.map(i=>B.encode(i)):typeof e=="object"&&e!==null?JSON.stringify(e):e}static stringify(e){return JSON.stringify(B.encode(e),(i,t)=>t instanceof f?t.toDict():t)}}let v=0;function M(o){r().sfDebug&&console.log("Initializing Exception Interceptor...");const e=new F.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5lcnJvcklkID0gdW5kZWZpbmVkOwpnbG9iYWwubm9kZU1vZHVsZXNUb0NvbGxlY3RMb2NhbFZhcmlhYmxlc09uID0gdW5kZWZpbmVkOwoKLyoqCiAqIEhhbmRsZXMgdGhlICJwYXVzZWQiIHN0YXRlIG9mIHRoZSBkZWJ1Z2dlciBhbmQgcHJvY2Vzc2VzIGV4Y2VwdGlvbnMgb3IgcHJvbWlzZSByZWplY3Rpb25zLgogKiBAcGFyYW0ge1Nlc3Npb259IHNlc3Npb24gLSBUaGUgZGVidWdnaW5nIHNlc3Npb24gaW5zdGFuY2UuCiAqIEBwYXJhbSB7b2JqZWN0fSBwYXJhbXMgLSBQYXJhbWV0ZXJzIGZyb20gdGhlICJwYXVzZWQiIGV2ZW50LgogKi8KYXN5bmMgZnVuY3Rpb24gaGFuZGxlUGF1c2VkKHNlc3Npb24sIHBhcmFtcykgewogIGNvbnN0IHsgcmVhc29uLCBkYXRhLCBjYWxsRnJhbWVzIH0gPSBwYXJhbXM7CgogIGlmIChyZWFzb24gIT09ICJleGNlcHRpb24iICYmIHJlYXNvbiAhPT0gInByb21pc2VSZWplY3Rpb24iKSB7Ci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AgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBGYWlsZWQgdG8gZmV0Y2ggc2NyaXB0IHNvdXJjZToiLCBlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBjb25zdCBsb2NhbHMgPSBsb2NhbFNjb3BlPy5vYmplY3Q/Lm9iamVjdElkCiAgICAgICAgICA/IGF3YWl0IGZldGNoTG9jYWxWYXJpYWJsZXMoc2Vzc2lvbiwgbG9jYWxTY29wZS5vYmplY3Qub2JqZWN0SWQpCiAgICAgICAgICA6IHt9OwoKICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246IGZ1bmN0aW9uTmFtZSB8fCAiPGFub255bW91cz4iLAogICAgICAgICAgbG9jYWxzLAogICAgICAgICAgZmlsZSwKICAgICAgICAgIGxpbmU6IGxvY2F0aW9uPy5saW5lTnVtYmVyIHx8IDAsCiAgICAgICAgICBjb2RlLAogICAgICAgIH07CiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBFcnJvciBwcm9jZXNzaW5nIGNhbGwgZnJhbWU6IiwgZXJyb3IpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246ICI8ZXJyb3I+IiwKICAgICAgICAgIGxvY2Fsczoge30sCiAgICAgICAgICBmaWxlOiAiPHVua25vd24+IiwKICAgICAgICAgIGxpbmU6IDAsCiAgICAgICAgICBjb2RlOiAiPG5vdCBjYXB0dXJlZD4iLAogICAgICAgIH07CiAgICAgIH0KICAgIH0pLAogICk7CgogIC8vIFBvc3QgZXhjZXB0aW9uIGRhdGEgYWxvbmcgd2l0aCB0aGUgZXJyb3JJZA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MDAwMCk7Cg=="),{workerData:{captureAllExceptions:!0}});let i=null;e.on("message",a=>{if(typeof a=="string"&&r().sfDebug&&console.log(`[Worker] ${a}`),a.readyToGetParameters&&e.postMessage({sfDebug:r().sfDebug,stackDepthLocals:r().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:r().nodeModulesToCollectLocalVariablesOn}),a.type==="exception"){const{frames:d}=a,I=i;if(!I)return;const C=function(l,g){const p=[];let h=-1,N=-1;for(let u=0;u<l.length;u++){const m=P(l[u].file);if(N=u,m!=="<unknown>"){for(let b=0;b<g.length;b++){const V=g[b];if(x(V,m)||typeof V.file=="string"&&V.file.includes(m)){h=b,v=0,r().sfDebug&&console.log(`✅ Matched Frame Found: ${m} @ Debugger Frame ${b}`);break}}if(h!==-1)break}}if(h===-1)return v===10?(v=0,l):(++v,r().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${v}"`),[]);r().sfDebug&&console.log(`🔄 Merging from matched index ${h} onward...`);for(let u=0;u<g.length;u++){const m=l[N+u],b=g[h+u];p.push(new f({function:b?.function||m?.function||"<anonymous>",locals:b?.locals||m?.locals||{},file:m?.file||b?.file||"<unknown>",line:b?.line||m?.line||0,code:m?.code||b?.code||"<not captured>"}))}return p}(function(l){return l?l.split(`
32
+ `).slice(1).map(g=>{const p=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(g)||/at (.+):(\d+):(\d+)/.exec(g);if(p){const[,h,N,u]=p;return new f({function:h||"<anonymous>",locals:{},file:N||"<unknown>",line:parseInt(u,10)||0,code:"<not captured>"})}return new f({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>"})}):[]}(I.stack),d||[]);if(C.length!==0){i=null;const l=r().stackDepthCodeTraceDepth,g=l===-1?C:C.slice(0,l+1);o.setOperationName("CollectExceptions");const p=I.message?`${I.name}: ${I.message}`:I.name;r().sfDebug&&console.log("error message is : ",p),o.doSend(p,g)}}}),e.on("error",a=>{console.error("[Worker Error]",a)}),e.on("exit",a=>{console.error(`[Worker] Exited with code ${a}`)}),e.unref();const t=Error,n=new Set;function s(...a){const d=Reflect.construct(t,a);Reflect.setPrototypeOf(d,s.prototype),t.captureStackTrace&&t.captureStackTrace(d,s);const I=`${d.message}:${d.stack?.split(`
33
+ `)[1]?.trim()}`;return n.has(I)||(n.add(I),i=d,e.postMessage({type:"processException",error:d.message})),d}s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(s,t),globalThis.Error=s}function P(o){return o?.split("/").pop()||"<unknown>"}function x(o,e){if(!o||typeof o!="object")return!1;for(const i of Object.values(o))if(typeof i=="string"&&i.includes(e)||typeof i=="object"&&x(i,e))return!0;return!1}class j extends S{constructor(){super();c(this,"serviceIdentifier",new w);this.setOperationName("CollectExceptions")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(i,t){this.sendAppIdentifier(),this.send(i,t)}async send(i,t){r().sfDebug&&console.log(" SENDING EXCEPTION...");const n=JSON.stringify(B.encode(t)),s=this.getVariables({exceptionMessage:i,traceJson:n,reentrancyGuardPreactive:!1,library:r().packageLibraryType,version:r().version});Z(this.endpoint,this.operationName,this.getQuery(),s)}getQuery(){return`
34
34
  mutation ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $exceptionMessage: String!, $traceJson: String!, $reentrancyGuardPreactive: Boolean!, $library: String!, $timestampMs: String!, $version: String!) {
35
35
  ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, exceptionMessage: $exceptionMessage, traceJson: $traceJson, reentrancyGuardPreactive: $reentrancyGuardPreactive, library: $library, timestampMs: $timestampMs, version: $version)
36
36
  }
@@ -46,7 +46,7 @@
46
46
  domains: $domains
47
47
  )
48
48
  }
49
- `,t={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:e};Z(this.endpoint,this.operationName,i,t)}}const q=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"];class _{constructor(e=[]){g(this,"HEADER_TRACING","X-Sf3-Rid");g(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");g(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");g(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");g(this,"contextManager");g(this,"excludedDomains");this.contextManager=W.getInstance(),this.excludedDomains=[...q,...e].map(i=>i.toLowerCase()),o().sfDebug&&console.log("[RequestInterceptor] Initialized.")}addReentrancyGuardHeaders(e){e.set(this.HEADER_LOG_GUARD,"true"),e.set(this.HEADER_PRINT_GUARD,"true"),e.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(e){return!this.excludedDomains.some(i=>new RegExp(`^${i.replace(/\*/g,".*")}$`).test(e))}addTracingHeaders(e,i){const t=new URL(i).hostname;if(this.shouldPropagateHeaders(t)){const n=this.contextManager.getOrSetSfTraceId();e.set(this.HEADER_TRACING,n),o().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${i}`)}else o().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${t}`);this.addReentrancyGuardHeaders(e)}patchFetch(){const e=globalThis.fetch;typeof e=="function"?globalThis.fetch=async(i,t)=>{const n=Date.now(),s=new Headers(t?.headers);let c;typeof i=="string"||i instanceof URL?c=i.toString():i instanceof Request?(c=i.url,i.headers.forEach((a,A)=>{s.set(A,a)})):o().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),o().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",c),this.addTracingHeaders(s,c);const l={...t,headers:s};try{const a=await e(c,l),A=Date.now();return o().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${a.status}, Duration: ${A-n}ms`),a}catch(a){const A=Date.now();o().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${a}, Duration: ${A-n}ms`)}}:o().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}}class ee extends K{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const e=`
49
+ `,t={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:e};Z(this.endpoint,this.operationName,i,t)}}const q=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"];class _{constructor(e=[]){c(this,"HEADER_TRACING","X-Sf3-Rid");c(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");c(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");c(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");c(this,"contextManager");c(this,"excludedDomains");this.contextManager=W.getInstance(),this.excludedDomains=[...q,...e].map(i=>i.toLowerCase()),r().sfDebug&&console.log("[RequestInterceptor] Initialized.")}addReentrancyGuardHeaders(e){e.set(this.HEADER_LOG_GUARD,"true"),e.set(this.HEADER_PRINT_GUARD,"true"),e.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(e){return!this.excludedDomains.some(i=>new RegExp(`^${i.replace(/\*/g,".*")}$`).test(e))}addTracingHeaders(e,i){const t=new URL(i).hostname;if(this.shouldPropagateHeaders(t)){const n=this.contextManager.getOrSetSfTraceId();e.set(this.HEADER_TRACING,n),r().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${i}`)}else r().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${t}`);this.addReentrancyGuardHeaders(e)}patchFetch(){const e=globalThis.fetch;typeof e=="function"?globalThis.fetch=async(i,t)=>{const n=Date.now(),s=new Headers(t?.headers);let a;typeof i=="string"||i instanceof URL?a=i.toString():i instanceof Request?(a=i.url,i.headers.forEach((I,C)=>{s.set(C,I)})):r().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),r().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",a),this.addTracingHeaders(s,a);const d={...t,headers:s};try{const I=await e(a,d),C=Date.now();return r().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${I.status}, Duration: ${C-n}ms`),I}catch(I){const C=Date.now();r().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${I}, Duration: ${C-n}ms`)}}:r().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}}class ee extends K{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const e=`
50
50
  ${this.queryType} ${this.operationName}(
51
51
  $apiKey: String!,
52
52
  $serviceUuid: String!,
@@ -66,4 +66,4 @@
66
66
 
67
67
  )
68
68
  }
69
- `,i=this.getVariables({serviceIdentifier:o().serviceIdentifier,serviceVersion:o().serviceVersion,serviceAdditionalMetadata:o().serviceAdditionalMetadata});Z(this.endpoint,this.operationName,e,i)}}exports.addOrUpdateMetadata=function(r,e={},i,t=!1){const n=o();new D(n.apiKey).addOrUpdateMetadata(r,e,i,t)},exports.identify=function(r,e,i,t=!1){const n=o();new D(n.apiKey).identify(r,e,i,t)},exports.setupInterceptors=function(r){const{config:e,created:i}=function(s){let c=!1;return f||(c=!0,s||(s={}),f=new T(s)),{config:f,created:c}}(r);if(!i)return;if(e.sfDebug&&console.log("Updated configuration after applying options:",e),!e.apiKey||!e.apiGraphqlEndpoint){const s=`The required config is not provided: ${JSON.stringify(e)}`;throw console.error(s),new Error(s)}const t=new K;t.setServiceUUID(e.serviceUUID),function(s){function c(I,u){s.setOperationName("CollectLogs"),s.doSend([u,I])}const l=console.log.bind(console),a=console.error.bind(console),A=console.warn.bind(console),C=console.info.bind(console),d=console.debug.bind(console);console.log=(...I)=>{c("INFO",I.join(" ")),l(...I)},console.error=(...I)=>{c("ERROR",I.join(" ")),a(...I)},console.warn=(...I)=>{c("WARN",I.join(" ")),A(...I)},console.info=(...I)=>{c("INFO",I.join(" ")),C(...I)},o().logLevel==="DEBUG"&&(console.debug=(...I)=>{c("DEBUG",I.join(" ")),d(...I)})}(t),function(s=[]){const c=new _(s);new Q().doSend(c.excludedDomains),c.patchFetch()}(e.domainsToNotPropagateHeadersTo);const n=new j;n.setServiceUUID(e.serviceUUID),M(n),new ee().send()};
69
+ `,i=this.getVariables({serviceIdentifier:r().serviceIdentifier,serviceVersion:r().serviceVersion,serviceAdditionalMetadata:r().serviceAdditionalMetadata});Z(this.endpoint,this.operationName,e,i)}}exports.addOrUpdateMetadata=function(o,e={},i,t=!1){const n=r();new D(n.apiKey).addOrUpdateMetadata(o,e,i,t)},exports.identify=function(o,e,i,t=!1){const n=r();new D(n.apiKey).identify(o,e,i,t)},exports.setupInterceptors=function(o){if(!o||!o.apiKey){const n=`The required API Key is not provided: ${JSON.stringify(o)}`;console.error(n)}const{config:e}=function(n){return G=new z(n),{config:G}}(o);if(e.sfDebug&&console.log("Updated configuration after applying options:",e),!e.apiKey||!e.apiGraphqlEndpoint){const n=`The required config is not provided: ${JSON.stringify(e)}`;throw console.error(n),new Error(n)}const i=new K;i.setServiceUUID(e.serviceUUID),function(n){function s(g,p){n.setOperationName("CollectLogs"),n.doSend([p,g])}const a=console.log.bind(console),d=console.error.bind(console),I=console.warn.bind(console),C=console.info.bind(console),l=console.debug.bind(console);console.log=(...g)=>{s("INFO",g.join(" ")),a(...g)},console.error=(...g)=>{s("ERROR",g.join(" ")),d(...g)},console.warn=(...g)=>{s("WARN",g.join(" ")),I(...g)},console.info=(...g)=>{s("INFO",g.join(" ")),C(...g)},r().logLevel==="DEBUG"&&(console.debug=(...g)=>{s("DEBUG",g.join(" ")),l(...g)})}(i),function(n=[]){const s=new _(n);new Q().doSend(s.excludedDomains),s.patchFetch()}(e.domainsToNotPropagateHeadersTo);const t=new j;t.setServiceUUID(e.serviceUUID),M(t),new ee().send()};
@@ -1,48 +1,48 @@
1
1
  var E = Object.defineProperty;
2
- var L = (r, e, i) => e in r ? E(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i;
3
- var g = (r, e, i) => L(r, typeof e != "symbol" ? e + "" : e, i);
2
+ var L = (o, e, t) => e in o ? E(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var c = (o, e, t) => L(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { AsyncLocalStorage as D } from "async_hooks";
5
5
  import { Worker as F } from "worker_threads";
6
- const p = [];
7
- for (let r = 0; r < 256; ++r) p.push((r + 256).toString(16).slice(1));
6
+ const A = [];
7
+ for (let o = 0; o < 256; ++o) A.push((o + 256).toString(16).slice(1));
8
8
  let Y;
9
- const z = new Uint8Array(16), X = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
10
- function J(r, e, i) {
11
- if (X.randomUUID && !r) return X.randomUUID();
12
- const t = (r = r || {}).random ?? r.rng?.() ?? function() {
9
+ const T = new Uint8Array(16), X = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
10
+ function J(o, e, t) {
11
+ if (X.randomUUID && !o) return X.randomUUID();
12
+ const i = (o = o || {}).random ?? o.rng?.() ?? function() {
13
13
  if (!Y) {
14
14
  if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
15
15
  Y = crypto.getRandomValues.bind(crypto);
16
16
  }
17
- return Y(z);
17
+ return Y(T);
18
18
  }();
19
- if (t.length < 16) throw new Error("Random bytes length must be >= 16");
20
- return t[6] = 15 & t[6] | 64, t[8] = 63 & t[8] | 128, function(n, s = 0) {
21
- return (p[n[s + 0]] + p[n[s + 1]] + p[n[s + 2]] + p[n[s + 3]] + "-" + p[n[s + 4]] + p[n[s + 5]] + "-" + p[n[s + 6]] + p[n[s + 7]] + "-" + p[n[s + 8]] + p[n[s + 9]] + "-" + p[n[s + 10]] + p[n[s + 11]] + p[n[s + 12]] + p[n[s + 13]] + p[n[s + 14]] + p[n[s + 15]]).toLowerCase();
22
- }(t);
19
+ if (i.length < 16) throw new Error("Random bytes length must be >= 16");
20
+ return i[6] = 15 & i[6] | 64, i[8] = 63 & i[8] | 128, function(n, s = 0) {
21
+ return (A[n[s + 0]] + A[n[s + 1]] + A[n[s + 2]] + A[n[s + 3]] + "-" + A[n[s + 4]] + A[n[s + 5]] + "-" + A[n[s + 6]] + A[n[s + 7]] + "-" + A[n[s + 8]] + A[n[s + 9]] + "-" + A[n[s + 10]] + A[n[s + 11]] + A[n[s + 12]] + A[n[s + 13]] + A[n[s + 14]] + A[n[s + 15]]).toLowerCase();
22
+ }(i);
23
23
  }
24
- class T {
24
+ class z {
25
25
  constructor(e) {
26
- g(this, "apiKey");
27
- g(this, "apiGraphqlEndpoint");
28
- g(this, "sfDebug");
29
- g(this, "serviceIdentifier");
30
- g(this, "serviceVersion");
31
- g(this, "serviceUUID");
32
- g(this, "serviceAdditionalMetadata");
33
- g(this, "profilingModeEnabled");
34
- g(this, "profilingMaxDepth");
35
- g(this, "profilingMaxVariableSizeKb");
36
- g(this, "domainsToNotPropagateHeadersTo");
37
- g(this, "nodeModulesToCollectLocalVariablesOn");
38
- g(this, "printConfigurationStatuses");
39
- g(this, "logLevel");
40
- g(this, "stackDepthLocals");
41
- g(this, "stackDepthCodeTraceDepth");
42
- g(this, "packageLibraryType");
43
- g(this, "version");
44
- g(this, "_serviceIdentificationReceived", !1);
45
- this.apiKey = e?.apiKey || process.env.SAILFISH_API_KEY, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = J(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || [], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "NEXT JS/TS", this.version = this.getPackageVersion();
26
+ c(this, "apiKey");
27
+ c(this, "apiGraphqlEndpoint");
28
+ c(this, "sfDebug");
29
+ c(this, "serviceIdentifier");
30
+ c(this, "serviceVersion");
31
+ c(this, "serviceUUID");
32
+ c(this, "serviceAdditionalMetadata");
33
+ c(this, "profilingModeEnabled");
34
+ c(this, "profilingMaxDepth");
35
+ c(this, "profilingMaxVariableSizeKb");
36
+ c(this, "domainsToNotPropagateHeadersTo");
37
+ c(this, "nodeModulesToCollectLocalVariablesOn");
38
+ c(this, "printConfigurationStatuses");
39
+ c(this, "logLevel");
40
+ c(this, "stackDepthLocals");
41
+ c(this, "stackDepthCodeTraceDepth");
42
+ c(this, "packageLibraryType");
43
+ c(this, "version");
44
+ c(this, "_serviceIdentificationReceived", !1);
45
+ this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = J(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || [], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "NEXT JS/TS", this.version = this.getPackageVersion();
46
46
  }
47
47
  getPackageVersion() {
48
48
  return "0.1.14";
@@ -54,10 +54,10 @@ class T {
54
54
  this._serviceIdentificationReceived = e;
55
55
  }
56
56
  }
57
- let f;
58
- function o() {
59
- if (!f) throw new Error("Configuration has not been initialized. Please call initializeConfig() before using getConfig().");
60
- return f;
57
+ let G;
58
+ function r() {
59
+ if (!G) throw new Error("Configuration has not been initialized.");
60
+ return G;
61
61
  }
62
62
  new D();
63
63
  const H = new D(), R = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1 }, y = class y {
@@ -70,8 +70,8 @@ const H = new D(), R = { handledExceptions: /* @__PURE__ */ new Set(), reentranc
70
70
  return H.getStore() || R;
71
71
  }
72
72
  setCurrentContext(e) {
73
- const i = H.getStore() || R;
74
- H.enterWith({ ...i, ...e });
73
+ const t = H.getStore() || R;
74
+ H.enterWith({ ...t, ...e });
75
75
  }
76
76
  getTraceId() {
77
77
  return this.getCurrentContext().traceId;
@@ -79,16 +79,16 @@ const H = new D(), R = { handledExceptions: /* @__PURE__ */ new Set(), reentranc
79
79
  setTraceId(e) {
80
80
  this.setCurrentContext({ traceId: e });
81
81
  }
82
- getOrSetSfTraceId(e, i = !1) {
83
- let t = this.getTraceId();
84
- return t || (t = e || (i ? J() : `nonsession-applogs-v3/${o().apiKey}/${J()}`), this.setTraceId(t), o().sfDebug && console.log(" Created new trace ID:", t), t);
82
+ getOrSetSfTraceId(e, t = !1) {
83
+ let i = this.getTraceId();
84
+ return i || (i = e || (t ? J() : `nonsession-applogs-v3/${r().apiKey}/${J()}`), this.setTraceId(i), r().sfDebug && console.log(" Created new trace ID:", i), i);
85
85
  }
86
86
  getHandledExceptions() {
87
87
  return this.getCurrentContext().handledExceptions;
88
88
  }
89
89
  markExceptionHandled(e) {
90
- const i = this.getHandledExceptions();
91
- i.add(e), this.setCurrentContext({ handledExceptions: i });
90
+ const t = this.getHandledExceptions();
91
+ t.add(e), this.setCurrentContext({ handledExceptions: t });
92
92
  }
93
93
  hasHandledException(e) {
94
94
  return this.getHandledExceptions().has(e);
@@ -97,24 +97,24 @@ const H = new D(), R = { handledExceptions: /* @__PURE__ */ new Set(), reentranc
97
97
  this.setCurrentContext({ handledExceptions: /* @__PURE__ */ new Set() });
98
98
  }
99
99
  };
100
- g(y, "instance");
100
+ c(y, "instance");
101
101
  let W = y;
102
102
  class V {
103
103
  constructor() {
104
- g(this, "apiKey");
105
- g(this, "endpoint");
106
- g(this, "queryType", "mutation");
107
- g(this, "operationName", "");
108
- g(this, "serviceUUID", o().serviceUUID);
109
- g(this, "contextManager");
110
- this.apiKey = o().apiKey, this.endpoint = o().apiGraphqlEndpoint, this.contextManager = W.getInstance();
104
+ c(this, "apiKey");
105
+ c(this, "endpoint");
106
+ c(this, "queryType", "mutation");
107
+ c(this, "operationName", "");
108
+ c(this, "serviceUUID", r().serviceUUID);
109
+ c(this, "contextManager");
110
+ this.apiKey = r().apiKey, this.endpoint = r().apiGraphqlEndpoint, this.contextManager = W.getInstance();
111
111
  }
112
112
  get queryName() {
113
113
  return this.operationName ? this.operationName.charAt(0).toLowerCase() + this.operationName.slice(1) : "";
114
114
  }
115
115
  getDefaultVariables() {
116
- const e = Date.now().toString(), i = this.contextManager.getOrSetSfTraceId();
117
- return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: i, timestampMs: e };
116
+ const e = Date.now().toString(), t = this.contextManager.getOrSetSfTraceId();
117
+ return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: t, timestampMs: e };
118
118
  }
119
119
  getVariables(e = {}) {
120
120
  return { ...this.getDefaultVariables(), ...e };
@@ -130,30 +130,30 @@ class V {
130
130
  }
131
131
  }
132
132
  const $ = fetch;
133
- async function Z(r, e, i, t) {
133
+ async function Z(o, e, t, i) {
134
134
  try {
135
- const n = o();
135
+ const n = r();
136
136
  let s;
137
137
  try {
138
- s = JSON.stringify({ query: i, variables: t, operationName: e });
138
+ s = JSON.stringify({ query: t, variables: i, operationName: e });
139
139
  } catch {
140
- s = JSON.stringify({ query: i, operationName: e });
140
+ s = JSON.stringify({ query: t, operationName: e });
141
141
  }
142
- $(r, { method: "POST", headers: { "Content-Type": "application/json" }, body: s }).then(async (c) => {
143
- if (!c.ok) return void (n.sfDebug && console.error(`GraphQL request failed with status ${c.status} for ${e}`));
144
- const l = await c.json();
145
- l.errors?.length ? function(a, A, C) {
146
- const d = a && typeof a == "object" && !Array.isArray(a) ? Object.keys(a)[0] : void 0;
147
- console.error(d === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${C.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(A)} for operation key ${d}`);
148
- }(l.data, l.errors, n) : n.sfDebug && function(a, A, C) {
149
- const d = a && typeof a == "object" && !Array.isArray(a) ? Object.keys(a)[0] : void 0, I = a[d] || !1;
150
- d === "identifyServiceDetails" && (C.setServiceIdentificationReceived(I), o().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${C.serviceUUID}; serviceIdentificationReceived=${d === "identifyServiceDetails" ? I : "N/A"}`));
151
- }(l.data, 0, n);
152
- }).catch((c) => {
153
- n.sfDebug && console.error("Fetch error:", c);
142
+ $(o, { method: "POST", headers: { "Content-Type": "application/json" }, body: s }).then(async (a) => {
143
+ if (!a.ok) return void (n.sfDebug && console.error(`GraphQL request failed with status ${a.status} for ${e}`));
144
+ const d = await a.json();
145
+ d.errors?.length ? function(I, C, l) {
146
+ const g = I && typeof I == "object" && !Array.isArray(I) ? Object.keys(I)[0] : void 0;
147
+ console.error(g === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${l.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(C)} for operation key ${g}`);
148
+ }(d.data, d.errors, n) : n.sfDebug && function(I, C, l) {
149
+ const g = I && typeof I == "object" && !Array.isArray(I) ? Object.keys(I)[0] : void 0, p = I[g] || !1;
150
+ g === "identifyServiceDetails" && (l.setServiceIdentificationReceived(p), r().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${l.serviceUUID}; serviceIdentificationReceived=${g === "identifyServiceDetails" ? p : "N/A"}`));
151
+ }(d.data, 0, n);
152
+ }).catch((a) => {
153
+ n.sfDebug && console.error("Fetch error:", a);
154
154
  });
155
155
  } catch (n) {
156
- o().sfDebug && console.error("Error sending data to GraphQL server:", n);
156
+ r().sfDebug && console.error("Error sending data to GraphQL server:", n);
157
157
  }
158
158
  }
159
159
  class w extends V {
@@ -161,10 +161,10 @@ class w extends V {
161
161
  super(), this.setOperationName("IdentifyServiceDetails");
162
162
  }
163
163
  async doSend(e) {
164
- if (!o().serviceIdentificationReceived) try {
164
+ if (!r().serviceIdentificationReceived) try {
165
165
  this.send();
166
- } catch (i) {
167
- o().sfDebug && console.error(" Error during service identification:", i);
166
+ } catch (t) {
167
+ r().sfDebug && console.error(" Error during service identification:", t);
168
168
  }
169
169
  }
170
170
  async send() {
@@ -190,13 +190,13 @@ class w extends V {
190
190
  version: $version,
191
191
  )
192
192
  }
193
- `, i = this.getVariables({ serviceIdentifier: o().serviceIdentifier, serviceVersion: o().serviceVersion, library: o().packageLibraryType, version: o().version, serviceAdditionalMetadata: o().serviceAdditionalMetadata });
194
- Z(this.endpoint, this.operationName, e, i);
193
+ `, t = this.getVariables({ serviceIdentifier: r().serviceIdentifier, serviceVersion: r().serviceVersion, library: r().packageLibraryType, version: r().version, serviceAdditionalMetadata: r().serviceAdditionalMetadata });
194
+ Z(this.endpoint, this.operationName, e, t);
195
195
  }
196
196
  }
197
- function k(r) {
197
+ function k(o) {
198
198
  try {
199
- return JSON.stringify(r), !0;
199
+ return JSON.stringify(o), !0;
200
200
  } catch {
201
201
  return !1;
202
202
  }
@@ -204,28 +204,28 @@ function k(r) {
204
204
  class O extends V {
205
205
  constructor() {
206
206
  super();
207
- g(this, "serviceIdentifier", new w());
207
+ c(this, "serviceIdentifier", new w());
208
208
  this.setOperationName("CollectMetadata");
209
209
  }
210
210
  async sendAppIdentifier() {
211
211
  this.serviceIdentifier.doSend({});
212
212
  }
213
- async doSend(i, t, n, s) {
214
- this.sendAppIdentifier(), this.send(i, t, n, s);
213
+ async doSend(t, i, n, s) {
214
+ this.sendAppIdentifier(), this.send(t, i, n, s);
215
215
  }
216
- async send(i, t, n, s) {
217
- if (!t && !s) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
218
- let c = [];
216
+ async send(t, i, n, s) {
217
+ if (!i && !s) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
218
+ let a = [];
219
219
  if (!s) {
220
- const a = function(A) {
221
- const C = {}, d = [];
222
- if (A) for (const [I, u] of Object.entries(A)) k(u) ? C[I] = u : d.push(I);
223
- return { traitsJson: JSON.stringify(C), excludedFields: d };
224
- }(t);
225
- s = a.traitsJson, c = a.excludedFields;
220
+ const I = function(C) {
221
+ const l = {}, g = [];
222
+ if (C) for (const [p, h] of Object.entries(C)) k(h) ? l[p] = h : g.push(p);
223
+ return { traitsJson: JSON.stringify(l), excludedFields: g };
224
+ }(i);
225
+ s = I.traitsJson, a = I.excludedFields;
226
226
  }
227
- const l = this.getVariables({ userId: i, traitsJson: s, excludedFields: c, override: n, library: o().packageLibraryType, version: o().version });
228
- Z(this.endpoint, this.operationName, this.getQuery(), l);
227
+ const d = this.getVariables({ userId: t, traitsJson: s, excludedFields: a, override: n, library: r().packageLibraryType, version: r().version });
228
+ Z(this.endpoint, this.operationName, this.getQuery(), d);
229
229
  }
230
230
  getQuery() {
231
231
  return `
@@ -237,34 +237,34 @@ class O extends V {
237
237
  }
238
238
  class U {
239
239
  constructor(e) {
240
- g(this, "metadataTransmitter");
240
+ c(this, "metadataTransmitter");
241
241
  this.apiKey = e, this.metadataTransmitter = new O();
242
242
  }
243
- identify(e, i, t, n = !1) {
244
- i || t ? this.addOrUpdateMetadata(e, i, t, n) : this.addOrUpdateMetadata(e, {}, void 0, n);
243
+ identify(e, t, i, n = !1) {
244
+ t || i ? this.addOrUpdateMetadata(e, t, i, n) : this.addOrUpdateMetadata(e, {}, void 0, n);
245
245
  }
246
- addOrUpdateMetadata(e, i = {}, t, n = !1) {
247
- if (!i && !t) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
248
- o().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), o().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, i, t), this.metadataTransmitter.doSend(e, i, n, t);
246
+ addOrUpdateMetadata(e, t = {}, i, n = !1) {
247
+ if (!t && !i) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
248
+ r().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), r().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, t, i), this.metadataTransmitter.doSend(e, t, n, i);
249
249
  }
250
250
  }
251
251
  class K extends V {
252
252
  constructor() {
253
253
  super();
254
- g(this, "serviceIdentifier", new w());
254
+ c(this, "serviceIdentifier", new w());
255
255
  }
256
256
  async sendAppIdentifier() {
257
257
  this.serviceIdentifier.doSend({});
258
258
  }
259
- async doSend(i) {
260
- this.sendAppIdentifier(), this.send(i);
259
+ async doSend(t) {
260
+ this.sendAppIdentifier(), this.send(t);
261
261
  }
262
- async send(i) {
262
+ async send(t) {
263
263
  try {
264
- const t = Array.isArray(i) ? i : [i, "default"], n = this.getVariables({ contents: t[0], level: t[1] });
264
+ const i = Array.isArray(t) ? t : [t, "default"], n = this.getVariables({ contents: i[0], level: i[1] });
265
265
  Z(this.endpoint, this.operationName, this.getQuery(), n);
266
- } catch (t) {
267
- o().sfDebug && console.error("🚨 Error in send():", t);
266
+ } catch (i) {
267
+ r().sfDebug && console.error("🚨 Error in send():", i);
268
268
  }
269
269
  }
270
270
  getQuery() {
@@ -275,18 +275,18 @@ class K extends V {
275
275
  `;
276
276
  }
277
277
  }
278
- class N {
279
- constructor({ file: e, line: i, function: t, code: n, locals: s = {}, offender: c = !1 }) {
280
- g(this, "file");
281
- g(this, "line");
282
- g(this, "function");
283
- g(this, "code");
284
- g(this, "locals");
285
- g(this, "offender");
286
- this.file = e, this.line = i, this.function = t, this.code = n, this.locals = s, this.offender = c;
278
+ class f {
279
+ constructor({ file: e, line: t, function: i, code: n, locals: s = {}, offender: a = !1 }) {
280
+ c(this, "file");
281
+ c(this, "line");
282
+ c(this, "function");
283
+ c(this, "code");
284
+ c(this, "locals");
285
+ c(this, "offender");
286
+ this.file = e, this.line = t, this.function = i, this.code = n, this.locals = s, this.offender = a;
287
287
  }
288
288
  toDict() {
289
- const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([i, t]) => [i, String(t)])) };
289
+ const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([t, i]) => [t, String(i)])) };
290
290
  return this.offender && (e.offender = this.offender), e;
291
291
  }
292
292
  toJson() {
@@ -295,102 +295,102 @@ class N {
295
295
  }
296
296
  class B {
297
297
  static encode(e) {
298
- return e instanceof N ? e.toDict() : Array.isArray(e) ? e.map((i) => B.encode(i)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
298
+ return e instanceof f ? e.toDict() : Array.isArray(e) ? e.map((t) => B.encode(t)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
299
299
  }
300
300
  static stringify(e) {
301
- return JSON.stringify(B.encode(e), (i, t) => t instanceof N ? t.toDict() : t);
301
+ return JSON.stringify(B.encode(e), (t, i) => i instanceof f ? i.toDict() : i);
302
302
  }
303
303
  }
304
304
  let v = 0;
305
- function M(r) {
306
- o().sfDebug && console.log("Initializing Exception Interceptor...");
305
+ function M(o) {
306
+ r().sfDebug && console.log("Initializing Exception Interceptor...");
307
307
  const e = new F(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5lcnJvcklkID0gdW5kZWZpbmVkOwpnbG9iYWwubm9kZU1vZHVsZXNUb0NvbGxlY3RMb2NhbFZhcmlhYmxlc09uID0gdW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kPiI7CiAgICAgICAgbGV0IGZpbGUgPSB1cmwgfHwgIjx1bmtub3duPiI7CiAgICAgICAgaWYgKGxvY2F0aW9uICYmIGxvY2F0aW9uLnNjcmlwdElkKSB7CiAgICAgICAgICBjb25zdCBzY3JpcHRJZCA9IGxvY2F0aW9uLnNjcmlwdElkOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgeyBzY3JpcHRTb3VyY2UgfSA9IGF3YWl0IHNlc3Npb24ucG9zdCgKICAgICAgICAgICAgICAiRGVidWdnZXIuZ2V0U2NyaXB0U291cmNlIiwKICAgICAgICAgICAgICB7IHNjcmlwdElkIH0sCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIGNvbnN0IHNvdXJjZUxpbmVzID0gc2NyaXB0U291cmNlLnNwbGl0KCJcbiIpOwogICAgICAgICAgICBjb2RlID0gc291cmNlTGluZXNbbG9jYXRpb24ubGluZU51bWJlcl0gfHwgIjxub3QgY2FwdHVyZWQ+IjsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBGYWlsZWQgdG8gZmV0Y2ggc2NyaXB0IHNvdXJjZToiLCBlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBjb25zdCBsb2NhbHMgPSBsb2NhbFNjb3BlPy5vYmplY3Q/Lm9iamVjdElkCiAgICAgICAgICA/IGF3YWl0IGZldGNoTG9jYWxWYXJpYWJsZXMoc2Vzc2lvbiwgbG9jYWxTY29wZS5vYmplY3Qub2JqZWN0SWQpCiAgICAgICAgICA6IHt9OwoKICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246IGZ1bmN0aW9uTmFtZSB8fCAiPGFub255bW91cz4iLAogICAgICAgICAgbG9jYWxzLAogICAgICAgICAgZmlsZSwKICAgICAgICAgIGxpbmU6I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HsKICAgICAgICAgIHVucm9sbE90aGVyKHByb3AsIHZhcmlhYmxlcyk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB2YXJpYWJsZXM7CiAgICB9CiAgfSBjYXRjaCAoZXJyKSB7CiAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIGZldGNoIGxvY2FsIHZhcmlhYmxlczoiLCBlcnIpOwogICAgfQogICAgcmV0dXJuIHt9OwogIH0KfQoKc3RhcnREZWJ1Z2dlcigpLmNhdGNoKChlcnJvcikgPT4gewogIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIHN0YXJ0IGRlYnVnZ2VyOiIsIGVycm9yKTsKICB9Cn0pOwoKLy8gS2VlcCB0aGUgd29ya2VyIGFsaXZlCnNldEludGVydmFsKCgpID0+IHt9LCAxMDAwMCk7Cg=="), { workerData: { captureAllExceptions: !0 } });
308
- let i = null;
309
- e.on("message", (c) => {
310
- if (typeof c == "string" && o().sfDebug && console.log(`[Worker] ${c}`), c.readyToGetParameters && e.postMessage({ sfDebug: o().sfDebug, stackDepthLocals: o().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: o().nodeModulesToCollectLocalVariablesOn }), c.type === "exception") {
311
- const { frames: l } = c, a = i;
312
- if (!a) return;
313
- const A = function(C, d) {
314
- const I = [];
315
- let u = -1, G = -1;
316
- for (let b = 0; b < C.length; b++) {
317
- const m = P(C[b].file);
318
- if (G = b, m !== "<unknown>") {
319
- for (let h = 0; h < d.length; h++) {
320
- const S = d[h];
308
+ let t = null;
309
+ e.on("message", (a) => {
310
+ if (typeof a == "string" && r().sfDebug && console.log(`[Worker] ${a}`), a.readyToGetParameters && e.postMessage({ sfDebug: r().sfDebug, stackDepthLocals: r().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: r().nodeModulesToCollectLocalVariablesOn }), a.type === "exception") {
311
+ const { frames: d } = a, I = t;
312
+ if (!I) return;
313
+ const C = function(l, g) {
314
+ const p = [];
315
+ let h = -1, N = -1;
316
+ for (let u = 0; u < l.length; u++) {
317
+ const m = P(l[u].file);
318
+ if (N = u, m !== "<unknown>") {
319
+ for (let b = 0; b < g.length; b++) {
320
+ const S = g[b];
321
321
  if (x(S, m) || typeof S.file == "string" && S.file.includes(m)) {
322
- u = h, v = 0, o().sfDebug && console.log(`✅ Matched Frame Found: ${m} @ Debugger Frame ${h}`);
322
+ h = b, v = 0, r().sfDebug && console.log(`✅ Matched Frame Found: ${m} @ Debugger Frame ${b}`);
323
323
  break;
324
324
  }
325
325
  }
326
- if (u !== -1) break;
326
+ if (h !== -1) break;
327
327
  }
328
328
  }
329
- if (u === -1) return v === 10 ? (v = 0, C) : (++v, o().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${v}"`), []);
330
- o().sfDebug && console.log(`🔄 Merging from matched index ${u} onward...`);
331
- for (let b = 0; b < d.length; b++) {
332
- const m = C[G + b], h = d[u + b];
333
- I.push(new N({ function: h?.function || m?.function || "<anonymous>", locals: h?.locals || m?.locals || {}, file: m?.file || h?.file || "<unknown>", line: h?.line || m?.line || 0, code: m?.code || h?.code || "<not captured>" }));
329
+ if (h === -1) return v === 10 ? (v = 0, l) : (++v, r().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${v}"`), []);
330
+ r().sfDebug && console.log(`🔄 Merging from matched index ${h} onward...`);
331
+ for (let u = 0; u < g.length; u++) {
332
+ const m = l[N + u], b = g[h + u];
333
+ p.push(new f({ function: b?.function || m?.function || "<anonymous>", locals: b?.locals || m?.locals || {}, file: m?.file || b?.file || "<unknown>", line: b?.line || m?.line || 0, code: m?.code || b?.code || "<not captured>" }));
334
334
  }
335
- return I;
336
- }(function(C) {
337
- return C ? C.split(`
338
- `).slice(1).map((d) => {
339
- const I = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(d) || /at (.+):(\d+):(\d+)/.exec(d);
340
- if (I) {
341
- const [, u, G, b] = I;
342
- return new N({ function: u || "<anonymous>", locals: {}, file: G || "<unknown>", line: parseInt(b, 10) || 0, code: "<not captured>" });
335
+ return p;
336
+ }(function(l) {
337
+ return l ? l.split(`
338
+ `).slice(1).map((g) => {
339
+ const p = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(g) || /at (.+):(\d+):(\d+)/.exec(g);
340
+ if (p) {
341
+ const [, h, N, u] = p;
342
+ return new f({ function: h || "<anonymous>", locals: {}, file: N || "<unknown>", line: parseInt(u, 10) || 0, code: "<not captured>" });
343
343
  }
344
- return new N({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>" });
344
+ return new f({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>" });
345
345
  }) : [];
346
- }(a.stack), l || []);
347
- if (A.length !== 0) {
348
- i = null;
349
- const C = o().stackDepthCodeTraceDepth, d = C === -1 ? A : A.slice(0, C + 1);
350
- r.setOperationName("CollectExceptions");
351
- const I = a.message ? `${a.name}: ${a.message}` : a.name;
352
- o().sfDebug && console.log("error message is : ", I), r.doSend(I, d);
346
+ }(I.stack), d || []);
347
+ if (C.length !== 0) {
348
+ t = null;
349
+ const l = r().stackDepthCodeTraceDepth, g = l === -1 ? C : C.slice(0, l + 1);
350
+ o.setOperationName("CollectExceptions");
351
+ const p = I.message ? `${I.name}: ${I.message}` : I.name;
352
+ r().sfDebug && console.log("error message is : ", p), o.doSend(p, g);
353
353
  }
354
354
  }
355
- }), e.on("error", (c) => {
356
- console.error("[Worker Error]", c);
357
- }), e.on("exit", (c) => {
358
- console.error(`[Worker] Exited with code ${c}`);
355
+ }), e.on("error", (a) => {
356
+ console.error("[Worker Error]", a);
357
+ }), e.on("exit", (a) => {
358
+ console.error(`[Worker] Exited with code ${a}`);
359
359
  }), e.unref();
360
- const t = Error, n = /* @__PURE__ */ new Set();
361
- function s(...c) {
362
- const l = Reflect.construct(t, c);
363
- Reflect.setPrototypeOf(l, s.prototype), t.captureStackTrace && t.captureStackTrace(l, s);
364
- const a = `${l.message}:${l.stack?.split(`
360
+ const i = Error, n = /* @__PURE__ */ new Set();
361
+ function s(...a) {
362
+ const d = Reflect.construct(i, a);
363
+ Reflect.setPrototypeOf(d, s.prototype), i.captureStackTrace && i.captureStackTrace(d, s);
364
+ const I = `${d.message}:${d.stack?.split(`
365
365
  `)[1]?.trim()}`;
366
- return n.has(a) || (n.add(a), i = l, e.postMessage({ type: "processException", error: l.message })), l;
366
+ return n.has(I) || (n.add(I), t = d, e.postMessage({ type: "processException", error: d.message })), d;
367
367
  }
368
- s.prototype = Object.create(t.prototype, { constructor: { value: s, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(s, t), globalThis.Error = s;
368
+ s.prototype = Object.create(i.prototype, { constructor: { value: s, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(s, i), globalThis.Error = s;
369
369
  }
370
- function P(r) {
371
- return r?.split("/").pop() || "<unknown>";
370
+ function P(o) {
371
+ return o?.split("/").pop() || "<unknown>";
372
372
  }
373
- function x(r, e) {
374
- if (!r || typeof r != "object") return !1;
375
- for (const i of Object.values(r))
376
- if (typeof i == "string" && i.includes(e) || typeof i == "object" && x(i, e)) return !0;
373
+ function x(o, e) {
374
+ if (!o || typeof o != "object") return !1;
375
+ for (const t of Object.values(o))
376
+ if (typeof t == "string" && t.includes(e) || typeof t == "object" && x(t, e)) return !0;
377
377
  return !1;
378
378
  }
379
379
  class j extends V {
380
380
  constructor() {
381
381
  super();
382
- g(this, "serviceIdentifier", new w());
382
+ c(this, "serviceIdentifier", new w());
383
383
  this.setOperationName("CollectExceptions");
384
384
  }
385
385
  async sendAppIdentifier() {
386
386
  this.serviceIdentifier.doSend({});
387
387
  }
388
- async doSend(i, t) {
389
- this.sendAppIdentifier(), this.send(i, t);
388
+ async doSend(t, i) {
389
+ this.sendAppIdentifier(), this.send(t, i);
390
390
  }
391
- async send(i, t) {
392
- o().sfDebug && console.log(" SENDING EXCEPTION...");
393
- const n = JSON.stringify(B.encode(t)), s = this.getVariables({ exceptionMessage: i, traceJson: n, reentrancyGuardPreactive: !1, library: o().packageLibraryType, version: o().version });
391
+ async send(t, i) {
392
+ r().sfDebug && console.log(" SENDING EXCEPTION...");
393
+ const n = JSON.stringify(B.encode(i)), s = this.getVariables({ exceptionMessage: t, traceJson: n, reentrancyGuardPreactive: !1, library: r().packageLibraryType, version: r().version });
394
394
  Z(this.endpoint, this.operationName, this.getQuery(), s);
395
395
  }
396
396
  getQuery() {
@@ -409,7 +409,7 @@ class Q extends K {
409
409
  this.sendAppIdentifier(), this.send(e);
410
410
  }
411
411
  async send(e) {
412
- const i = `
412
+ const t = `
413
413
  ${this.queryType} ${this.operationName}(
414
414
  $apiKey: String!,
415
415
  $serviceUuid: String!,
@@ -421,52 +421,52 @@ class Q extends K {
421
421
  domains: $domains
422
422
  )
423
423
  }
424
- `, t = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
425
- Z(this.endpoint, this.operationName, i, t);
424
+ `, i = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
425
+ Z(this.endpoint, this.operationName, t, i);
426
426
  }
427
427
  }
428
- const _ = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"];
429
- class q {
428
+ const q = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"];
429
+ class _ {
430
430
  constructor(e = []) {
431
- g(this, "HEADER_TRACING", "X-Sf3-Rid");
432
- g(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
433
- g(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
434
- g(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
435
- g(this, "contextManager");
436
- g(this, "excludedDomains");
437
- this.contextManager = W.getInstance(), this.excludedDomains = [..._, ...e].map((i) => i.toLowerCase()), o().sfDebug && console.log("[RequestInterceptor] Initialized.");
431
+ c(this, "HEADER_TRACING", "X-Sf3-Rid");
432
+ c(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
433
+ c(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
434
+ c(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
435
+ c(this, "contextManager");
436
+ c(this, "excludedDomains");
437
+ this.contextManager = W.getInstance(), this.excludedDomains = [...q, ...e].map((t) => t.toLowerCase()), r().sfDebug && console.log("[RequestInterceptor] Initialized.");
438
438
  }
439
439
  addReentrancyGuardHeaders(e) {
440
440
  e.set(this.HEADER_LOG_GUARD, "true"), e.set(this.HEADER_PRINT_GUARD, "true"), e.set(this.HEADER_EXCEPTION_GUARD, "true");
441
441
  }
442
442
  shouldPropagateHeaders(e) {
443
- return !this.excludedDomains.some((i) => new RegExp(`^${i.replace(/\*/g, ".*")}$`).test(e));
443
+ return !this.excludedDomains.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
444
444
  }
445
- addTracingHeaders(e, i) {
446
- const t = new URL(i).hostname;
447
- if (this.shouldPropagateHeaders(t)) {
445
+ addTracingHeaders(e, t) {
446
+ const i = new URL(t).hostname;
447
+ if (this.shouldPropagateHeaders(i)) {
448
448
  const n = this.contextManager.getOrSetSfTraceId();
449
- e.set(this.HEADER_TRACING, n), o().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${i}`);
450
- } else o().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${t}`);
449
+ e.set(this.HEADER_TRACING, n), r().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
450
+ } else r().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`);
451
451
  this.addReentrancyGuardHeaders(e);
452
452
  }
453
453
  patchFetch() {
454
454
  const e = globalThis.fetch;
455
- typeof e == "function" ? globalThis.fetch = async (i, t) => {
456
- const n = Date.now(), s = new Headers(t?.headers);
457
- let c;
458
- typeof i == "string" || i instanceof URL ? c = i.toString() : i instanceof Request ? (c = i.url, i.headers.forEach((a, A) => {
459
- s.set(A, a);
460
- })) : o().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), o().sfDebug && console.log("[RequestInterceptor] Fetching request to:", c), this.addTracingHeaders(s, c);
461
- const l = { ...t, headers: s };
455
+ typeof e == "function" ? globalThis.fetch = async (t, i) => {
456
+ const n = Date.now(), s = new Headers(i?.headers);
457
+ let a;
458
+ typeof t == "string" || t instanceof URL ? a = t.toString() : t instanceof Request ? (a = t.url, t.headers.forEach((I, C) => {
459
+ s.set(C, I);
460
+ })) : r().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), r().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a), this.addTracingHeaders(s, a);
461
+ const d = { ...i, headers: s };
462
462
  try {
463
- const a = await e(c, l), A = Date.now();
464
- return o().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${a.status}, Duration: ${A - n}ms`), a;
465
- } catch (a) {
466
- const A = Date.now();
467
- o().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${a}, Duration: ${A - n}ms`);
463
+ const I = await e(a, d), C = Date.now();
464
+ return r().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${I.status}, Duration: ${C - n}ms`), I;
465
+ } catch (I) {
466
+ const C = Date.now();
467
+ r().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${I}, Duration: ${C - n}ms`);
468
468
  }
469
- } : o().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
469
+ } : r().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
470
470
  }
471
471
  }
472
472
  class ee extends K {
@@ -497,51 +497,53 @@ class ee extends K {
497
497
 
498
498
  )
499
499
  }
500
- `, i = this.getVariables({ serviceIdentifier: o().serviceIdentifier, serviceVersion: o().serviceVersion, serviceAdditionalMetadata: o().serviceAdditionalMetadata });
501
- Z(this.endpoint, this.operationName, e, i);
500
+ `, t = this.getVariables({ serviceIdentifier: r().serviceIdentifier, serviceVersion: r().serviceVersion, serviceAdditionalMetadata: r().serviceAdditionalMetadata });
501
+ Z(this.endpoint, this.operationName, e, t);
502
502
  }
503
503
  }
504
- function se(r) {
505
- const { config: e, created: i } = function(s) {
506
- let c = !1;
507
- return f || (c = !0, s || (s = {}), f = new T(s)), { config: f, created: c };
508
- }(r);
509
- if (!i) return;
504
+ function se(o) {
505
+ if (!o || !o.apiKey) {
506
+ const n = `The required API Key is not provided: ${JSON.stringify(o)}`;
507
+ console.error(n);
508
+ }
509
+ const { config: e } = function(n) {
510
+ return G = new z(n), { config: G };
511
+ }(o);
510
512
  if (e.sfDebug && console.log("Updated configuration after applying options:", e), !e.apiKey || !e.apiGraphqlEndpoint) {
511
- const s = `The required config is not provided: ${JSON.stringify(e)}`;
512
- throw console.error(s), new Error(s);
513
+ const n = `The required config is not provided: ${JSON.stringify(e)}`;
514
+ throw console.error(n), new Error(n);
513
515
  }
514
516
  const t = new K();
515
- t.setServiceUUID(e.serviceUUID), function(s) {
516
- function c(I, u) {
517
- s.setOperationName("CollectLogs"), s.doSend([u, I]);
517
+ t.setServiceUUID(e.serviceUUID), function(n) {
518
+ function s(g, p) {
519
+ n.setOperationName("CollectLogs"), n.doSend([p, g]);
518
520
  }
519
- const l = console.log.bind(console), a = console.error.bind(console), A = console.warn.bind(console), C = console.info.bind(console), d = console.debug.bind(console);
520
- console.log = (...I) => {
521
- c("INFO", I.join(" ")), l(...I);
522
- }, console.error = (...I) => {
523
- c("ERROR", I.join(" ")), a(...I);
524
- }, console.warn = (...I) => {
525
- c("WARN", I.join(" ")), A(...I);
526
- }, console.info = (...I) => {
527
- c("INFO", I.join(" ")), C(...I);
528
- }, o().logLevel === "DEBUG" && (console.debug = (...I) => {
529
- c("DEBUG", I.join(" ")), d(...I);
521
+ const a = console.log.bind(console), d = console.error.bind(console), I = console.warn.bind(console), C = console.info.bind(console), l = console.debug.bind(console);
522
+ console.log = (...g) => {
523
+ s("INFO", g.join(" ")), a(...g);
524
+ }, console.error = (...g) => {
525
+ s("ERROR", g.join(" ")), d(...g);
526
+ }, console.warn = (...g) => {
527
+ s("WARN", g.join(" ")), I(...g);
528
+ }, console.info = (...g) => {
529
+ s("INFO", g.join(" ")), C(...g);
530
+ }, r().logLevel === "DEBUG" && (console.debug = (...g) => {
531
+ s("DEBUG", g.join(" ")), l(...g);
530
532
  });
531
- }(t), function(s = []) {
532
- const c = new q(s);
533
- new Q().doSend(c.excludedDomains), c.patchFetch();
533
+ }(t), function(n = []) {
534
+ const s = new _(n);
535
+ new Q().doSend(s.excludedDomains), s.patchFetch();
534
536
  }(e.domainsToNotPropagateHeadersTo);
535
- const n = new j();
536
- n.setServiceUUID(e.serviceUUID), M(n), new ee().send();
537
+ const i = new j();
538
+ i.setServiceUUID(e.serviceUUID), M(i), new ee().send();
537
539
  }
538
- function oe(r, e, i, t = !1) {
539
- const n = o();
540
- new U(n.apiKey).identify(r, e, i, t);
540
+ function oe(o, e, t, i = !1) {
541
+ const n = r();
542
+ new U(n.apiKey).identify(o, e, t, i);
541
543
  }
542
- function re(r, e = {}, i, t = !1) {
543
- const n = o();
544
- new U(n.apiKey).addOrUpdateMetadata(r, e, i, t);
544
+ function re(o, e = {}, t, i = !1) {
545
+ const n = r();
546
+ new U(n.apiKey).addOrUpdateMetadata(o, e, t, i);
545
547
  }
546
548
  export {
547
549
  re as addOrUpdateMetadata,
@@ -2,7 +2,7 @@
2
2
  * Interface for setting up options for the service configuration.
3
3
  */
4
4
  export interface SetupOptions {
5
- apiKey?: string;
5
+ apiKey: string;
6
6
  /**
7
7
  * Optional identifier for api key
8
8
  */
@@ -55,7 +55,6 @@ export interface SetupOptions {
55
55
  }
56
56
  export interface GetOrCreateConfig {
57
57
  config: AppConfig;
58
- created: boolean;
59
58
  }
60
59
  declare class AppConfig {
61
60
  apiKey: string;
@@ -83,7 +82,7 @@ declare class AppConfig {
83
82
  setServiceIdentificationReceived(value: boolean): void;
84
83
  }
85
84
  /**
86
- * Create the global configuration with the provided SetupOptions or return if it is already created.
85
+ * Create the global configuration with the provided SetupOptions
87
86
  * This should be called once at the start of the application.
88
87
  */
89
88
  export declare function getOrCreateConfig(options: SetupOptions): GetOrCreateConfig;
@@ -6,7 +6,7 @@ import { Traits } from "./utils";
6
6
  * Initializes configuration settings for the application, checks for required
7
7
  * configuration variables, and sets up log, exception, and metadata interceptors.
8
8
  */
9
- export declare function setupInterceptors(options?: SetupOptions): void;
9
+ export declare function setupInterceptors(options: SetupOptions): void;
10
10
  /**
11
11
  * Identifies a user and optionally updates their metadata.
12
12
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailfish-ai/sf-veritas",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "publishPublicly": true,
5
5
  "description": "A versatile Edge Runtime-compatible package for Next.js.",
6
6
  "main": "./dist/sf-veritas.cjs",