hud-sdk 1.8.7 → 1.8.8

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/cjs/wrap.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(global,()=>(()=>{"use strict";var t={4403:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchManager=void 0;const i=n(4602);e.SketchManager=class{binWidth;logBinWidth;constructor(t){this.binWidth=t,this.logBinWidth=Math.log(t)}binIndex(t){return Math.floor(Math.log(t)/this.logBinWidth)}indexToBinStart(t){return this.binWidth**t}newSketchDataWithValue(t){const e=this.binIndex(t),n=new i.SketchData;return n.indexShift=e,n[0]=1,n}add(t,e){const n=this.binIndex(e);let i=n-t.indexShift;i<0?(t.unshift(...new Array(-i).fill(0)),t.indexShift=n,i=n-t.indexShift):i>=t.length&&t.push(...new Array(i-t.length+1).fill(0)),t[i]+=1}zero(t){t.fill(0)}copy(t){const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t),e}mergeIntoNoChecks(t,e){const n=e.indexShift-t.indexShift;for(let i=0;i<e.length;i++)t[i+n]+=e[i]}mergeInto(t,e){e.indexShift<t.indexShift&&(t.unshift(...new Array(t.indexShift-e.indexShift).fill(0)),t.indexShift=e.indexShift),e.indexShift+e.length>t.indexShift+t.length&&t.push(...new Array(e.indexShift+e.length-(t.indexShift+t.length)).fill(0)),this.mergeIntoNoChecks(t,e)}mergeMany(t){if(0===t.length)throw new Error("Cannot merge empty list of SketchData.");if(1===t.length)return this.copy(t[0]);let e=1/0,n=-1/0;for(const i of t)e=Math.min(e,i.indexShift),n=Math.max(n,i.indexShift+i.length-1);const r=new i.SketchData;r.indexShift=e,r.push(...new Array(n-e+1).fill(0));for(const e of t)this.mergeIntoNoChecks(r,e);return r}getQuantile(t,e){const n=t.reduce((t,e)=>t+e,0);if(0===n)throw new Error("Cannot get quantile of empty SketchData.");const i=n*e;let r,o=0;for(r=0;r<t.length&&(o+=t[r],!(o>=i));r++);const a=this.indexToBinStart(r+t.indexShift),u=(o-i)/t[r];return a*this.binWidth**(1-u)}encode(t){return{binWidth:this.binWidth,indexShift:t.indexShift,data:Array.from(t)}}decode(t){if(t.binWidth!==this.binWidth)throw new Error(`Should not decode sketch data with bin width ${t.binWidth} using SketchManager with bin width ${this.binWidth}.`);const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t.data),e}}},4602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchData=void 0,e.SketchData=class extends Array{indexShift=0;constructor(){super()}}},6042:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e._hudVersion=e.getWrapperTypeFromPrefix=e.asyncWrapper=e.wrapperUserCatch=e.fixStack=e.wrapperFinally=e.wrapperCatch=e.wrapperInitial=e.InvestigationStatus=e.kHudCaller=void 0,e.setHudExecutionAsyncResource=function(t){s=t},e.setFlowStateStorage=function(t){void 0===c&&(c=t)},e.getFlowStateStorage=l,e.getFlowState=function(){return c?.getStore()},e.setInvestigationStorage=function(t){void 0===d&&(d=t)},e.getInvestigationStorage=function(){return d},e.investigateError=f,e.extractName=g,e.extractMessage=function(t){if(t instanceof Error)return t.message?t.message:void 0},e.extractStackTrace=function(t){if(t instanceof Error)return t.stack?t.stack:void 0},e.asyncIteratorWrapper=function(t){if(t&&t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if(t&&t[Symbol.iterator])return new x(t[Symbol.iterator]());if(t&&t["@@asyncIterator"])return t["@@asyncIterator"]();if(t&&t["@@iterator"])return t["@@iterator"]();throw new TypeError("Object is not async iterable")};const o=n(4403),a=n(7830),u=new o.SketchManager(1.2);e.kHudCaller=Symbol.for("hudCaller");let c,s=()=>({});function l(){return c}var h;let d;function f(t,e,n,i){if(!globalThis.hudEnableInvestigation)return;if(void 0===d)return;const r=d.getStore();if(void 0===r||r.status!==h.Open||void 0===r.data)return;const o=globalThis.hudExceptionMaxLength??20;let a=r.data.exceptions.get(i);if(void 0===a){if(r.data.exceptions.size>=o)return;a={exception:i,executionFlow:[],caught:e},r.data.exceptions.set(i,a)}a.caught=e,r.data.caught=e;const u=globalThis.hudExecutionFlowMaxLength??20;a.executionFlow.length>=u||a.executionFlow.push({function_id:t.functionId,caller_id:t.wrappedCaller,args:globalThis.hudEnableInvestigationArgsSending?n:void 0,is_outbound_function:t.isOutbound??!1})}function g(t){return t instanceof Error?t.constructor?t.constructor.name:t.name?t.name:"Non-Deducible-Name-Exception":"Non-Error-Exception"}function S(t){t&&2===globalThis.hudRunningMode&&t.fixFlag&&(void 0!==s()[e.kHudCaller]?(globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0):globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1)}var p;!function(t){t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Cleared=3]="Cleared"}(h||(e.InvestigationStatus=h={})),function(t){t[t.AWAIT_BEFORE=1]="AWAIT_BEFORE",t[t.AWAIT_AFTER=2]="AWAIT_AFTER",t[t.YIELD_BEFORE=3]="YIELD_BEFORE",t[t.YIELD_AFTER=4]="YIELD_AFTER"}(p||(p={}));class x{iterator;n;constructor(t){this.iterator=t,this.n=t.next}static AsyncFromSyncIteratorContinuation(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));const e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}next(...t){return x.AsyncFromSyncIteratorContinuation(this.n.call(this.iterator,...t))}return(t){const e=this.iterator.return;return void 0===e?Promise.resolve({value:t,done:!0}):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}throw(t){const e=this.iterator.throw;return void 0===e?Promise.reject(t):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}[Symbol.asyncIterator](){return this}}e.wrapperInitial=function(t,n){if(2===globalThis.hudRunningMode)try{const i=hudCalls[t]??={shouldDetach:!1};if(i.shouldDetach)return;const r=s(),o=r[e.kHudCaller];void 0!==o&&(r[e.kHudCaller]=void 0);const a=o??(globalThis.hudStackIndex.value<0?"":globalThis.hudStack[globalThis.hudStackIndex.value]),u=i[a]??={},c=l()?.getStore(),h=u[c?.flowId||""]??={count:0,samplingCounter:0,sampledCount:0,sum:0,exceptions:{},squareSum:0,sketch:null,isLinkedFunction:!1},d=h.samplingCounter++,f=!!n||(d>=5e3?d%103==0:hudSampleTable[d]),g=f?process.hrtime.bigint():0n;return c?.shouldLinkFunction&&(c.shouldLinkFunction=!1,h.isLinkedFunction=!0),hudStack[++hudStackIndex.value]=t,{functionId:t,callObj:h,wrappedCaller:a,sampleFlag:f,start:g,fixFlag:!1,isOutbound:n}}catch{return}},e.wrapperCatch=function(t,e,n){if(!e||2!==globalThis.hudRunningMode)return;const i=g(t),r=e.callObj;r.exceptions[i]??=0,r.exceptions[i]++,f(e,!1,n,t)},e.wrapperFinally=function(t){if(!t||2!==globalThis.hudRunningMode)return;t.fixFlag||hudStackIndex.value--;const e=t.callObj;if(e.count++,t.sampleFlag){const n=process.hrtime.bigint(),i=Number(n-t.start);i>0&&(e.sampledCount++,e.sum+=i,e.squareSum+=i*i,null===e.sketch?e.sketch=u.newSketchDataWithValue(i):u.add(e.sketch,i))}},e.fixStack=S,e.wrapperUserCatch=function(t,e,n){e&&2===globalThis.hudRunningMode&&(S(e),f(e,!0,n,t))},e.asyncWrapper=function(t,n){if(t&&2===globalThis.hudRunningMode)switch(n){case p.AWAIT_BEFORE:return function(t){globalThis.hudStackPop=!0,t.fixFlag=!0}(t);case p.AWAIT_AFTER:return function(t){globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0,t.fixFlag=!1}(t);case p.YIELD_BEFORE:return function(t){globalThis.hudStackIndex.value--,t.fixFlag=!0}(t);case p.YIELD_AFTER:return function(t){globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1}(t)}},e.getWrapperTypeFromPrefix=function(t,e){return"await"===t?e?p.AWAIT_BEFORE:p.AWAIT_AFTER:e?p.YIELD_BEFORE:p.YIELD_AFTER},e._hudVersion=a.SDK_VERSION,r(n(4602),e),r(n(4403),e)},7830:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_VERSION=void 0,e.SDK_VERSION="1.8.7"}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(6042)})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(global,()=>(()=>{"use strict";var t={4403:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchManager=void 0;const i=n(4602);e.SketchManager=class{binWidth;logBinWidth;constructor(t){this.binWidth=t,this.logBinWidth=Math.log(t)}binIndex(t){return Math.floor(Math.log(t)/this.logBinWidth)}indexToBinStart(t){return this.binWidth**t}newSketchDataWithValue(t){const e=this.binIndex(t),n=new i.SketchData;return n.indexShift=e,n[0]=1,n}add(t,e){const n=this.binIndex(e);let i=n-t.indexShift;i<0?(t.unshift(...new Array(-i).fill(0)),t.indexShift=n,i=n-t.indexShift):i>=t.length&&t.push(...new Array(i-t.length+1).fill(0)),t[i]+=1}zero(t){t.fill(0)}copy(t){const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t),e}mergeIntoNoChecks(t,e){const n=e.indexShift-t.indexShift;for(let i=0;i<e.length;i++)t[i+n]+=e[i]}mergeInto(t,e){e.indexShift<t.indexShift&&(t.unshift(...new Array(t.indexShift-e.indexShift).fill(0)),t.indexShift=e.indexShift),e.indexShift+e.length>t.indexShift+t.length&&t.push(...new Array(e.indexShift+e.length-(t.indexShift+t.length)).fill(0)),this.mergeIntoNoChecks(t,e)}mergeMany(t){if(0===t.length)throw new Error("Cannot merge empty list of SketchData.");if(1===t.length)return this.copy(t[0]);let e=1/0,n=-1/0;for(const i of t)e=Math.min(e,i.indexShift),n=Math.max(n,i.indexShift+i.length-1);const r=new i.SketchData;r.indexShift=e,r.push(...new Array(n-e+1).fill(0));for(const e of t)this.mergeIntoNoChecks(r,e);return r}getQuantile(t,e){const n=t.reduce((t,e)=>t+e,0);if(0===n)throw new Error("Cannot get quantile of empty SketchData.");const i=n*e;let r,o=0;for(r=0;r<t.length&&(o+=t[r],!(o>=i));r++);const a=this.indexToBinStart(r+t.indexShift),u=(o-i)/t[r];return a*this.binWidth**(1-u)}encode(t){return{binWidth:this.binWidth,indexShift:t.indexShift,data:Array.from(t)}}decode(t){if(t.binWidth!==this.binWidth)throw new Error(`Should not decode sketch data with bin width ${t.binWidth} using SketchManager with bin width ${this.binWidth}.`);const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t.data),e}}},4602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchData=void 0,e.SketchData=class extends Array{indexShift=0;constructor(){super()}}},6042:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e._hudVersion=e.getWrapperTypeFromPrefix=e.asyncWrapper=e.wrapperUserCatch=e.fixStack=e.wrapperFinally=e.wrapperCatch=e.wrapperInitial=e.InvestigationStatus=e.kHudCaller=void 0,e.setHudExecutionAsyncResource=function(t){s=t},e.setFlowStateStorage=function(t){void 0===c&&(c=t)},e.getFlowStateStorage=l,e.getFlowState=function(){return c?.getStore()},e.setInvestigationStorage=function(t){void 0===d&&(d=t)},e.getInvestigationStorage=function(){return d},e.investigateError=f,e.extractName=g,e.extractMessage=function(t){if(t instanceof Error)return t.message?t.message:void 0},e.extractStackTrace=function(t){if(t instanceof Error)return t.stack?t.stack:void 0},e.asyncIteratorWrapper=function(t){if(t&&t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if(t&&t[Symbol.iterator])return new x(t[Symbol.iterator]());if(t&&t["@@asyncIterator"])return t["@@asyncIterator"]();if(t&&t["@@iterator"])return t["@@iterator"]();throw new TypeError("Object is not async iterable")};const o=n(4403),a=n(7830),u=new o.SketchManager(1.2);e.kHudCaller=Symbol.for("hudCaller");let c,s=()=>({});function l(){return c}var h;let d;function f(t,e,n,i){if(!globalThis.hudEnableInvestigation)return;if(void 0===d)return;const r=d.getStore();if(void 0===r||r.status!==h.Open||void 0===r.data)return;const o=globalThis.hudExceptionMaxLength??20;let a=r.data.exceptions.get(i);if(void 0===a){if(r.data.exceptions.size>=o)return;a={exception:i,executionFlow:[],caught:e},r.data.exceptions.set(i,a)}a.caught=e,r.data.caught=e;const u=globalThis.hudExecutionFlowMaxLength??20;a.executionFlow.length>=u||a.executionFlow.push({function_id:t.functionId,caller_id:t.wrappedCaller,args:globalThis.hudEnableInvestigationArgsSending?n:void 0,is_outbound_function:t.isOutbound??!1})}function g(t){return t instanceof Error?t.constructor?t.constructor.name:t.name?t.name:"Non-Deducible-Name-Exception":"Non-Error-Exception"}function S(t){t&&2===globalThis.hudRunningMode&&t.fixFlag&&(void 0!==s()[e.kHudCaller]?(globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0):globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1)}var p;!function(t){t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Cleared=3]="Cleared"}(h||(e.InvestigationStatus=h={})),function(t){t[t.AWAIT_BEFORE=1]="AWAIT_BEFORE",t[t.AWAIT_AFTER=2]="AWAIT_AFTER",t[t.YIELD_BEFORE=3]="YIELD_BEFORE",t[t.YIELD_AFTER=4]="YIELD_AFTER"}(p||(p={}));class x{iterator;n;constructor(t){this.iterator=t,this.n=t.next}static AsyncFromSyncIteratorContinuation(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));const e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}next(...t){return x.AsyncFromSyncIteratorContinuation(this.n.call(this.iterator,...t))}return(t){const e=this.iterator.return;return void 0===e?Promise.resolve({value:t,done:!0}):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}throw(t){const e=this.iterator.throw;return void 0===e?Promise.reject(t):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}[Symbol.asyncIterator](){return this}}e.wrapperInitial=function(t,n){if(2===globalThis.hudRunningMode)try{const i=hudCalls[t]??={shouldDetach:!1};if(i.shouldDetach)return;const r=s(),o=r[e.kHudCaller];void 0!==o&&(r[e.kHudCaller]=void 0);const a=o??(globalThis.hudStackIndex.value<0?"":globalThis.hudStack[globalThis.hudStackIndex.value]),u=i[a]??={},c=l()?.getStore(),h=u[c?.flowId||""]??={count:0,samplingCounter:0,sampledCount:0,sum:0,exceptions:{},squareSum:0,sketch:null,isLinkedFunction:!1},d=h.samplingCounter++,f=!!n||(d>=5e3?d%103==0:hudSampleTable[d]),g=f?process.hrtime.bigint():0n;return c?.shouldLinkFunction&&(c.shouldLinkFunction=!1,h.isLinkedFunction=!0),hudStack[++hudStackIndex.value]=t,{functionId:t,callObj:h,wrappedCaller:a,sampleFlag:f,start:g,fixFlag:!1,isOutbound:n}}catch{return}},e.wrapperCatch=function(t,e,n){if(!e||2!==globalThis.hudRunningMode)return;const i=g(t),r=e.callObj;r.exceptions[i]??=0,r.exceptions[i]++,f(e,!1,n,t)},e.wrapperFinally=function(t){if(!t||2!==globalThis.hudRunningMode)return;t.fixFlag||hudStackIndex.value--;const e=t.callObj;if(e.count++,t.sampleFlag){const n=process.hrtime.bigint(),i=Number(n-t.start);i>0&&(e.sampledCount++,e.sum+=i,e.squareSum+=i*i,null===e.sketch?e.sketch=u.newSketchDataWithValue(i):u.add(e.sketch,i))}},e.fixStack=S,e.wrapperUserCatch=function(t,e,n){e&&2===globalThis.hudRunningMode&&(S(e),f(e,!0,n,t))},e.asyncWrapper=function(t,n){if(t&&2===globalThis.hudRunningMode)switch(n){case p.AWAIT_BEFORE:return function(t){globalThis.hudStackPop=!0,t.fixFlag=!0}(t);case p.AWAIT_AFTER:return function(t){globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0,t.fixFlag=!1}(t);case p.YIELD_BEFORE:return function(t){globalThis.hudStackIndex.value--,t.fixFlag=!0}(t);case p.YIELD_AFTER:return function(t){globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1}(t)}},e.getWrapperTypeFromPrefix=function(t,e){return"await"===t?e?p.AWAIT_BEFORE:p.AWAIT_AFTER:e?p.YIELD_BEFORE:p.YIELD_AFTER},e._hudVersion=a.SDK_VERSION,r(n(4602),e),r(n(4403),e)},7830:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_VERSION=void 0,e.SDK_VERSION="1.8.8"}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(6042)})());
2
2
  //# sourceMappingURL=wrap.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hud-sdk",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "description": "Hud's Node SDK",
5
5
  "homepage": "https://www.hud.io/",
6
6
  "keywords": [