hud-sdk
Version:
Hud's Node SDK
2 lines • 2.67 kB
JavaScript
!function(r,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t=e();for(var o in t)("object"==typeof exports?exports:r)[o]=t[o]}}(global,()=>(()=>{"use strict";var r={523:r=>{r.exports=require("./logger")},2546:r=>{r.exports=require("./lib")},5809:r=>{r.exports=require("./config")},7131:r=>{r.exports=require("./wrap")}},e={};function t(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return r[o](i,i.exports,t),i.exports}var o={};return(()=>{var r=o;Object.defineProperty(r,"__esModule",{value:!0}),r.setContext=f,r.setFailure=function(r,t){try{const o=(0,g.getInvestigationStorage)();if(void 0===o)return void(c||(i.app_logger.warning("setFailure - No Storage"),i.customer_logger.logEntry(n.UserErrorLogs.SetFailureBeforeRegister()),c=!0));if(!e.hudConfig.dynamicConfig.enableInvestigation)return;const s=o.getStore();if(void 0===s)return void(d||(i.app_logger.warning("setFailure called not inside async context. Skipping."),i.customer_logger.logEntry(n.UserErrorLogs.SetFailureNoAsyncContext()),d=!0));if("string"!=typeof r)return void i.customer_logger.logEntry(n.UserErrorLogs.SetFailureErrorNotString());if(0===r.length)return void i.customer_logger.logEntry(n.UserErrorLogs.SetFailureErrorEmpty());let a=r;r.length>p&&(i.customer_logger.logEntry(n.UserErrorLogs.SetFailureErrorTooLong()),a=r.substring(0,p)),s.userDefinedError=a,void 0!==t&&f(t)}catch(r){i.app_logger.warning("failed to set failure. Skipping.",{error:r,stack:r instanceof Error&&null!==r?r.stack:void 0})}};const e=t(5809),n=t(2546),i=t(523),g=t(7131);let s=!1,a=!1,l=!1,u=!1,c=!1,d=!1;const p=1024;function f(r){try{const t=(0,g.getInvestigationStorage)();if(void 0===t)return void(l||(i.app_logger.warning("HudContext warning: No Storage"),i.customer_logger.logEntry(n.UserErrorLogs.SetContextBeforeRegister()),l=!0));if(!e.hudConfig.dynamicConfig.enableInvestigation)return;const o=t.getStore();if(void 0===o)return void(s||(i.app_logger.warning("HudContext warning: setContext called not inside async context. Skipping."),i.customer_logger.logEntry(n.UserErrorLogs.SetContextNoAsyncContext()),s=!0));const a=(0,n.validateContext)(r);o.userContext={...o.userContext,...a}}catch(r){if(r instanceof n.HudContextValidationError)return void(u||(i.app_logger.warning("HudContext warning: failed to validate context. Skipping.",{error:r,stack:r instanceof Error&&null!==r?r.stack:void 0}),u=!0));a||(i.app_logger.warning("HudContext warning: failed to set context. Skipping.",{error:r,stack:r instanceof Error&&null!==r?r.stack:void 0}),a=!0)}}})(),o})());
//# sourceMappingURL=api.js.map