@sailfish-ai/sf-veritas 0.1.20-alpha0 → 0.1.22
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/dist/sf-veritas.cjs +8 -8
- package/dist/sf-veritas.mjs +156 -146
- package/dist/types/contextManager.d.ts +4 -0
- package/package.json +1 -1
package/dist/sf-veritas.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var E=Object.defineProperty;var L=(
|
|
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 c=(r,e,i)=>L(r,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("async_hooks"),$=require("worker_threads"),A=[];for(let r=0;r<256;++r)A.push((r+256).toString(16).slice(1));let H;const F=new Uint8Array(16),D={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function f(r,e,i){if(D.randomUUID&&!r)return D.randomUUID();const t=(r=r||{}).random??r.rng?.()??function(){if(!H){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");H=crypto.getRandomValues.bind(crypto)}return H(F)}();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 T{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=f(),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 V;function o(){if(!V)throw new Error("Configuration has not been initialized.");return V}new U.AsyncLocalStorage;const J=new U.AsyncLocalStorage,X={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 J.getStore()||X}setCurrentContext(e){const i=J.getStore()||X;J.enterWith({...i,...e})}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getOrSetSfTraceId(e,i=!1){let t=this.getTraceId();return t||(t=e||(i?f():`nonsession-applogs-v3/${o().apiKey}/${f()}`),this.setTraceId(t),o().sfDebug&&console.log(" Created new trace ID:",t),t)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=f(),this.setPageVisitUUID(e),o().sfDebug&&console.log(" Created new page visit UUID:",e),e)}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 B{constructor(){c(this,"apiKey");c(this,"endpoint");c(this,"queryType","mutation");c(this,"operationName","");c(this,"serviceUUID",o().serviceUUID);c(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 z=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})}z(r,{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),o().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){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=`
|
|
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:
|
|
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 O(r){try{return JSON.stringify(r),!0}catch{return!1}}class k extends B{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))O(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:o().packageLibraryType,version:o().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
|
|
27
|
+
`}}class R{constructor(e){c(this,"metadataTransmitter");this.apiKey=e,this.metadataTransmitter=new k}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();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){o().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 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 $.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7Cgpn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bG9jYXRpb24sIHVybCwgc2NvcGVDaGFpbiB9ID0gZnJhbWU7CiAgICAgICAgY29uc3QgbG9jYWxTY29wZSA9IHNjb3BlQ2hhaW4uZmluZCgoc2NvcGUpID0+IHNjb3BlLnR5cGUgPT09ICJsb2NhbCIpOwoKICAgICAgICBsZXQgY29kZSA9ICI8bm90IGNhcHR1cmVkPiI7CiAgICAgICAgbGV0IGZpbGUgPSB1cmwgfHwgIjx1bmtub3duPiI7CiAgICAgICAgaWYgKGxvY2F0aW9uICYmIGxvY2F0aW9uLnNjcmlwdElkKSB7CiAgICAgICAgICBjb25zdCBzY3JpcHRJZCA9IGxvY2F0aW9uLnNjcmlwdElkOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgeyBzY3JpcHRTb3VyY2UgfSA9IGF3YWl0IHNlc3Npb24ucG9zdCgKICAgICAgICAgICAgICAiRGVidWdnZXIuZ2V0U2NyaXB0U291cmNlIiwKICAgICAgICAgICAgICB7IHNjcmlwdElkIH0sCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIGNvbnN0IHNvdXJjZUxpbmVzID0gc2NyaXB0U291cmNlLnNwbGl0KCJcbiIpOwogICAgICAgICAgICBjb2RlID0gc291cmNlTGluZXNbbG9jYXRpb24ubGluZU51bWJlcl0gfHwgIjxub3QgY2FwdHVyZWQ+IjsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBGYWlsZWQgdG8gZmV0Y2ggc2NyaXB0IHNvdXJjZToiLCBlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBjb25zdCBsb2NhbHMgPSBsb2NhbFNjb3BlPy5vYmplY3Q/Lm9iamVjdElkCiAgICAgICAgICA/IGF3YWl0IGZldGNoTG9jYWxWYXJpYWJsZXMoc2Vzc2lvbiwgbG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jdCIKICAgICAgICApIHsKICAgICAgICAgIGNvbnN0IGlkID0gcHJvcC52YWx1ZS5vYmplY3RJZDsKICAgICAgICAgIGF3YWl0IHVucm9sbE9iamVjdChzZXNzaW9uLCBpZCwgcHJvcC5uYW1lLCB2YXJpYWJsZXMpOwogICAgICAgIH0gZWxzZSBpZiAocHJvcD8udmFsdWUpIHsKICAgICAgICAgIHVucm9sbE90aGVyKHByb3AsIHZhcmlhYmxlcyk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB2YXJpYWJsZXM7CiAgICB9CiAgfSBjYXRjaCAoZXJyKSB7CiAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIGZldGNoIGxvY2FsIHZhcmlhYmxlczoiLCBlcnIpOwogICAgfQogICAgcmV0dXJuIHt9OwogIH0KfQoKc3RhcnREZWJ1Z2dlcigpLmNhdGNoKChlcnJvcikgPT4gewogIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIHN0YXJ0IGRlYnVnZ2VyOiIsIGVycm9yKTsKICB9Cn0pOwoKLy8gS2VlcCB0aGUgd29ya2VyIGFsaXZlCnNldEludGVydmFsKCgpID0+IHt9LCAxMDAwMCk7Cg=="),{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 Y=g[b];if(x(Y,m)||typeof Y.file=="string"&&Y.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,
|
|
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(
|
|
31
|
+
`}}class N{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 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 $.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZ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IGxpbWl0ZWRDYWxsRnJhbWVzLm1hcChhc3luYyAoZnJhbWUpID0+IHsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCB7IGZ1bmN0aW9uTmFtZSwgbG9jYXRpb24sIHVybCwgc2NvcGVDaGFpbiB9ID0gZnJhbWU7CiAgICAgICAgY29uc3QgbG9jYWxTY29wZSA9IHNjb3BlQ2hhaW4uZmluZCgoc2NvcGUpID0+IHNjb3BlLnR5cGUgPT09ICJsb2NhbCIpOwoKICAgICAgICBsZXQgY29kZSA9ICI8bm90IGNhcHR1cmVkPiI7CiAgICAgICAgbGV0IGZpbGUgPSB1cmwgfHwgIjx1bmtub3duPiI7CiAgICAgICAgaWYgKGxvY2F0aW9uICYmIGxvY2F0aW9uLnNjcmlwdElkKSB7CiAgICAgICAgICBjb25zdCBzY3JpcHRJZCA9IGxvY2F0aW9uLnNjcmlwdElkOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgeyBzY3JpcHRTb3VyY2UgfSA9IGF3YWl0IHNlc3Npb24ucG9zdCgKICAgICAgICAgICAgICAiRGVidWdnZXIuZ2V0U2NyaXB0U291cmNlIiwKICAgICAgICAgICAgICB7IHNjcmlwdElkIH0sCiAgICAgICAgICAgICk7CiAgICAgICAgICAgIGNvbnN0IHNvdXJjZUxpbmVzID0gc2NyaXB0U291cmNlLnNwbGl0KCJcbiIpOwogICAgICAgICAgICBjb2RlID0gc291cmNlTGluZXNbbG9jYXRpb24ubGluZU51bWJlcl0gfHwgIjxub3QgY2FwdHVyZWQ+IjsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBGYWlsZWQgdG8gZmV0Y2ggc2NyaXB0IHNvdXJjZToiLCBlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBjb25zdCBsb2Nh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SBlbHNlIGlmICgKICAgICAgICAgIHByb3A/LnZhbHVlPy5vYmplY3RJZCAmJgogICAgICAgICAgcHJvcD8udmFsdWU/LmNsYXNzTmFtZSA9PT0gIk9iamVjdCIKICAgICAgICApIHsKICAgICAgICAgIGNvbnN0IGlkID0gcHJvcC52YWx1ZS5vYmplY3RJZDsKICAgICAgICAgIGF3YWl0IHVucm9sbE9iamVjdChzZXNzaW9uLCBpZCwgcHJvcC5uYW1lLCB2YXJpYWJsZXMpOwogICAgICAgIH0gZWxzZSBpZiAocHJvcD8udmFsdWUpIHsKICAgICAgICAgIHVucm9sbE90aGVyKHByb3AsIHZhcmlhYmxlcyk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiB2YXJpYWJsZXM7CiAgICB9CiAgfSBjYXRjaCAoZXJyKSB7CiAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIGZldGNoIGxvY2FsIHZhcmlhYmxlczoiLCBlcnIpOwogICAgfQogICAgcmV0dXJuIHt9OwogIH0KfQoKc3RhcnREZWJ1Z2dlcigpLmNhdGNoKChlcnJvcikgPT4gewogIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRmFpbGVkIHRvIHN0YXJ0IGRlYnVnZ2VyOiIsIGVycm9yKTsKICB9Cn0pOwoKLy8gS2VlcCB0aGUgd29ya2VyIGFsaXZlCnNldEludGVydmFsKCgpID0+IHt9LCAxMDAwMCk7Cg=="),{workerData:{captureAllExceptions:!0}});let i=null;e.on("message",a=>{if(typeof a=="string"&&o().sfDebug&&console.log(`[Worker] ${a}`),a.readyToGetParameters&&e.postMessage({sfDebug:o().sfDebug,stackDepthLocals:o().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:o().nodeModulesToCollectLocalVariablesOn}),a.type==="exception"){const{frames:d}=a,I=i;if(!I)return;const C=function(l,g){const p=[];let h=-1,G=-1;for(let u=0;u<l.length;u++){const m=P(l[u].file);if(G=u,m!=="<unknown>"){for(let b=0;b<g.length;b++){const Y=g[b];if(x(Y,m)||typeof Y.file=="string"&&Y.file.includes(m)){h=b,v=0,o().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,o().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${v}"`),[]);o().sfDebug&&console.log(`🔄 Merging from matched index ${h} onward...`);for(let u=0;u<g.length;u++){const m=l[G+u],b=g[h+u];p.push(new N({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,G,u]=p;return new N({function:h||"<anonymous>",locals:{},file:G||"<unknown>",line:parseInt(u,10)||0,code:"<not captured>"})}return new N({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>"})}):[]}(I.stack),d||[]);if(C.length!==0){i=null;const l=o().stackDepthCodeTraceDepth,g=l===-1?C:C.slice(0,l+1);r.setOperationName("CollectExceptions");const p=I.message?`${I.name}: ${I.message}`:I.name;o().sfDebug&&console.log("error message is : ",p),r.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(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();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){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`
|
|
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=[]){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=
|
|
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()),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(),s=this.contextManager.getOrSetPageVisitUUID(),a=f();e.set(this.HEADER_TRACING,`${n}/${s}/${a}`),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 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)})):o().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),o().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 o().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${I.status}, Duration: ${C-n}ms`),I}catch(I){const C=Date.now();o().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${I}, Duration: ${C-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=`
|
|
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:
|
|
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 R(n.apiKey).addOrUpdateMetadata(r,e,i,t)},exports.identify=function(r,e,i,t=!1){const n=o();new R(n.apiKey).identify(r,e,i,t)},exports.setupInterceptors=function(r){if(!r||!r.apiKey){const n=`The required API Key is not provided: ${JSON.stringify(r)}`;console.error(n)}const{config:e}=function(n){return V=new T(n),{config:V}}(r);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)},o().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()};
|
package/dist/sf-veritas.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
var E = Object.defineProperty;
|
|
2
|
-
var L = (
|
|
3
|
-
var c = (
|
|
4
|
-
import { AsyncLocalStorage as
|
|
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 c = (r, e, i) => L(r, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
import { AsyncLocalStorage as R } from "async_hooks";
|
|
5
5
|
import { Worker as $ } from "worker_threads";
|
|
6
6
|
const A = [];
|
|
7
|
-
for (let
|
|
7
|
+
for (let r = 0; r < 256; ++r) A.push((r + 256).toString(16).slice(1));
|
|
8
8
|
let H;
|
|
9
|
-
const F = new Uint8Array(16),
|
|
10
|
-
function
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
9
|
+
const F = new Uint8Array(16), D = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
10
|
+
function f(r, e, i) {
|
|
11
|
+
if (D.randomUUID && !r) return D.randomUUID();
|
|
12
|
+
const t = (r = r || {}).random ?? r.rng?.() ?? function() {
|
|
13
13
|
if (!H) {
|
|
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
|
H = crypto.getRandomValues.bind(crypto);
|
|
16
16
|
}
|
|
17
17
|
return H(F);
|
|
18
18
|
}();
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
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
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
|
-
}(
|
|
22
|
+
}(t);
|
|
23
23
|
}
|
|
24
24
|
class T {
|
|
25
25
|
constructor(e) {
|
|
@@ -42,7 +42,7 @@ class T {
|
|
|
42
42
|
c(this, "packageLibraryType");
|
|
43
43
|
c(this, "version");
|
|
44
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 =
|
|
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 = f(), 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,41 +54,51 @@ class T {
|
|
|
54
54
|
this._serviceIdentificationReceived = e;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
let
|
|
58
|
-
function
|
|
59
|
-
if (!
|
|
60
|
-
return
|
|
57
|
+
let V;
|
|
58
|
+
function o() {
|
|
59
|
+
if (!V) throw new Error("Configuration has not been initialized.");
|
|
60
|
+
return V;
|
|
61
61
|
}
|
|
62
|
-
new
|
|
63
|
-
const J = new
|
|
62
|
+
new R();
|
|
63
|
+
const J = new R(), X = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1 }, y = class y {
|
|
64
64
|
constructor() {
|
|
65
65
|
}
|
|
66
66
|
static getInstance() {
|
|
67
67
|
return y.instance || (y.instance = new y()), y.instance;
|
|
68
68
|
}
|
|
69
69
|
getCurrentContext() {
|
|
70
|
-
return J.getStore() ||
|
|
70
|
+
return J.getStore() || X;
|
|
71
71
|
}
|
|
72
72
|
setCurrentContext(e) {
|
|
73
|
-
const
|
|
74
|
-
J.enterWith({ ...
|
|
73
|
+
const i = J.getStore() || X;
|
|
74
|
+
J.enterWith({ ...i, ...e });
|
|
75
75
|
}
|
|
76
76
|
getTraceId() {
|
|
77
77
|
return this.getCurrentContext().traceId;
|
|
78
78
|
}
|
|
79
|
+
getPageVisitUUID() {
|
|
80
|
+
return this.getCurrentContext().pageVisitUUID;
|
|
81
|
+
}
|
|
79
82
|
setTraceId(e) {
|
|
80
83
|
this.setCurrentContext({ traceId: e });
|
|
81
84
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
setPageVisitUUID(e) {
|
|
86
|
+
this.setCurrentContext({ pageVisitUUID: e });
|
|
87
|
+
}
|
|
88
|
+
getOrSetSfTraceId(e, i = !1) {
|
|
89
|
+
let t = this.getTraceId();
|
|
90
|
+
return t || (t = e || (i ? f() : `nonsession-applogs-v3/${o().apiKey}/${f()}`), this.setTraceId(t), o().sfDebug && console.log(" Created new trace ID:", t), t);
|
|
91
|
+
}
|
|
92
|
+
getOrSetPageVisitUUID() {
|
|
93
|
+
let e = this.getPageVisitUUID();
|
|
94
|
+
return e || (e = f(), this.setPageVisitUUID(e), o().sfDebug && console.log(" Created new page visit UUID:", e), e);
|
|
85
95
|
}
|
|
86
96
|
getHandledExceptions() {
|
|
87
97
|
return this.getCurrentContext().handledExceptions;
|
|
88
98
|
}
|
|
89
99
|
markExceptionHandled(e) {
|
|
90
|
-
const
|
|
91
|
-
|
|
100
|
+
const i = this.getHandledExceptions();
|
|
101
|
+
i.add(e), this.setCurrentContext({ handledExceptions: i });
|
|
92
102
|
}
|
|
93
103
|
hasHandledException(e) {
|
|
94
104
|
return this.getHandledExceptions().has(e);
|
|
@@ -98,23 +108,23 @@ const J = new D(), R = { handledExceptions: /* @__PURE__ */ new Set(), reentranc
|
|
|
98
108
|
}
|
|
99
109
|
};
|
|
100
110
|
c(y, "instance");
|
|
101
|
-
let
|
|
111
|
+
let W = y;
|
|
102
112
|
class S {
|
|
103
113
|
constructor() {
|
|
104
114
|
c(this, "apiKey");
|
|
105
115
|
c(this, "endpoint");
|
|
106
116
|
c(this, "queryType", "mutation");
|
|
107
117
|
c(this, "operationName", "");
|
|
108
|
-
c(this, "serviceUUID",
|
|
118
|
+
c(this, "serviceUUID", o().serviceUUID);
|
|
109
119
|
c(this, "contextManager");
|
|
110
|
-
this.apiKey =
|
|
120
|
+
this.apiKey = o().apiKey, this.endpoint = o().apiGraphqlEndpoint, this.contextManager = W.getInstance();
|
|
111
121
|
}
|
|
112
122
|
get queryName() {
|
|
113
123
|
return this.operationName ? this.operationName.charAt(0).toLowerCase() + this.operationName.slice(1) : "";
|
|
114
124
|
}
|
|
115
125
|
getDefaultVariables() {
|
|
116
|
-
const e = Date.now().toString(),
|
|
117
|
-
return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId:
|
|
126
|
+
const e = Date.now().toString(), i = this.contextManager.getOrSetSfTraceId();
|
|
127
|
+
return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: i, timestampMs: e };
|
|
118
128
|
}
|
|
119
129
|
getVariables(e = {}) {
|
|
120
130
|
return { ...this.getDefaultVariables(), ...e };
|
|
@@ -130,16 +140,16 @@ class S {
|
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
const z = fetch;
|
|
133
|
-
async function Z(
|
|
143
|
+
async function Z(r, e, i, t) {
|
|
134
144
|
try {
|
|
135
|
-
const n =
|
|
145
|
+
const n = o();
|
|
136
146
|
let s;
|
|
137
147
|
try {
|
|
138
|
-
s = JSON.stringify({ query:
|
|
148
|
+
s = JSON.stringify({ query: i, variables: t, operationName: e });
|
|
139
149
|
} catch {
|
|
140
|
-
s = JSON.stringify({ query:
|
|
150
|
+
s = JSON.stringify({ query: i, operationName: e });
|
|
141
151
|
}
|
|
142
|
-
z(
|
|
152
|
+
z(r, { method: "POST", headers: { "Content-Type": "application/json" }, body: s }).then(async (a) => {
|
|
143
153
|
if (!a.ok) return void (n.sfDebug && console.error(`GraphQL request failed with status ${a.status} for ${e}`));
|
|
144
154
|
const d = await a.json();
|
|
145
155
|
d.errors?.length ? function(I, C, l) {
|
|
@@ -147,13 +157,13 @@ async function Z(o, e, t, i) {
|
|
|
147
157
|
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
158
|
}(d.data, d.errors, n) : n.sfDebug && function(I, C, l) {
|
|
149
159
|
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),
|
|
160
|
+
g === "identifyServiceDetails" && (l.setServiceIdentificationReceived(p), o().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${l.serviceUUID}; serviceIdentificationReceived=${g === "identifyServiceDetails" ? p : "N/A"}`));
|
|
151
161
|
}(d.data, 0, n);
|
|
152
162
|
}).catch((a) => {
|
|
153
163
|
n.sfDebug && console.error("Fetch error:", a);
|
|
154
164
|
});
|
|
155
165
|
} catch (n) {
|
|
156
|
-
|
|
166
|
+
o().sfDebug && console.error("Error sending data to GraphQL server:", n);
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
class w extends S {
|
|
@@ -161,10 +171,10 @@ class w extends S {
|
|
|
161
171
|
super(), this.setOperationName("IdentifyServiceDetails");
|
|
162
172
|
}
|
|
163
173
|
async doSend(e) {
|
|
164
|
-
if (!
|
|
174
|
+
if (!o().serviceIdentificationReceived) try {
|
|
165
175
|
this.send();
|
|
166
|
-
} catch (
|
|
167
|
-
|
|
176
|
+
} catch (i) {
|
|
177
|
+
o().sfDebug && console.error(" Error during service identification:", i);
|
|
168
178
|
}
|
|
169
179
|
}
|
|
170
180
|
async send() {
|
|
@@ -190,18 +200,18 @@ class w extends S {
|
|
|
190
200
|
version: $version,
|
|
191
201
|
)
|
|
192
202
|
}
|
|
193
|
-
`,
|
|
194
|
-
Z(this.endpoint, this.operationName, e,
|
|
203
|
+
`, i = this.getVariables({ serviceIdentifier: o().serviceIdentifier, serviceVersion: o().serviceVersion, library: o().packageLibraryType, version: o().version, serviceAdditionalMetadata: o().serviceAdditionalMetadata });
|
|
204
|
+
Z(this.endpoint, this.operationName, e, i);
|
|
195
205
|
}
|
|
196
206
|
}
|
|
197
|
-
function
|
|
207
|
+
function O(r) {
|
|
198
208
|
try {
|
|
199
|
-
return JSON.stringify(
|
|
209
|
+
return JSON.stringify(r), !0;
|
|
200
210
|
} catch {
|
|
201
211
|
return !1;
|
|
202
212
|
}
|
|
203
213
|
}
|
|
204
|
-
class
|
|
214
|
+
class k extends S {
|
|
205
215
|
constructor() {
|
|
206
216
|
super();
|
|
207
217
|
c(this, "serviceIdentifier", new w());
|
|
@@ -210,21 +220,21 @@ class O extends S {
|
|
|
210
220
|
async sendAppIdentifier() {
|
|
211
221
|
this.serviceIdentifier.doSend({});
|
|
212
222
|
}
|
|
213
|
-
async doSend(
|
|
214
|
-
this.sendAppIdentifier(), this.send(
|
|
223
|
+
async doSend(i, t, n, s) {
|
|
224
|
+
this.sendAppIdentifier(), this.send(i, t, n, s);
|
|
215
225
|
}
|
|
216
|
-
async send(
|
|
217
|
-
if (!
|
|
226
|
+
async send(i, t, n, s) {
|
|
227
|
+
if (!t && !s) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
|
|
218
228
|
let a = [];
|
|
219
229
|
if (!s) {
|
|
220
230
|
const I = function(C) {
|
|
221
231
|
const l = {}, g = [];
|
|
222
|
-
if (C) for (const [p, h] of Object.entries(C))
|
|
232
|
+
if (C) for (const [p, h] of Object.entries(C)) O(h) ? l[p] = h : g.push(p);
|
|
223
233
|
return { traitsJson: JSON.stringify(l), excludedFields: g };
|
|
224
|
-
}(
|
|
234
|
+
}(t);
|
|
225
235
|
s = I.traitsJson, a = I.excludedFields;
|
|
226
236
|
}
|
|
227
|
-
const d = this.getVariables({ userId:
|
|
237
|
+
const d = this.getVariables({ userId: i, traitsJson: s, excludedFields: a, override: n, library: o().packageLibraryType, version: o().version });
|
|
228
238
|
Z(this.endpoint, this.operationName, this.getQuery(), d);
|
|
229
239
|
}
|
|
230
240
|
getQuery() {
|
|
@@ -238,14 +248,14 @@ class O extends S {
|
|
|
238
248
|
class U {
|
|
239
249
|
constructor(e) {
|
|
240
250
|
c(this, "metadataTransmitter");
|
|
241
|
-
this.apiKey = e, this.metadataTransmitter = new
|
|
251
|
+
this.apiKey = e, this.metadataTransmitter = new k();
|
|
242
252
|
}
|
|
243
|
-
identify(e,
|
|
244
|
-
|
|
253
|
+
identify(e, i, t, n = !1) {
|
|
254
|
+
i || t ? this.addOrUpdateMetadata(e, i, t, n) : this.addOrUpdateMetadata(e, {}, void 0, n);
|
|
245
255
|
}
|
|
246
|
-
addOrUpdateMetadata(e,
|
|
247
|
-
if (!
|
|
248
|
-
|
|
256
|
+
addOrUpdateMetadata(e, i = {}, t, n = !1) {
|
|
257
|
+
if (!i && !t) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
|
|
258
|
+
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);
|
|
249
259
|
}
|
|
250
260
|
}
|
|
251
261
|
class K extends S {
|
|
@@ -256,15 +266,15 @@ class K extends S {
|
|
|
256
266
|
async sendAppIdentifier() {
|
|
257
267
|
this.serviceIdentifier.doSend({});
|
|
258
268
|
}
|
|
259
|
-
async doSend(
|
|
260
|
-
this.sendAppIdentifier(), this.send(
|
|
269
|
+
async doSend(i) {
|
|
270
|
+
this.sendAppIdentifier(), this.send(i);
|
|
261
271
|
}
|
|
262
|
-
async send(
|
|
272
|
+
async send(i) {
|
|
263
273
|
try {
|
|
264
|
-
const
|
|
274
|
+
const t = Array.isArray(i) ? i : [i, "default"], n = this.getVariables({ contents: t[0], level: t[1] });
|
|
265
275
|
Z(this.endpoint, this.operationName, this.getQuery(), n);
|
|
266
|
-
} catch (
|
|
267
|
-
|
|
276
|
+
} catch (t) {
|
|
277
|
+
o().sfDebug && console.error("🚨 Error in send():", t);
|
|
268
278
|
}
|
|
269
279
|
}
|
|
270
280
|
getQuery() {
|
|
@@ -275,62 +285,62 @@ class K extends S {
|
|
|
275
285
|
`;
|
|
276
286
|
}
|
|
277
287
|
}
|
|
278
|
-
class
|
|
279
|
-
constructor({ file: e, line:
|
|
288
|
+
class N {
|
|
289
|
+
constructor({ file: e, line: i, function: t, code: n, locals: s = {}, offender: a = !1 }) {
|
|
280
290
|
c(this, "file");
|
|
281
291
|
c(this, "line");
|
|
282
292
|
c(this, "function");
|
|
283
293
|
c(this, "code");
|
|
284
294
|
c(this, "locals");
|
|
285
295
|
c(this, "offender");
|
|
286
|
-
this.file = e, this.line =
|
|
296
|
+
this.file = e, this.line = i, this.function = t, this.code = n, this.locals = s, this.offender = a;
|
|
287
297
|
}
|
|
288
298
|
toDict() {
|
|
289
|
-
const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([
|
|
299
|
+
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)])) };
|
|
290
300
|
return this.offender && (e.offender = this.offender), e;
|
|
291
301
|
}
|
|
292
302
|
toJson() {
|
|
293
303
|
return JSON.stringify(this.toDict());
|
|
294
304
|
}
|
|
295
305
|
}
|
|
296
|
-
class
|
|
306
|
+
class B {
|
|
297
307
|
static encode(e) {
|
|
298
|
-
return e instanceof
|
|
308
|
+
return e instanceof N ? e.toDict() : Array.isArray(e) ? e.map((i) => B.encode(i)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
|
|
299
309
|
}
|
|
300
310
|
static stringify(e) {
|
|
301
|
-
return JSON.stringify(
|
|
311
|
+
return JSON.stringify(B.encode(e), (i, t) => t instanceof N ? t.toDict() : t);
|
|
302
312
|
}
|
|
303
313
|
}
|
|
304
314
|
let v = 0;
|
|
305
|
-
function M(
|
|
306
|
-
|
|
315
|
+
function M(r) {
|
|
316
|
+
o().sfDebug && console.log("Initializing Exception Interceptor...");
|
|
307
317
|
const e = new $(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5lcnJvcklkID0gdW5kZWZpbmVkOwpnbG9iYWwubm9kZU1vZHVsZXNUb0NvbGxlY3RMb2NhbFZhcmlhYmxlc09uID0gdW5kZWZpbmVkOwoKLyoqCiAqIEhhbmRsZXMgdGhlICJwYXVzZWQiIHN0YXRlIG9mIHRoZSBkZWJ1Z2dlciBhbmQgcHJvY2Vzc2VzIGV4Y2VwdGlvbnMgb3IgcHJvbWlzZSByZWplY3Rpb25zLgogKiBAcGFyYW0ge1Nlc3Npb259IHNlc3Npb24gLSBUaGUgZGVidWdnaW5nIHNlc3Npb24gaW5zdGFuY2UuCiAqIEBwYXJhbSB7b2JqZWN0fSBwYXJhbXMgLSBQYXJhbWV0ZXJzIGZyb20gdGhlICJwYXVzZWQiIGV2ZW50LgogKi8KYXN5bmMgZnVuY3Rpb24gaGFuZGxlUGF1c2VkKHNlc3Npb24sIHBhcmFtcykgewogIGNvbnN0IHsgcmVhc29uLCBkYXRhLCB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mNlLnNwbGl0KCJcbiIpOwogICAgICAgICAgICBjb2RlID0gc291cmNlTGluZXNbbG9jYXRpb24ubGluZU51bWJlcl0gfHwgIjxub3QgY2FwdHVyZWQ+IjsKICAgICAgICAgIH0gY2F0Y2ggKGVycikgewogICAgICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBGYWlsZWQgdG8gZmV0Y2ggc2NyaXB0IHNvdXJjZToiLCBlcnIpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBjb25zdCBsb2NhbHMgPSBsb2NhbFNjb3BlPy5vYmplY3Q/Lm9iamVjdElkCiAgICAgICAgICA/IGF3YWl0IGZldGNoTG9jYWxWYXJpYWJsZXMoc2Vzc2lvbiwgbG9jYWxTY29wZS5vYmplY3Qub2JqZWN0SWQpCiAgICAgICAgICA6IHt9OwoKICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246IGZ1bmN0aW9uTmFtZSB8fCAiPGFub255bW91cz4iLAogICAgICAgICAgbG9jYWxzLAogICAgICAgICAgZmlsZSwKICAgICAgICAgIGxpbmU6IGxvY2F0aW9uPy5saW5lTnVtYmVyIHx8IDAsCiAgICAgICAgICBjb2RlLAogICAgICAgIH07CiAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICBjb25zb2xlLmVycm9yKCJbV29ya2VyXSBFcnJvciBwcm9jZXNzaW5nIGNhbGwgZnJhbWU6IiwgZXJyb3IpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gewogICAgICAgICAgZnVuY3Rpb246ICI8ZXJyb3I+IiwKICAgICAgICAgIGxvY2Fsczoge30sCiAgICAgICAgICBmaWxlOiAiPHVua25vd24+IiwKICAgICAgICAgIGxpbmU6IDAsCiAgICAgICAgICBjb2RlOiAiPG5vdCBjYXB0d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vIHN0YXJ0IGRlYnVnZ2VyOiIsIGVycm9yKTsKICB9Cn0pOwoKLy8gS2VlcCB0aGUgd29ya2VyIGFsaXZlCnNldEludGVydmFsKCgpID0+IHt9LCAxMDAwMCk7Cg=="), { workerData: { captureAllExceptions: !0 } });
|
|
308
|
-
let
|
|
318
|
+
let i = null;
|
|
309
319
|
e.on("message", (a) => {
|
|
310
|
-
if (typeof a == "string" &&
|
|
311
|
-
const { frames: d } = a, I =
|
|
320
|
+
if (typeof a == "string" && o().sfDebug && console.log(`[Worker] ${a}`), a.readyToGetParameters && e.postMessage({ sfDebug: o().sfDebug, stackDepthLocals: o().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: o().nodeModulesToCollectLocalVariablesOn }), a.type === "exception") {
|
|
321
|
+
const { frames: d } = a, I = i;
|
|
312
322
|
if (!I) return;
|
|
313
323
|
const C = function(l, g) {
|
|
314
324
|
const p = [];
|
|
315
|
-
let h = -1,
|
|
325
|
+
let h = -1, G = -1;
|
|
316
326
|
for (let u = 0; u < l.length; u++) {
|
|
317
327
|
const m = P(l[u].file);
|
|
318
|
-
if (
|
|
328
|
+
if (G = u, m !== "<unknown>") {
|
|
319
329
|
for (let b = 0; b < g.length; b++) {
|
|
320
330
|
const Y = g[b];
|
|
321
331
|
if (x(Y, m) || typeof Y.file == "string" && Y.file.includes(m)) {
|
|
322
|
-
h = b, v = 0,
|
|
332
|
+
h = b, v = 0, o().sfDebug && console.log(`✅ Matched Frame Found: ${m} @ Debugger Frame ${b}`);
|
|
323
333
|
break;
|
|
324
334
|
}
|
|
325
335
|
}
|
|
326
336
|
if (h !== -1) break;
|
|
327
337
|
}
|
|
328
338
|
}
|
|
329
|
-
if (h === -1) return v === 10 ? (v = 0, l) : (++v,
|
|
330
|
-
|
|
339
|
+
if (h === -1) return v === 10 ? (v = 0, l) : (++v, o().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${v}"`), []);
|
|
340
|
+
o().sfDebug && console.log(`🔄 Merging from matched index ${h} onward...`);
|
|
331
341
|
for (let u = 0; u < g.length; u++) {
|
|
332
|
-
const m = l[
|
|
333
|
-
p.push(new
|
|
342
|
+
const m = l[G + u], b = g[h + u];
|
|
343
|
+
p.push(new N({ 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
344
|
}
|
|
335
345
|
return p;
|
|
336
346
|
}(function(l) {
|
|
@@ -338,18 +348,18 @@ function M(o) {
|
|
|
338
348
|
`).slice(1).map((g) => {
|
|
339
349
|
const p = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(g) || /at (.+):(\d+):(\d+)/.exec(g);
|
|
340
350
|
if (p) {
|
|
341
|
-
const [, h,
|
|
342
|
-
return new
|
|
351
|
+
const [, h, G, u] = p;
|
|
352
|
+
return new N({ function: h || "<anonymous>", locals: {}, file: G || "<unknown>", line: parseInt(u, 10) || 0, code: "<not captured>" });
|
|
343
353
|
}
|
|
344
|
-
return new
|
|
354
|
+
return new N({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>" });
|
|
345
355
|
}) : [];
|
|
346
356
|
}(I.stack), d || []);
|
|
347
357
|
if (C.length !== 0) {
|
|
348
|
-
|
|
349
|
-
const l =
|
|
350
|
-
|
|
358
|
+
i = null;
|
|
359
|
+
const l = o().stackDepthCodeTraceDepth, g = l === -1 ? C : C.slice(0, l + 1);
|
|
360
|
+
r.setOperationName("CollectExceptions");
|
|
351
361
|
const p = I.message ? `${I.name}: ${I.message}` : I.name;
|
|
352
|
-
|
|
362
|
+
o().sfDebug && console.log("error message is : ", p), r.doSend(p, g);
|
|
353
363
|
}
|
|
354
364
|
}
|
|
355
365
|
}), e.on("error", (a) => {
|
|
@@ -357,23 +367,23 @@ function M(o) {
|
|
|
357
367
|
}), e.on("exit", (a) => {
|
|
358
368
|
console.error(`[Worker] Exited with code ${a}`);
|
|
359
369
|
}), e.unref();
|
|
360
|
-
const
|
|
370
|
+
const t = Error, n = /* @__PURE__ */ new Set();
|
|
361
371
|
function s(...a) {
|
|
362
|
-
const d = Reflect.construct(
|
|
363
|
-
Reflect.setPrototypeOf(d, s.prototype),
|
|
372
|
+
const d = Reflect.construct(t, a);
|
|
373
|
+
Reflect.setPrototypeOf(d, s.prototype), t.captureStackTrace && t.captureStackTrace(d, s);
|
|
364
374
|
const I = `${d.message}:${d.stack?.split(`
|
|
365
375
|
`)[1]?.trim()}`;
|
|
366
|
-
return n.has(I) || (n.add(I),
|
|
376
|
+
return n.has(I) || (n.add(I), i = d, e.postMessage({ type: "processException", error: d.message })), d;
|
|
367
377
|
}
|
|
368
|
-
s.prototype = Object.create(
|
|
378
|
+
s.prototype = Object.create(t.prototype, { constructor: { value: s, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(s, t), globalThis.Error = s;
|
|
369
379
|
}
|
|
370
|
-
function P(
|
|
371
|
-
return
|
|
380
|
+
function P(r) {
|
|
381
|
+
return r?.split("/").pop() || "<unknown>";
|
|
372
382
|
}
|
|
373
|
-
function x(
|
|
374
|
-
if (!
|
|
375
|
-
for (const
|
|
376
|
-
if (typeof
|
|
383
|
+
function x(r, e) {
|
|
384
|
+
if (!r || typeof r != "object") return !1;
|
|
385
|
+
for (const i of Object.values(r))
|
|
386
|
+
if (typeof i == "string" && i.includes(e) || typeof i == "object" && x(i, e)) return !0;
|
|
377
387
|
return !1;
|
|
378
388
|
}
|
|
379
389
|
class j extends S {
|
|
@@ -385,12 +395,12 @@ class j extends S {
|
|
|
385
395
|
async sendAppIdentifier() {
|
|
386
396
|
this.serviceIdentifier.doSend({});
|
|
387
397
|
}
|
|
388
|
-
async doSend(
|
|
389
|
-
this.sendAppIdentifier(), this.send(
|
|
398
|
+
async doSend(i, t) {
|
|
399
|
+
this.sendAppIdentifier(), this.send(i, t);
|
|
390
400
|
}
|
|
391
|
-
async send(
|
|
392
|
-
|
|
393
|
-
const n = JSON.stringify(
|
|
401
|
+
async send(i, t) {
|
|
402
|
+
o().sfDebug && console.log(" SENDING EXCEPTION...");
|
|
403
|
+
const n = JSON.stringify(B.encode(t)), s = this.getVariables({ exceptionMessage: i, traceJson: n, reentrancyGuardPreactive: !1, library: o().packageLibraryType, version: o().version });
|
|
394
404
|
Z(this.endpoint, this.operationName, this.getQuery(), s);
|
|
395
405
|
}
|
|
396
406
|
getQuery() {
|
|
@@ -409,7 +419,7 @@ class Q extends K {
|
|
|
409
419
|
this.sendAppIdentifier(), this.send(e);
|
|
410
420
|
}
|
|
411
421
|
async send(e) {
|
|
412
|
-
const
|
|
422
|
+
const i = `
|
|
413
423
|
${this.queryType} ${this.operationName}(
|
|
414
424
|
$apiKey: String!,
|
|
415
425
|
$serviceUuid: String!,
|
|
@@ -421,8 +431,8 @@ class Q extends K {
|
|
|
421
431
|
domains: $domains
|
|
422
432
|
)
|
|
423
433
|
}
|
|
424
|
-
`,
|
|
425
|
-
Z(this.endpoint, this.operationName,
|
|
434
|
+
`, t = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
|
|
435
|
+
Z(this.endpoint, this.operationName, i, t);
|
|
426
436
|
}
|
|
427
437
|
}
|
|
428
438
|
const q = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"];
|
|
@@ -434,39 +444,39 @@ class _ {
|
|
|
434
444
|
c(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
|
|
435
445
|
c(this, "contextManager");
|
|
436
446
|
c(this, "excludedDomains");
|
|
437
|
-
this.contextManager =
|
|
447
|
+
this.contextManager = W.getInstance(), this.excludedDomains = [...q, ...e].map((i) => i.toLowerCase()), o().sfDebug && console.log("[RequestInterceptor] Initialized.");
|
|
438
448
|
}
|
|
439
449
|
addReentrancyGuardHeaders(e) {
|
|
440
450
|
e.set(this.HEADER_LOG_GUARD, "true"), e.set(this.HEADER_PRINT_GUARD, "true"), e.set(this.HEADER_EXCEPTION_GUARD, "true");
|
|
441
451
|
}
|
|
442
452
|
shouldPropagateHeaders(e) {
|
|
443
|
-
return !this.excludedDomains.some((
|
|
444
|
-
}
|
|
445
|
-
addTracingHeaders(e,
|
|
446
|
-
const
|
|
447
|
-
if (this.shouldPropagateHeaders(
|
|
448
|
-
const n = this.contextManager.getOrSetSfTraceId(), s =
|
|
449
|
-
e.set(this.HEADER_TRACING, `${n}/${s}/${a}`),
|
|
450
|
-
} else
|
|
453
|
+
return !this.excludedDomains.some((i) => new RegExp(`^${i.replace(/\*/g, ".*")}$`).test(e));
|
|
454
|
+
}
|
|
455
|
+
addTracingHeaders(e, i) {
|
|
456
|
+
const t = new URL(i).hostname;
|
|
457
|
+
if (this.shouldPropagateHeaders(t)) {
|
|
458
|
+
const n = this.contextManager.getOrSetSfTraceId(), s = this.contextManager.getOrSetPageVisitUUID(), a = f();
|
|
459
|
+
e.set(this.HEADER_TRACING, `${n}/${s}/${a}`), o().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${i}`);
|
|
460
|
+
} else o().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${t}`);
|
|
451
461
|
this.addReentrancyGuardHeaders(e);
|
|
452
462
|
}
|
|
453
463
|
patchFetch() {
|
|
454
464
|
const e = globalThis.fetch;
|
|
455
|
-
typeof e == "function" ? globalThis.fetch = async (
|
|
456
|
-
const n = Date.now(), s = new Headers(
|
|
465
|
+
typeof e == "function" ? globalThis.fetch = async (i, t) => {
|
|
466
|
+
const n = Date.now(), s = new Headers(t?.headers);
|
|
457
467
|
let a;
|
|
458
|
-
typeof
|
|
468
|
+
typeof i == "string" || i instanceof URL ? a = i.toString() : i instanceof Request ? (a = i.url, i.headers.forEach((I, C) => {
|
|
459
469
|
s.set(C, I);
|
|
460
|
-
})) :
|
|
461
|
-
const d = { ...
|
|
470
|
+
})) : o().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), o().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a), this.addTracingHeaders(s, a);
|
|
471
|
+
const d = { ...t, headers: s };
|
|
462
472
|
try {
|
|
463
473
|
const I = await e(a, d), C = Date.now();
|
|
464
|
-
return
|
|
474
|
+
return o().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${I.status}, Duration: ${C - n}ms`), I;
|
|
465
475
|
} catch (I) {
|
|
466
476
|
const C = Date.now();
|
|
467
|
-
|
|
477
|
+
o().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${I}, Duration: ${C - n}ms`);
|
|
468
478
|
}
|
|
469
|
-
} :
|
|
479
|
+
} : o().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
|
|
470
480
|
}
|
|
471
481
|
}
|
|
472
482
|
class ee extends K {
|
|
@@ -497,24 +507,24 @@ class ee extends K {
|
|
|
497
507
|
|
|
498
508
|
)
|
|
499
509
|
}
|
|
500
|
-
`,
|
|
501
|
-
Z(this.endpoint, this.operationName, e,
|
|
510
|
+
`, i = this.getVariables({ serviceIdentifier: o().serviceIdentifier, serviceVersion: o().serviceVersion, serviceAdditionalMetadata: o().serviceAdditionalMetadata });
|
|
511
|
+
Z(this.endpoint, this.operationName, e, i);
|
|
502
512
|
}
|
|
503
513
|
}
|
|
504
|
-
function se(
|
|
505
|
-
if (!
|
|
506
|
-
const n = `The required API Key is not provided: ${JSON.stringify(
|
|
514
|
+
function se(r) {
|
|
515
|
+
if (!r || !r.apiKey) {
|
|
516
|
+
const n = `The required API Key is not provided: ${JSON.stringify(r)}`;
|
|
507
517
|
console.error(n);
|
|
508
518
|
}
|
|
509
519
|
const { config: e } = function(n) {
|
|
510
|
-
return
|
|
511
|
-
}(
|
|
520
|
+
return V = new T(n), { config: V };
|
|
521
|
+
}(r);
|
|
512
522
|
if (e.sfDebug && console.log("Updated configuration after applying options:", e), !e.apiKey || !e.apiGraphqlEndpoint) {
|
|
513
523
|
const n = `The required config is not provided: ${JSON.stringify(e)}`;
|
|
514
524
|
throw console.error(n), new Error(n);
|
|
515
525
|
}
|
|
516
|
-
const
|
|
517
|
-
|
|
526
|
+
const i = new K();
|
|
527
|
+
i.setServiceUUID(e.serviceUUID), function(n) {
|
|
518
528
|
function s(g, p) {
|
|
519
529
|
n.setOperationName("CollectLogs"), n.doSend([p, g]);
|
|
520
530
|
}
|
|
@@ -527,23 +537,23 @@ function se(o) {
|
|
|
527
537
|
s("WARN", g.join(" ")), I(...g);
|
|
528
538
|
}, console.info = (...g) => {
|
|
529
539
|
s("INFO", g.join(" ")), C(...g);
|
|
530
|
-
},
|
|
540
|
+
}, o().logLevel === "DEBUG" && (console.debug = (...g) => {
|
|
531
541
|
s("DEBUG", g.join(" ")), l(...g);
|
|
532
542
|
});
|
|
533
|
-
}(
|
|
543
|
+
}(i), function(n = []) {
|
|
534
544
|
const s = new _(n);
|
|
535
545
|
new Q().doSend(s.excludedDomains), s.patchFetch();
|
|
536
546
|
}(e.domainsToNotPropagateHeadersTo);
|
|
537
|
-
const
|
|
538
|
-
|
|
547
|
+
const t = new j();
|
|
548
|
+
t.setServiceUUID(e.serviceUUID), M(t), new ee().send();
|
|
539
549
|
}
|
|
540
|
-
function oe(
|
|
541
|
-
const n =
|
|
542
|
-
new U(n.apiKey).identify(
|
|
550
|
+
function oe(r, e, i, t = !1) {
|
|
551
|
+
const n = o();
|
|
552
|
+
new U(n.apiKey).identify(r, e, i, t);
|
|
543
553
|
}
|
|
544
|
-
function re(
|
|
545
|
-
const n =
|
|
546
|
-
new U(n.apiKey).addOrUpdateMetadata(
|
|
554
|
+
function re(r, e = {}, i, t = !1) {
|
|
555
|
+
const n = o();
|
|
556
|
+
new U(n.apiKey).addOrUpdateMetadata(r, e, i, t);
|
|
547
557
|
}
|
|
548
558
|
export {
|
|
549
559
|
re as addOrUpdateMetadata,
|
|
@@ -2,6 +2,7 @@ import { AsyncLocalStorage } from "async_hooks";
|
|
|
2
2
|
export declare const context: AsyncLocalStorage<Map<string, any>>;
|
|
3
3
|
type Context = {
|
|
4
4
|
traceId?: string;
|
|
5
|
+
pageVisitUUID?: string;
|
|
5
6
|
handledExceptions: Set<any>;
|
|
6
7
|
reentrancyGuardLoggingActive: boolean;
|
|
7
8
|
reentrancyGuardLoggingPreActive: boolean;
|
|
@@ -17,8 +18,11 @@ export declare class ContextManager {
|
|
|
17
18
|
getCurrentContext(): Context;
|
|
18
19
|
private setCurrentContext;
|
|
19
20
|
getTraceId(): string | undefined;
|
|
21
|
+
getPageVisitUUID(): string | undefined;
|
|
20
22
|
setTraceId(traceId: string): void;
|
|
23
|
+
setPageVisitUUID(pageVisitUUID: string): void;
|
|
21
24
|
getOrSetSfTraceId(newTraceIdIfNotSet?: string, isAssociatedWithInboundRequest?: boolean): string;
|
|
25
|
+
getOrSetPageVisitUUID(): string;
|
|
22
26
|
getHandledExceptions(): Set<any>;
|
|
23
27
|
markExceptionHandled(exception: any): void;
|
|
24
28
|
hasHandledException(exception: any): boolean;
|