splunk-events
Advanced tools
Comparing version 1.6.0 to 1.6.1-beta
@@ -10,2 +10,6 @@ # Changelog | ||
## [1.6.1-beta] - 2021-04-12 | ||
### Changed | ||
- Removed `Content-Type` from default headers list. | ||
## [1.6.0] - 2021-04-07 | ||
@@ -12,0 +16,0 @@ ### Added |
/*! | ||
* splunk-events v1.6.0 | ||
* splunk-events v1.6.1-beta | ||
* Copyright (c) VTEX | ||
@@ -330,3 +330,3 @@ * Released under the MIT License. | ||
(_s = config === null || config === void 0 ? void 0 : config.maxNumberOfRetries) !== null && _s !== void 0 ? _s : this.maxNumberOfRetries; | ||
this.headers = __assign({ Authorization: "Splunk " + this.token, 'Content-Type': 'application/json' }, ((_t = config === null || config === void 0 ? void 0 : config.headers) !== null && _t !== void 0 ? _t : {})); | ||
this.headers = __assign({ Authorization: "Splunk " + this.token }, ((_t = config === null || config === void 0 ? void 0 : config.headers) !== null && _t !== void 0 ? _t : {})); | ||
}; | ||
@@ -333,0 +333,0 @@ /** |
/*! | ||
* splunk-events v1.6.0 | ||
* splunk-events v1.6.1-beta | ||
* Copyright (c) VTEX | ||
@@ -20,3 +20,3 @@ * Released under the MIT License. | ||
***************************************************************************** */ | ||
var n=function(){return(n=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function t(n,t,e,o){return new(e||(e=Promise))((function(i,s){function u(n){try{l(o.next(n))}catch(n){s(n)}}function r(n){try{l(o.throw(n))}catch(n){s(n)}}function l(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,r)}l((o=o.apply(n,t||[])).next())}))}function e(n,t){var e,o,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function r(s){return function(r){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,o=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(n,u)}catch(n){s=[6,n],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,r])}}}function o(n,t){void 0===t&&(t=100);var e=null,o=null,i=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return e&&(clearTimeout(e),e=null),new Promise((function(s,u){o=u,e=setTimeout((function(){var t=n.apply(void 0,i);null!=t&&t.then(s).catch(u)}),t)}))};return i.clear=function(){e&&(clearTimeout(e),null==o||o(),e=null)},i}function i(t){return"undefined"!=typeof window&&"function"!=typeof window.fetch||"undefined"!=typeof global&&"function"!=typeof global.fetch?(console.log("Error, using fetchRequest without fetch object"),Promise.resolve(null)):fetch(t.url,n(n({},t),{body:t.data})).then((function(n){return"json"===t.responseType?n.json():n}))}var s=function(){function s(s){var u=this;this._requestImpl=i,this.autoFlush=!0,this.autoRetryFlush=!0,this.debounceTime=2e3,this.debug=!1,this.events=[],this.host="-",this.injectAdditionalInfo=!1,this.injectTimestamp=!1,this.isSendingEvents=!1,this.path="/services/collector/event",this.pendingEvents=[],this.shouldParseEventData=!0,this.source="log",this.flushPending=!1,this.useExponentialBackoff=!1,this.exponentialBackoffLimit=6e4,this.isBackoffInProgress=!1,this.maxNumberOfRetries=1/0,this.logEvent=function(t,e,o,i,s,r){void 0===r&&(r=""),u.validateEvent(s);var l=n(n({level:t,type:e,workflowType:o,workflowInstance:i,account:r},s),u.injectAdditionalInfo?u.getAdditionalInfo():{}),a=u.shouldParseEventData?u.parseEventData(l):l,h=n(n({sourcetype:u.source,host:u.host},u.injectTimestamp&&{time:+new Date}),{event:a});u.events.push(h),u.autoFlush&&u.flushEvents()},this.flushEvents=function(){u.useExponentialBackoff?u._backoffFlush():u.debouncedFlush()},this.flush=function(n){return void 0===n&&(n=u.events),t(u,void 0,void 0,(function(){var t,o,i=this;return e(this,(function(e){return this.validateConfig(),0===n.length?[2]:(this.debug&&console.log("sending "+n.length+" events to splunk"),t=this.formatEventsForSplunkBatch(n),[2,this.request({url:""+this.endpoint+this.path,method:"POST",data:t,headers:null!==(o=this.headers)&&void 0!==o?o:{},responseType:"json"}).then((function(){i.debug&&console.log(n.length+" events successfuly sent to splunk")})).catch((function(n){throw i.debug&&console.warn("Error sending events to splunk.",n),n}))])}))}))},this._backoffFlush=function(){if(!u.isBackoffInProgress){u.isBackoffInProgress=!0;var n=function(t){return void 0===t&&(t=0),u.flush().then((function(){u.events=[],u.isBackoffInProgress=!1})).catch((function(){var e=1e3*Math.pow(2,t);return t>u.maxNumberOfRetries?(u.events=[],void(u.isBackoffInProgress=!1)):new Promise((function(o,i){setTimeout((function(){n(t+1).then(o,i).catch(i)}),Math.min(e,u.exponentialBackoffLimit))}))}))};return n()}},this._debouncedFlush=function(){u.isSendingEvents?u.flushPending=!0:(u.pendingEvents=Array.from(u.events),u.events=[],u.isSendingEvents=!0,u.flush(u.pendingEvents).then((function(){if(u.pendingEvents=[],u.isSendingEvents=!1,u.flushPending)return u.flushPending=!1,u._debouncedFlush()})).catch((function(){u.events=u.events.concat(u.pendingEvents),u.pendingEvents=[],u.isSendingEvents=!1,u.autoRetryFlush&&u.flushEvents()})))},this.debouncedFlush=o(this._debouncedFlush,this.debounceTime),s&&this.config(s)}return s.prototype.config=function(t){var e,i,s,u,r,l,a,h,c,f,d,v,p,g,b,m,y,w;this.endpoint=null!==(e=null==t?void 0:t.endpoint)&&void 0!==e?e:this.endpoint,this.token=null!==(i=null==t?void 0:t.token)&&void 0!==i?i:this.endpoint,this.injectAdditionalInfo=null!==(u=null!==(s=null==t?void 0:t.injectAditionalInfo)&&void 0!==s?s:null==t?void 0:t.injectAdditionalInfo)&&void 0!==u?u:this.injectAdditionalInfo,this.useExponentialBackoff=null!==(r=null==t?void 0:t.useExponentialBackoff)&&void 0!==r?r:this.useExponentialBackoff,this.exponentialBackoffLimit=null!==(l=null==t?void 0:t.exponentialBackoffLimit)&&void 0!==l?l:this.exponentialBackoffLimit,this.autoFlush=!!this.useExponentialBackoff||(null!==(a=null==t?void 0:t.autoFlush)&&void 0!==a?a:this.autoFlush),this.autoRetryFlush=null!==(h=null==t?void 0:t.autoRetryFlush)&&void 0!==h?h:this.autoRetryFlush,this.source=null!==(c=null==t?void 0:t.source)&&void 0!==c?c:this.source,this.path=null!==(f=null==t?void 0:t.path)&&void 0!==f?f:this.path,this.host=null!==(d=null==t?void 0:t.host)&&void 0!==d?d:this.host,this.debug=null!==(v=null==t?void 0:t.debug)&&void 0!==v?v:this.debug;var E=this.debounceTime;this.debounceTime=null!==(p=null==t?void 0:t.debounceTime)&&void 0!==p?p:this.debounceTime,this.debounceTime!==E&&(this.debouncedFlush.clear(),this.debouncedFlush=o(this._debouncedFlush,this.debounceTime)),this._requestImpl=null!==(g=null==t?void 0:t.request)&&void 0!==g?g:this._requestImpl,this.injectTimestamp=null!==(b=null==t?void 0:t.injectTimestamp)&&void 0!==b?b:this.injectTimestamp,this.shouldParseEventData=null!==(m=null==t?void 0:t.shouldParseEventData)&&void 0!==m?m:this.shouldParseEventData,this.maxNumberOfRetries=null!==(y=null==t?void 0:t.maxNumberOfRetries)&&void 0!==y?y:this.maxNumberOfRetries,this.headers=n({Authorization:"Splunk "+this.token,"Content-Type":"application/json"},null!==(w=null==t?void 0:t.headers)&&void 0!==w?w:{})},s.prototype.request=function(n){return this._requestImpl(n)},s.prototype.parseEventData=function(n){var t="";for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&null!=n[e]){var o=n[e];switch(typeof o){case"string":t+=e+'="'+o.replace(/"/g,"")+'" ';break;case"boolean":case"number":t+=e+"="+o+" ";break;default:throw new Error("Event property must be string, number or boolean")}}return t},s.prototype.validateEvent=function(n){if(null===n)throw new Error("Event must not be null");if(void 0===n)throw new Error("Event must not be undefined");if("object"!=typeof n)throw new Error("Event must be an object")},s.prototype.getAdditionalInfo=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return"";var n=window.screen,t=window.location;return{additional_info:navigator.userAgent.replace(/,/g,";")+","+(navigator.browserLanguage||navigator.language)+","+navigator.platform+","+(n.availWidth||"-")+","+(n.availHeight||"-")+","+t.hostname+","+t.pathname+","+t.protocol.replace(":","")+","+(t.hash||"-")}},s.prototype.formatEventsForSplunkBatch=function(n){return n.map((function(n){return JSON.stringify(n)})).join("\n")},s.prototype.validateConfig=function(){if(null==this.token)throw new Error("Token must not be null nor undefined");if(null==this.endpoint)throw new Error("Endpoint must not be null nor undefined")},s}();export default s; | ||
var n=function(){return(n=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function t(n,t,e,o){return new(e||(e=Promise))((function(i,s){function u(n){try{l(o.next(n))}catch(n){s(n)}}function r(n){try{l(o.throw(n))}catch(n){s(n)}}function l(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,r)}l((o=o.apply(n,t||[])).next())}))}function e(n,t){var e,o,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function r(s){return function(r){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,o=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(n,u)}catch(n){s=[6,n],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,r])}}}function o(n,t){void 0===t&&(t=100);var e=null,o=null,i=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return e&&(clearTimeout(e),e=null),new Promise((function(s,u){o=u,e=setTimeout((function(){var t=n.apply(void 0,i);null!=t&&t.then(s).catch(u)}),t)}))};return i.clear=function(){e&&(clearTimeout(e),null==o||o(),e=null)},i}function i(t){return"undefined"!=typeof window&&"function"!=typeof window.fetch||"undefined"!=typeof global&&"function"!=typeof global.fetch?(console.log("Error, using fetchRequest without fetch object"),Promise.resolve(null)):fetch(t.url,n(n({},t),{body:t.data})).then((function(n){return"json"===t.responseType?n.json():n}))}var s=function(){function s(s){var u=this;this._requestImpl=i,this.autoFlush=!0,this.autoRetryFlush=!0,this.debounceTime=2e3,this.debug=!1,this.events=[],this.host="-",this.injectAdditionalInfo=!1,this.injectTimestamp=!1,this.isSendingEvents=!1,this.path="/services/collector/event",this.pendingEvents=[],this.shouldParseEventData=!0,this.source="log",this.flushPending=!1,this.useExponentialBackoff=!1,this.exponentialBackoffLimit=6e4,this.isBackoffInProgress=!1,this.maxNumberOfRetries=1/0,this.logEvent=function(t,e,o,i,s,r){void 0===r&&(r=""),u.validateEvent(s);var l=n(n({level:t,type:e,workflowType:o,workflowInstance:i,account:r},s),u.injectAdditionalInfo?u.getAdditionalInfo():{}),a=u.shouldParseEventData?u.parseEventData(l):l,h=n(n({sourcetype:u.source,host:u.host},u.injectTimestamp&&{time:+new Date}),{event:a});u.events.push(h),u.autoFlush&&u.flushEvents()},this.flushEvents=function(){u.useExponentialBackoff?u._backoffFlush():u.debouncedFlush()},this.flush=function(n){return void 0===n&&(n=u.events),t(u,void 0,void 0,(function(){var t,o,i=this;return e(this,(function(e){return this.validateConfig(),0===n.length?[2]:(this.debug&&console.log("sending "+n.length+" events to splunk"),t=this.formatEventsForSplunkBatch(n),[2,this.request({url:""+this.endpoint+this.path,method:"POST",data:t,headers:null!==(o=this.headers)&&void 0!==o?o:{},responseType:"json"}).then((function(){i.debug&&console.log(n.length+" events successfuly sent to splunk")})).catch((function(n){throw i.debug&&console.warn("Error sending events to splunk.",n),n}))])}))}))},this._backoffFlush=function(){if(!u.isBackoffInProgress){u.isBackoffInProgress=!0;var n=function(t){return void 0===t&&(t=0),u.flush().then((function(){u.events=[],u.isBackoffInProgress=!1})).catch((function(){var e=1e3*Math.pow(2,t);return t>u.maxNumberOfRetries?(u.events=[],void(u.isBackoffInProgress=!1)):new Promise((function(o,i){setTimeout((function(){n(t+1).then(o,i).catch(i)}),Math.min(e,u.exponentialBackoffLimit))}))}))};return n()}},this._debouncedFlush=function(){u.isSendingEvents?u.flushPending=!0:(u.pendingEvents=Array.from(u.events),u.events=[],u.isSendingEvents=!0,u.flush(u.pendingEvents).then((function(){if(u.pendingEvents=[],u.isSendingEvents=!1,u.flushPending)return u.flushPending=!1,u._debouncedFlush()})).catch((function(){u.events=u.events.concat(u.pendingEvents),u.pendingEvents=[],u.isSendingEvents=!1,u.autoRetryFlush&&u.flushEvents()})))},this.debouncedFlush=o(this._debouncedFlush,this.debounceTime),s&&this.config(s)}return s.prototype.config=function(t){var e,i,s,u,r,l,a,h,c,f,d,v,p,g,b,m,y,w;this.endpoint=null!==(e=null==t?void 0:t.endpoint)&&void 0!==e?e:this.endpoint,this.token=null!==(i=null==t?void 0:t.token)&&void 0!==i?i:this.endpoint,this.injectAdditionalInfo=null!==(u=null!==(s=null==t?void 0:t.injectAditionalInfo)&&void 0!==s?s:null==t?void 0:t.injectAdditionalInfo)&&void 0!==u?u:this.injectAdditionalInfo,this.useExponentialBackoff=null!==(r=null==t?void 0:t.useExponentialBackoff)&&void 0!==r?r:this.useExponentialBackoff,this.exponentialBackoffLimit=null!==(l=null==t?void 0:t.exponentialBackoffLimit)&&void 0!==l?l:this.exponentialBackoffLimit,this.autoFlush=!!this.useExponentialBackoff||(null!==(a=null==t?void 0:t.autoFlush)&&void 0!==a?a:this.autoFlush),this.autoRetryFlush=null!==(h=null==t?void 0:t.autoRetryFlush)&&void 0!==h?h:this.autoRetryFlush,this.source=null!==(c=null==t?void 0:t.source)&&void 0!==c?c:this.source,this.path=null!==(f=null==t?void 0:t.path)&&void 0!==f?f:this.path,this.host=null!==(d=null==t?void 0:t.host)&&void 0!==d?d:this.host,this.debug=null!==(v=null==t?void 0:t.debug)&&void 0!==v?v:this.debug;var E=this.debounceTime;this.debounceTime=null!==(p=null==t?void 0:t.debounceTime)&&void 0!==p?p:this.debounceTime,this.debounceTime!==E&&(this.debouncedFlush.clear(),this.debouncedFlush=o(this._debouncedFlush,this.debounceTime)),this._requestImpl=null!==(g=null==t?void 0:t.request)&&void 0!==g?g:this._requestImpl,this.injectTimestamp=null!==(b=null==t?void 0:t.injectTimestamp)&&void 0!==b?b:this.injectTimestamp,this.shouldParseEventData=null!==(m=null==t?void 0:t.shouldParseEventData)&&void 0!==m?m:this.shouldParseEventData,this.maxNumberOfRetries=null!==(y=null==t?void 0:t.maxNumberOfRetries)&&void 0!==y?y:this.maxNumberOfRetries,this.headers=n({Authorization:"Splunk "+this.token},null!==(w=null==t?void 0:t.headers)&&void 0!==w?w:{})},s.prototype.request=function(n){return this._requestImpl(n)},s.prototype.parseEventData=function(n){var t="";for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&null!=n[e]){var o=n[e];switch(typeof o){case"string":t+=e+'="'+o.replace(/"/g,"")+'" ';break;case"boolean":case"number":t+=e+"="+o+" ";break;default:throw new Error("Event property must be string, number or boolean")}}return t},s.prototype.validateEvent=function(n){if(null===n)throw new Error("Event must not be null");if(void 0===n)throw new Error("Event must not be undefined");if("object"!=typeof n)throw new Error("Event must be an object")},s.prototype.getAdditionalInfo=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return"";var n=window.screen,t=window.location;return{additional_info:navigator.userAgent.replace(/,/g,";")+","+(navigator.browserLanguage||navigator.language)+","+navigator.platform+","+(n.availWidth||"-")+","+(n.availHeight||"-")+","+t.hostname+","+t.pathname+","+t.protocol.replace(":","")+","+(t.hash||"-")}},s.prototype.formatEventsForSplunkBatch=function(n){return n.map((function(n){return JSON.stringify(n)})).join("\n")},s.prototype.validateConfig=function(){if(null==this.token)throw new Error("Token must not be null nor undefined");if(null==this.endpoint)throw new Error("Endpoint must not be null nor undefined")},s}();export default s; | ||
//# sourceMappingURL=splunk-events.esm.min.js.map |
/*! | ||
* splunk-events v1.6.0 | ||
* splunk-events v1.6.1-beta | ||
* Copyright (c) VTEX | ||
@@ -332,3 +332,3 @@ * Released under the MIT License. | ||
(_s = config === null || config === void 0 ? void 0 : config.maxNumberOfRetries) !== null && _s !== void 0 ? _s : this.maxNumberOfRetries; | ||
this.headers = __assign({ Authorization: "Splunk " + this.token, 'Content-Type': 'application/json' }, ((_t = config === null || config === void 0 ? void 0 : config.headers) !== null && _t !== void 0 ? _t : {})); | ||
this.headers = __assign({ Authorization: "Splunk " + this.token }, ((_t = config === null || config === void 0 ? void 0 : config.headers) !== null && _t !== void 0 ? _t : {})); | ||
}; | ||
@@ -335,0 +335,0 @@ /** |
/*! | ||
* splunk-events v1.6.0 | ||
* splunk-events v1.6.1-beta | ||
* Copyright (c) VTEX | ||
@@ -20,3 +20,3 @@ * Released under the MIT License. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var n=function(){return(n=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function t(n,t,e,o){return new(e||(e=Promise))((function(i,s){function u(n){try{l(o.next(n))}catch(n){s(n)}}function r(n){try{l(o.throw(n))}catch(n){s(n)}}function l(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,r)}l((o=o.apply(n,t||[])).next())}))}function e(n,t){var e,o,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function r(s){return function(r){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,o=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(n,u)}catch(n){s=[6,n],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,r])}}}function o(n,t){void 0===t&&(t=100);var e=null,o=null,i=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return e&&(clearTimeout(e),e=null),new Promise((function(s,u){o=u,e=setTimeout((function(){var t=n.apply(void 0,i);null!=t&&t.then(s).catch(u)}),t)}))};return i.clear=function(){e&&(clearTimeout(e),null==o||o(),e=null)},i}function i(t){return"undefined"!=typeof window&&"function"!=typeof window.fetch||"undefined"!=typeof global&&"function"!=typeof global.fetch?(console.log("Error, using fetchRequest without fetch object"),Promise.resolve(null)):fetch(t.url,n(n({},t),{body:t.data})).then((function(n){return"json"===t.responseType?n.json():n}))}var s=function(){function s(s){var u=this;this._requestImpl=i,this.autoFlush=!0,this.autoRetryFlush=!0,this.debounceTime=2e3,this.debug=!1,this.events=[],this.host="-",this.injectAdditionalInfo=!1,this.injectTimestamp=!1,this.isSendingEvents=!1,this.path="/services/collector/event",this.pendingEvents=[],this.shouldParseEventData=!0,this.source="log",this.flushPending=!1,this.useExponentialBackoff=!1,this.exponentialBackoffLimit=6e4,this.isBackoffInProgress=!1,this.maxNumberOfRetries=1/0,this.logEvent=function(t,e,o,i,s,r){void 0===r&&(r=""),u.validateEvent(s);var l=n(n({level:t,type:e,workflowType:o,workflowInstance:i,account:r},s),u.injectAdditionalInfo?u.getAdditionalInfo():{}),a=u.shouldParseEventData?u.parseEventData(l):l,h=n(n({sourcetype:u.source,host:u.host},u.injectTimestamp&&{time:+new Date}),{event:a});u.events.push(h),u.autoFlush&&u.flushEvents()},this.flushEvents=function(){u.useExponentialBackoff?u._backoffFlush():u.debouncedFlush()},this.flush=function(n){return void 0===n&&(n=u.events),t(u,void 0,void 0,(function(){var t,o,i=this;return e(this,(function(e){return this.validateConfig(),0===n.length?[2]:(this.debug&&console.log("sending "+n.length+" events to splunk"),t=this.formatEventsForSplunkBatch(n),[2,this.request({url:""+this.endpoint+this.path,method:"POST",data:t,headers:null!==(o=this.headers)&&void 0!==o?o:{},responseType:"json"}).then((function(){i.debug&&console.log(n.length+" events successfuly sent to splunk")})).catch((function(n){throw i.debug&&console.warn("Error sending events to splunk.",n),n}))])}))}))},this._backoffFlush=function(){if(!u.isBackoffInProgress){u.isBackoffInProgress=!0;var n=function(t){return void 0===t&&(t=0),u.flush().then((function(){u.events=[],u.isBackoffInProgress=!1})).catch((function(){var e=1e3*Math.pow(2,t);return t>u.maxNumberOfRetries?(u.events=[],void(u.isBackoffInProgress=!1)):new Promise((function(o,i){setTimeout((function(){n(t+1).then(o,i).catch(i)}),Math.min(e,u.exponentialBackoffLimit))}))}))};return n()}},this._debouncedFlush=function(){u.isSendingEvents?u.flushPending=!0:(u.pendingEvents=Array.from(u.events),u.events=[],u.isSendingEvents=!0,u.flush(u.pendingEvents).then((function(){if(u.pendingEvents=[],u.isSendingEvents=!1,u.flushPending)return u.flushPending=!1,u._debouncedFlush()})).catch((function(){u.events=u.events.concat(u.pendingEvents),u.pendingEvents=[],u.isSendingEvents=!1,u.autoRetryFlush&&u.flushEvents()})))},this.debouncedFlush=o(this._debouncedFlush,this.debounceTime),s&&this.config(s)}return s.prototype.config=function(t){var e,i,s,u,r,l,a,h,c,f,d,v,p,g,b,m,y,w;this.endpoint=null!==(e=null==t?void 0:t.endpoint)&&void 0!==e?e:this.endpoint,this.token=null!==(i=null==t?void 0:t.token)&&void 0!==i?i:this.endpoint,this.injectAdditionalInfo=null!==(u=null!==(s=null==t?void 0:t.injectAditionalInfo)&&void 0!==s?s:null==t?void 0:t.injectAdditionalInfo)&&void 0!==u?u:this.injectAdditionalInfo,this.useExponentialBackoff=null!==(r=null==t?void 0:t.useExponentialBackoff)&&void 0!==r?r:this.useExponentialBackoff,this.exponentialBackoffLimit=null!==(l=null==t?void 0:t.exponentialBackoffLimit)&&void 0!==l?l:this.exponentialBackoffLimit,this.autoFlush=!!this.useExponentialBackoff||(null!==(a=null==t?void 0:t.autoFlush)&&void 0!==a?a:this.autoFlush),this.autoRetryFlush=null!==(h=null==t?void 0:t.autoRetryFlush)&&void 0!==h?h:this.autoRetryFlush,this.source=null!==(c=null==t?void 0:t.source)&&void 0!==c?c:this.source,this.path=null!==(f=null==t?void 0:t.path)&&void 0!==f?f:this.path,this.host=null!==(d=null==t?void 0:t.host)&&void 0!==d?d:this.host,this.debug=null!==(v=null==t?void 0:t.debug)&&void 0!==v?v:this.debug;var E=this.debounceTime;this.debounceTime=null!==(p=null==t?void 0:t.debounceTime)&&void 0!==p?p:this.debounceTime,this.debounceTime!==E&&(this.debouncedFlush.clear(),this.debouncedFlush=o(this._debouncedFlush,this.debounceTime)),this._requestImpl=null!==(g=null==t?void 0:t.request)&&void 0!==g?g:this._requestImpl,this.injectTimestamp=null!==(b=null==t?void 0:t.injectTimestamp)&&void 0!==b?b:this.injectTimestamp,this.shouldParseEventData=null!==(m=null==t?void 0:t.shouldParseEventData)&&void 0!==m?m:this.shouldParseEventData,this.maxNumberOfRetries=null!==(y=null==t?void 0:t.maxNumberOfRetries)&&void 0!==y?y:this.maxNumberOfRetries,this.headers=n({Authorization:"Splunk "+this.token,"Content-Type":"application/json"},null!==(w=null==t?void 0:t.headers)&&void 0!==w?w:{})},s.prototype.request=function(n){return this._requestImpl(n)},s.prototype.parseEventData=function(n){var t="";for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&null!=n[e]){var o=n[e];switch(typeof o){case"string":t+=e+'="'+o.replace(/"/g,"")+'" ';break;case"boolean":case"number":t+=e+"="+o+" ";break;default:throw new Error("Event property must be string, number or boolean")}}return t},s.prototype.validateEvent=function(n){if(null===n)throw new Error("Event must not be null");if(void 0===n)throw new Error("Event must not be undefined");if("object"!=typeof n)throw new Error("Event must be an object")},s.prototype.getAdditionalInfo=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return"";var n=window.screen,t=window.location;return{additional_info:navigator.userAgent.replace(/,/g,";")+","+(navigator.browserLanguage||navigator.language)+","+navigator.platform+","+(n.availWidth||"-")+","+(n.availHeight||"-")+","+t.hostname+","+t.pathname+","+t.protocol.replace(":","")+","+(t.hash||"-")}},s.prototype.formatEventsForSplunkBatch=function(n){return n.map((function(n){return JSON.stringify(n)})).join("\n")},s.prototype.validateConfig=function(){if(null==this.token)throw new Error("Token must not be null nor undefined");if(null==this.endpoint)throw new Error("Endpoint must not be null nor undefined")},s}();module.exports=s; | ||
***************************************************************************** */var n=function(){return(n=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function t(n,t,e,o){return new(e||(e=Promise))((function(i,s){function u(n){try{l(o.next(n))}catch(n){s(n)}}function r(n){try{l(o.throw(n))}catch(n){s(n)}}function l(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,r)}l((o=o.apply(n,t||[])).next())}))}function e(n,t){var e,o,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function r(s){return function(r){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,o=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(n,u)}catch(n){s=[6,n],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,r])}}}function o(n,t){void 0===t&&(t=100);var e=null,o=null,i=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return e&&(clearTimeout(e),e=null),new Promise((function(s,u){o=u,e=setTimeout((function(){var t=n.apply(void 0,i);null!=t&&t.then(s).catch(u)}),t)}))};return i.clear=function(){e&&(clearTimeout(e),null==o||o(),e=null)},i}function i(t){return"undefined"!=typeof window&&"function"!=typeof window.fetch||"undefined"!=typeof global&&"function"!=typeof global.fetch?(console.log("Error, using fetchRequest without fetch object"),Promise.resolve(null)):fetch(t.url,n(n({},t),{body:t.data})).then((function(n){return"json"===t.responseType?n.json():n}))}var s=function(){function s(s){var u=this;this._requestImpl=i,this.autoFlush=!0,this.autoRetryFlush=!0,this.debounceTime=2e3,this.debug=!1,this.events=[],this.host="-",this.injectAdditionalInfo=!1,this.injectTimestamp=!1,this.isSendingEvents=!1,this.path="/services/collector/event",this.pendingEvents=[],this.shouldParseEventData=!0,this.source="log",this.flushPending=!1,this.useExponentialBackoff=!1,this.exponentialBackoffLimit=6e4,this.isBackoffInProgress=!1,this.maxNumberOfRetries=1/0,this.logEvent=function(t,e,o,i,s,r){void 0===r&&(r=""),u.validateEvent(s);var l=n(n({level:t,type:e,workflowType:o,workflowInstance:i,account:r},s),u.injectAdditionalInfo?u.getAdditionalInfo():{}),a=u.shouldParseEventData?u.parseEventData(l):l,h=n(n({sourcetype:u.source,host:u.host},u.injectTimestamp&&{time:+new Date}),{event:a});u.events.push(h),u.autoFlush&&u.flushEvents()},this.flushEvents=function(){u.useExponentialBackoff?u._backoffFlush():u.debouncedFlush()},this.flush=function(n){return void 0===n&&(n=u.events),t(u,void 0,void 0,(function(){var t,o,i=this;return e(this,(function(e){return this.validateConfig(),0===n.length?[2]:(this.debug&&console.log("sending "+n.length+" events to splunk"),t=this.formatEventsForSplunkBatch(n),[2,this.request({url:""+this.endpoint+this.path,method:"POST",data:t,headers:null!==(o=this.headers)&&void 0!==o?o:{},responseType:"json"}).then((function(){i.debug&&console.log(n.length+" events successfuly sent to splunk")})).catch((function(n){throw i.debug&&console.warn("Error sending events to splunk.",n),n}))])}))}))},this._backoffFlush=function(){if(!u.isBackoffInProgress){u.isBackoffInProgress=!0;var n=function(t){return void 0===t&&(t=0),u.flush().then((function(){u.events=[],u.isBackoffInProgress=!1})).catch((function(){var e=1e3*Math.pow(2,t);return t>u.maxNumberOfRetries?(u.events=[],void(u.isBackoffInProgress=!1)):new Promise((function(o,i){setTimeout((function(){n(t+1).then(o,i).catch(i)}),Math.min(e,u.exponentialBackoffLimit))}))}))};return n()}},this._debouncedFlush=function(){u.isSendingEvents?u.flushPending=!0:(u.pendingEvents=Array.from(u.events),u.events=[],u.isSendingEvents=!0,u.flush(u.pendingEvents).then((function(){if(u.pendingEvents=[],u.isSendingEvents=!1,u.flushPending)return u.flushPending=!1,u._debouncedFlush()})).catch((function(){u.events=u.events.concat(u.pendingEvents),u.pendingEvents=[],u.isSendingEvents=!1,u.autoRetryFlush&&u.flushEvents()})))},this.debouncedFlush=o(this._debouncedFlush,this.debounceTime),s&&this.config(s)}return s.prototype.config=function(t){var e,i,s,u,r,l,a,h,c,f,d,v,p,g,b,m,y,w;this.endpoint=null!==(e=null==t?void 0:t.endpoint)&&void 0!==e?e:this.endpoint,this.token=null!==(i=null==t?void 0:t.token)&&void 0!==i?i:this.endpoint,this.injectAdditionalInfo=null!==(u=null!==(s=null==t?void 0:t.injectAditionalInfo)&&void 0!==s?s:null==t?void 0:t.injectAdditionalInfo)&&void 0!==u?u:this.injectAdditionalInfo,this.useExponentialBackoff=null!==(r=null==t?void 0:t.useExponentialBackoff)&&void 0!==r?r:this.useExponentialBackoff,this.exponentialBackoffLimit=null!==(l=null==t?void 0:t.exponentialBackoffLimit)&&void 0!==l?l:this.exponentialBackoffLimit,this.autoFlush=!!this.useExponentialBackoff||(null!==(a=null==t?void 0:t.autoFlush)&&void 0!==a?a:this.autoFlush),this.autoRetryFlush=null!==(h=null==t?void 0:t.autoRetryFlush)&&void 0!==h?h:this.autoRetryFlush,this.source=null!==(c=null==t?void 0:t.source)&&void 0!==c?c:this.source,this.path=null!==(f=null==t?void 0:t.path)&&void 0!==f?f:this.path,this.host=null!==(d=null==t?void 0:t.host)&&void 0!==d?d:this.host,this.debug=null!==(v=null==t?void 0:t.debug)&&void 0!==v?v:this.debug;var E=this.debounceTime;this.debounceTime=null!==(p=null==t?void 0:t.debounceTime)&&void 0!==p?p:this.debounceTime,this.debounceTime!==E&&(this.debouncedFlush.clear(),this.debouncedFlush=o(this._debouncedFlush,this.debounceTime)),this._requestImpl=null!==(g=null==t?void 0:t.request)&&void 0!==g?g:this._requestImpl,this.injectTimestamp=null!==(b=null==t?void 0:t.injectTimestamp)&&void 0!==b?b:this.injectTimestamp,this.shouldParseEventData=null!==(m=null==t?void 0:t.shouldParseEventData)&&void 0!==m?m:this.shouldParseEventData,this.maxNumberOfRetries=null!==(y=null==t?void 0:t.maxNumberOfRetries)&&void 0!==y?y:this.maxNumberOfRetries,this.headers=n({Authorization:"Splunk "+this.token},null!==(w=null==t?void 0:t.headers)&&void 0!==w?w:{})},s.prototype.request=function(n){return this._requestImpl(n)},s.prototype.parseEventData=function(n){var t="";for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&null!=n[e]){var o=n[e];switch(typeof o){case"string":t+=e+'="'+o.replace(/"/g,"")+'" ';break;case"boolean":case"number":t+=e+"="+o+" ";break;default:throw new Error("Event property must be string, number or boolean")}}return t},s.prototype.validateEvent=function(n){if(null===n)throw new Error("Event must not be null");if(void 0===n)throw new Error("Event must not be undefined");if("object"!=typeof n)throw new Error("Event must be an object")},s.prototype.getAdditionalInfo=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return"";var n=window.screen,t=window.location;return{additional_info:navigator.userAgent.replace(/,/g,";")+","+(navigator.browserLanguage||navigator.language)+","+navigator.platform+","+(n.availWidth||"-")+","+(n.availHeight||"-")+","+t.hostname+","+t.pathname+","+t.protocol.replace(":","")+","+(t.hash||"-")}},s.prototype.formatEventsForSplunkBatch=function(n){return n.map((function(n){return JSON.stringify(n)})).join("\n")},s.prototype.validateConfig=function(){if(null==this.token)throw new Error("Token must not be null nor undefined");if(null==this.endpoint)throw new Error("Endpoint must not be null nor undefined")},s}();module.exports=s; | ||
//# sourceMappingURL=splunk-events.min.js.map |
/*! | ||
* splunk-events v1.6.0 | ||
* splunk-events v1.6.1-beta | ||
* Copyright (c) VTEX | ||
@@ -336,3 +336,3 @@ * Released under the MIT License. | ||
(_s = config === null || config === void 0 ? void 0 : config.maxNumberOfRetries) !== null && _s !== void 0 ? _s : this.maxNumberOfRetries; | ||
this.headers = __assign({ Authorization: "Splunk " + this.token, 'Content-Type': 'application/json' }, ((_t = config === null || config === void 0 ? void 0 : config.headers) !== null && _t !== void 0 ? _t : {})); | ||
this.headers = __assign({ Authorization: "Splunk " + this.token }, ((_t = config === null || config === void 0 ? void 0 : config.headers) !== null && _t !== void 0 ? _t : {})); | ||
}; | ||
@@ -339,0 +339,0 @@ /** |
/*! | ||
* splunk-events v1.6.0 | ||
* splunk-events v1.6.1-beta | ||
* Copyright (c) VTEX | ||
@@ -20,3 +20,3 @@ * Released under the MIT License. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var n=function(){return(n=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function t(n,t,e,o){return new(e||(e=Promise))((function(i,s){function u(n){try{r(o.next(n))}catch(n){s(n)}}function l(n){try{r(o.throw(n))}catch(n){s(n)}}function r(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,l)}r((o=o.apply(n,t||[])).next())}))}function e(n,t){var e,o,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(s){return function(l){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,o=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(n,u)}catch(n){s=[6,n],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function o(n,t){void 0===t&&(t=100);var e=null,o=null,i=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return e&&(clearTimeout(e),e=null),new Promise((function(s,u){o=u,e=setTimeout((function(){var t=n.apply(void 0,i);null!=t&&t.then(s).catch(u)}),t)}))};return i.clear=function(){e&&(clearTimeout(e),null==o||o(),e=null)},i}function i(t){return"undefined"!=typeof window&&"function"!=typeof window.fetch||"undefined"!=typeof global&&"function"!=typeof global.fetch?(console.log("Error, using fetchRequest without fetch object"),Promise.resolve(null)):fetch(t.url,n(n({},t),{body:t.data})).then((function(n){return"json"===t.responseType?n.json():n}))}return function(){function s(s){var u=this;this._requestImpl=i,this.autoFlush=!0,this.autoRetryFlush=!0,this.debounceTime=2e3,this.debug=!1,this.events=[],this.host="-",this.injectAdditionalInfo=!1,this.injectTimestamp=!1,this.isSendingEvents=!1,this.path="/services/collector/event",this.pendingEvents=[],this.shouldParseEventData=!0,this.source="log",this.flushPending=!1,this.useExponentialBackoff=!1,this.exponentialBackoffLimit=6e4,this.isBackoffInProgress=!1,this.maxNumberOfRetries=1/0,this.logEvent=function(t,e,o,i,s,l){void 0===l&&(l=""),u.validateEvent(s);var r=n(n({level:t,type:e,workflowType:o,workflowInstance:i,account:l},s),u.injectAdditionalInfo?u.getAdditionalInfo():{}),a=u.shouldParseEventData?u.parseEventData(r):r,h=n(n({sourcetype:u.source,host:u.host},u.injectTimestamp&&{time:+new Date}),{event:a});u.events.push(h),u.autoFlush&&u.flushEvents()},this.flushEvents=function(){u.useExponentialBackoff?u._backoffFlush():u.debouncedFlush()},this.flush=function(n){return void 0===n&&(n=u.events),t(u,void 0,void 0,(function(){var t,o,i=this;return e(this,(function(e){return this.validateConfig(),0===n.length?[2]:(this.debug&&console.log("sending "+n.length+" events to splunk"),t=this.formatEventsForSplunkBatch(n),[2,this.request({url:""+this.endpoint+this.path,method:"POST",data:t,headers:null!==(o=this.headers)&&void 0!==o?o:{},responseType:"json"}).then((function(){i.debug&&console.log(n.length+" events successfuly sent to splunk")})).catch((function(n){throw i.debug&&console.warn("Error sending events to splunk.",n),n}))])}))}))},this._backoffFlush=function(){if(!u.isBackoffInProgress){u.isBackoffInProgress=!0;var n=function(t){return void 0===t&&(t=0),u.flush().then((function(){u.events=[],u.isBackoffInProgress=!1})).catch((function(){var e=1e3*Math.pow(2,t);return t>u.maxNumberOfRetries?(u.events=[],void(u.isBackoffInProgress=!1)):new Promise((function(o,i){setTimeout((function(){n(t+1).then(o,i).catch(i)}),Math.min(e,u.exponentialBackoffLimit))}))}))};return n()}},this._debouncedFlush=function(){u.isSendingEvents?u.flushPending=!0:(u.pendingEvents=Array.from(u.events),u.events=[],u.isSendingEvents=!0,u.flush(u.pendingEvents).then((function(){if(u.pendingEvents=[],u.isSendingEvents=!1,u.flushPending)return u.flushPending=!1,u._debouncedFlush()})).catch((function(){u.events=u.events.concat(u.pendingEvents),u.pendingEvents=[],u.isSendingEvents=!1,u.autoRetryFlush&&u.flushEvents()})))},this.debouncedFlush=o(this._debouncedFlush,this.debounceTime),s&&this.config(s)}return s.prototype.config=function(t){var e,i,s,u,l,r,a,h,c,f,d,v,p,g,b,m,y,w;this.endpoint=null!==(e=null==t?void 0:t.endpoint)&&void 0!==e?e:this.endpoint,this.token=null!==(i=null==t?void 0:t.token)&&void 0!==i?i:this.endpoint,this.injectAdditionalInfo=null!==(u=null!==(s=null==t?void 0:t.injectAditionalInfo)&&void 0!==s?s:null==t?void 0:t.injectAdditionalInfo)&&void 0!==u?u:this.injectAdditionalInfo,this.useExponentialBackoff=null!==(l=null==t?void 0:t.useExponentialBackoff)&&void 0!==l?l:this.useExponentialBackoff,this.exponentialBackoffLimit=null!==(r=null==t?void 0:t.exponentialBackoffLimit)&&void 0!==r?r:this.exponentialBackoffLimit,this.autoFlush=!!this.useExponentialBackoff||(null!==(a=null==t?void 0:t.autoFlush)&&void 0!==a?a:this.autoFlush),this.autoRetryFlush=null!==(h=null==t?void 0:t.autoRetryFlush)&&void 0!==h?h:this.autoRetryFlush,this.source=null!==(c=null==t?void 0:t.source)&&void 0!==c?c:this.source,this.path=null!==(f=null==t?void 0:t.path)&&void 0!==f?f:this.path,this.host=null!==(d=null==t?void 0:t.host)&&void 0!==d?d:this.host,this.debug=null!==(v=null==t?void 0:t.debug)&&void 0!==v?v:this.debug;var E=this.debounceTime;this.debounceTime=null!==(p=null==t?void 0:t.debounceTime)&&void 0!==p?p:this.debounceTime,this.debounceTime!==E&&(this.debouncedFlush.clear(),this.debouncedFlush=o(this._debouncedFlush,this.debounceTime)),this._requestImpl=null!==(g=null==t?void 0:t.request)&&void 0!==g?g:this._requestImpl,this.injectTimestamp=null!==(b=null==t?void 0:t.injectTimestamp)&&void 0!==b?b:this.injectTimestamp,this.shouldParseEventData=null!==(m=null==t?void 0:t.shouldParseEventData)&&void 0!==m?m:this.shouldParseEventData,this.maxNumberOfRetries=null!==(y=null==t?void 0:t.maxNumberOfRetries)&&void 0!==y?y:this.maxNumberOfRetries,this.headers=n({Authorization:"Splunk "+this.token,"Content-Type":"application/json"},null!==(w=null==t?void 0:t.headers)&&void 0!==w?w:{})},s.prototype.request=function(n){return this._requestImpl(n)},s.prototype.parseEventData=function(n){var t="";for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&null!=n[e]){var o=n[e];switch(typeof o){case"string":t+=e+'="'+o.replace(/"/g,"")+'" ';break;case"boolean":case"number":t+=e+"="+o+" ";break;default:throw new Error("Event property must be string, number or boolean")}}return t},s.prototype.validateEvent=function(n){if(null===n)throw new Error("Event must not be null");if(void 0===n)throw new Error("Event must not be undefined");if("object"!=typeof n)throw new Error("Event must be an object")},s.prototype.getAdditionalInfo=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return"";var n=window.screen,t=window.location;return{additional_info:navigator.userAgent.replace(/,/g,";")+","+(navigator.browserLanguage||navigator.language)+","+navigator.platform+","+(n.availWidth||"-")+","+(n.availHeight||"-")+","+t.hostname+","+t.pathname+","+t.protocol.replace(":","")+","+(t.hash||"-")}},s.prototype.formatEventsForSplunkBatch=function(n){return n.map((function(n){return JSON.stringify(n)})).join("\n")},s.prototype.validateConfig=function(){if(null==this.token)throw new Error("Token must not be null nor undefined");if(null==this.endpoint)throw new Error("Endpoint must not be null nor undefined")},s}()})); | ||
***************************************************************************** */var n=function(){return(n=Object.assign||function(n){for(var t,e=1,o=arguments.length;e<o;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)};function t(n,t,e,o){return new(e||(e=Promise))((function(i,s){function u(n){try{r(o.next(n))}catch(n){s(n)}}function l(n){try{r(o.throw(n))}catch(n){s(n)}}function r(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(u,l)}r((o=o.apply(n,t||[])).next())}))}function e(n,t){var e,o,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function l(s){return function(l){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,o=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(n,u)}catch(n){s=[6,n],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function o(n,t){void 0===t&&(t=100);var e=null,o=null,i=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];return e&&(clearTimeout(e),e=null),new Promise((function(s,u){o=u,e=setTimeout((function(){var t=n.apply(void 0,i);null!=t&&t.then(s).catch(u)}),t)}))};return i.clear=function(){e&&(clearTimeout(e),null==o||o(),e=null)},i}function i(t){return"undefined"!=typeof window&&"function"!=typeof window.fetch||"undefined"!=typeof global&&"function"!=typeof global.fetch?(console.log("Error, using fetchRequest without fetch object"),Promise.resolve(null)):fetch(t.url,n(n({},t),{body:t.data})).then((function(n){return"json"===t.responseType?n.json():n}))}return function(){function s(s){var u=this;this._requestImpl=i,this.autoFlush=!0,this.autoRetryFlush=!0,this.debounceTime=2e3,this.debug=!1,this.events=[],this.host="-",this.injectAdditionalInfo=!1,this.injectTimestamp=!1,this.isSendingEvents=!1,this.path="/services/collector/event",this.pendingEvents=[],this.shouldParseEventData=!0,this.source="log",this.flushPending=!1,this.useExponentialBackoff=!1,this.exponentialBackoffLimit=6e4,this.isBackoffInProgress=!1,this.maxNumberOfRetries=1/0,this.logEvent=function(t,e,o,i,s,l){void 0===l&&(l=""),u.validateEvent(s);var r=n(n({level:t,type:e,workflowType:o,workflowInstance:i,account:l},s),u.injectAdditionalInfo?u.getAdditionalInfo():{}),a=u.shouldParseEventData?u.parseEventData(r):r,h=n(n({sourcetype:u.source,host:u.host},u.injectTimestamp&&{time:+new Date}),{event:a});u.events.push(h),u.autoFlush&&u.flushEvents()},this.flushEvents=function(){u.useExponentialBackoff?u._backoffFlush():u.debouncedFlush()},this.flush=function(n){return void 0===n&&(n=u.events),t(u,void 0,void 0,(function(){var t,o,i=this;return e(this,(function(e){return this.validateConfig(),0===n.length?[2]:(this.debug&&console.log("sending "+n.length+" events to splunk"),t=this.formatEventsForSplunkBatch(n),[2,this.request({url:""+this.endpoint+this.path,method:"POST",data:t,headers:null!==(o=this.headers)&&void 0!==o?o:{},responseType:"json"}).then((function(){i.debug&&console.log(n.length+" events successfuly sent to splunk")})).catch((function(n){throw i.debug&&console.warn("Error sending events to splunk.",n),n}))])}))}))},this._backoffFlush=function(){if(!u.isBackoffInProgress){u.isBackoffInProgress=!0;var n=function(t){return void 0===t&&(t=0),u.flush().then((function(){u.events=[],u.isBackoffInProgress=!1})).catch((function(){var e=1e3*Math.pow(2,t);return t>u.maxNumberOfRetries?(u.events=[],void(u.isBackoffInProgress=!1)):new Promise((function(o,i){setTimeout((function(){n(t+1).then(o,i).catch(i)}),Math.min(e,u.exponentialBackoffLimit))}))}))};return n()}},this._debouncedFlush=function(){u.isSendingEvents?u.flushPending=!0:(u.pendingEvents=Array.from(u.events),u.events=[],u.isSendingEvents=!0,u.flush(u.pendingEvents).then((function(){if(u.pendingEvents=[],u.isSendingEvents=!1,u.flushPending)return u.flushPending=!1,u._debouncedFlush()})).catch((function(){u.events=u.events.concat(u.pendingEvents),u.pendingEvents=[],u.isSendingEvents=!1,u.autoRetryFlush&&u.flushEvents()})))},this.debouncedFlush=o(this._debouncedFlush,this.debounceTime),s&&this.config(s)}return s.prototype.config=function(t){var e,i,s,u,l,r,a,h,c,f,d,v,p,g,b,m,y,w;this.endpoint=null!==(e=null==t?void 0:t.endpoint)&&void 0!==e?e:this.endpoint,this.token=null!==(i=null==t?void 0:t.token)&&void 0!==i?i:this.endpoint,this.injectAdditionalInfo=null!==(u=null!==(s=null==t?void 0:t.injectAditionalInfo)&&void 0!==s?s:null==t?void 0:t.injectAdditionalInfo)&&void 0!==u?u:this.injectAdditionalInfo,this.useExponentialBackoff=null!==(l=null==t?void 0:t.useExponentialBackoff)&&void 0!==l?l:this.useExponentialBackoff,this.exponentialBackoffLimit=null!==(r=null==t?void 0:t.exponentialBackoffLimit)&&void 0!==r?r:this.exponentialBackoffLimit,this.autoFlush=!!this.useExponentialBackoff||(null!==(a=null==t?void 0:t.autoFlush)&&void 0!==a?a:this.autoFlush),this.autoRetryFlush=null!==(h=null==t?void 0:t.autoRetryFlush)&&void 0!==h?h:this.autoRetryFlush,this.source=null!==(c=null==t?void 0:t.source)&&void 0!==c?c:this.source,this.path=null!==(f=null==t?void 0:t.path)&&void 0!==f?f:this.path,this.host=null!==(d=null==t?void 0:t.host)&&void 0!==d?d:this.host,this.debug=null!==(v=null==t?void 0:t.debug)&&void 0!==v?v:this.debug;var E=this.debounceTime;this.debounceTime=null!==(p=null==t?void 0:t.debounceTime)&&void 0!==p?p:this.debounceTime,this.debounceTime!==E&&(this.debouncedFlush.clear(),this.debouncedFlush=o(this._debouncedFlush,this.debounceTime)),this._requestImpl=null!==(g=null==t?void 0:t.request)&&void 0!==g?g:this._requestImpl,this.injectTimestamp=null!==(b=null==t?void 0:t.injectTimestamp)&&void 0!==b?b:this.injectTimestamp,this.shouldParseEventData=null!==(m=null==t?void 0:t.shouldParseEventData)&&void 0!==m?m:this.shouldParseEventData,this.maxNumberOfRetries=null!==(y=null==t?void 0:t.maxNumberOfRetries)&&void 0!==y?y:this.maxNumberOfRetries,this.headers=n({Authorization:"Splunk "+this.token},null!==(w=null==t?void 0:t.headers)&&void 0!==w?w:{})},s.prototype.request=function(n){return this._requestImpl(n)},s.prototype.parseEventData=function(n){var t="";for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&null!=n[e]){var o=n[e];switch(typeof o){case"string":t+=e+'="'+o.replace(/"/g,"")+'" ';break;case"boolean":case"number":t+=e+"="+o+" ";break;default:throw new Error("Event property must be string, number or boolean")}}return t},s.prototype.validateEvent=function(n){if(null===n)throw new Error("Event must not be null");if(void 0===n)throw new Error("Event must not be undefined");if("object"!=typeof n)throw new Error("Event must be an object")},s.prototype.getAdditionalInfo=function(){if("undefined"==typeof navigator||"undefined"==typeof window)return"";var n=window.screen,t=window.location;return{additional_info:navigator.userAgent.replace(/,/g,";")+","+(navigator.browserLanguage||navigator.language)+","+navigator.platform+","+(n.availWidth||"-")+","+(n.availHeight||"-")+","+t.hostname+","+t.pathname+","+t.protocol.replace(":","")+","+(t.hash||"-")}},s.prototype.formatEventsForSplunkBatch=function(n){return n.map((function(n){return JSON.stringify(n)})).join("\n")},s.prototype.validateConfig=function(){if(null==this.token)throw new Error("Token must not be null nor undefined");if(null==this.endpoint)throw new Error("Endpoint must not be null nor undefined")},s}()})); | ||
//# sourceMappingURL=splunk-events.umd.min.js.map |
{ | ||
"name": "splunk-events", | ||
"version": "1.6.0", | ||
"version": "1.6.1-beta", | ||
"description": "Javascript lib to create Splunk Logs via HTTP", | ||
@@ -5,0 +5,0 @@ "main": "lib/splunk-events.min.js", |
@@ -184,3 +184,2 @@ import debounce from './debounce' | ||
Authorization: `Splunk ${this.token}`, | ||
'Content-Type': 'application/json', | ||
...(config?.headers ?? {}), | ||
@@ -187,0 +186,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
268644
2302
2