splunk-events
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -1,2 +0,3 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("splunk-events",[],e):"object"==typeof exports?exports["splunk-events"]=e():t["splunk-events"]=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),s=n(1),a=r(s),c=n(8),f=r(c),l=n(37),p=r(l),d=function(){function t(){o(this,t)}return u(t,[{key:"config",value:function(t){this.events=[],this.endpoint=t.endpoint,this.token=t.token,this.index=t.index,this.autoFlush=t.autoFlush||!0,this.autoRetryFlush=t.autoRetryFlush||!0,this.source=t.source||"datasource",this.path=t.path||"/services/collector/event",this.sourcetype=t.sourcetype||"log",this.debug=t.debug||!1,this.debounceTime=t.debounceTime||2e3,this.debounceMaxWait=t.debounceMaxWait||5e3,this.debouncedFlush=(0,a["default"])(this.flush,this.debounceTime,{},!1,this.debounceMaxWait),this.axiosInstance=p["default"].create({baseURL:""+this.endpoint,headers:{Authorization:"Splunk "+this.token},responseType:"json"})}},{key:"logEvent",value:function(t){this.validateEvent(t),t=(0,f["default"])(t,this.getAdditionalInfo());var e={time:(new Date).getTime(),host:this.host,source:this.source,event:t};this.events.push(e),this.autoFlush&&this.debouncedFlush()}},{key:"validateEvent",value:function(t){if(null===t)throw"Event must not be null";if(void 0===t)throw"Event must not be undefined";if("object"!==("undefined"==typeof t?"undefined":i(t)))throw"Event must be an object"}},{key:"getAdditionalInfo",value:function(){return{userAgent:navigator.userAgent,language:navigator.browserLanguage||navigator.language,platform:navigator.platform,screenWidth:window.screen.availWidth,screenHeight:window.screen.availHeight,host:window.location.host,path:window.location.pathname,protocol:window.location.protocol,hash:window.location.hash}}},{key:"flush",value:function(){var t=this;this.validateConfig(),this.debug&&console.log("sending "+this.events.length+" events to splunk");var e=this.formatEventsForSplunkBatch(this.events);this.axiosInstance.post(this.path,e).then(function(e){t.debug&&console.log(t.events.length+" events successfuly sent to splunk"),t.events=[]})["catch"](function(e){t.autoRetryFlush?(t.debug&&console.warn("Error sending events to splunk. Retrying in 5 seconds."),t.debouncedFlush()):t.debug&&console.warn("Error sending events to splunk.")})}},{key:"formatEventsForSplunkBatch",value:function(t){for(var e="",n=0;n<t.length;n++)e+="\n"+JSON.stringify(t[n])+"\n";return e}},{key:"validateConfig",value:function(){if(null===this.token)throw"Token must not be null";if(void 0===this.token)throw"Token must not be undefined";if(null===this.endpoint)throw"endpoint must not be null";if(void 0===this.endpoint)throw"endpoint must not be undefined"}}]),t}();e["default"]=d,t.exports=e["default"]},function(t,e,n){function r(t,e,n){function r(e){var n=g,r=b;return g=b=void 0,S=e,w=t.apply(r,n)}function f(t){return S=t,j=setTimeout(d,e),A?r(t):w}function l(t){var n=t-E,r=t-S,o=e-n;return O?c(o,x-r):o}function p(t){var n=t-E,r=t-S;return void 0===E||n>=e||n<0||O&&r>=x}function d(){var t=i();return p(t)?h(t):void(j=setTimeout(d,l(t)))}function h(t){return j=void 0,T&&g?r(t):(g=b=void 0,w)}function v(){S=0,g=E=b=j=void 0}function y(){return void 0===j?w:h(i())}function m(){var t=i(),n=p(t);if(g=arguments,b=this,E=t,n){if(void 0===j)return f(E);if(O)return j=setTimeout(d,e),r(E)}return void 0===j&&(j=setTimeout(d,e)),w}var g,b,x,w,j,E,S=0,A=!1,O=!1,T=!0;if("function"!=typeof t)throw new TypeError(s);return e=u(e)||0,o(n)&&(A=!!n.leading,O="maxWait"in n,x=O?a(u(n.maxWait)||0,e):x,T="trailing"in n?!!n.trailing:T),m.cancel=v,m.flush=y,m}var o=n(2),i=n(3),u=n(4),s="Expected a function",a=Math.max,c=Math.min;t.exports=r},function(t,e){function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e){function n(){return Date.now()}t.exports=n},function(t,e,n){function r(t){if("number"==typeof t)return t;if(u(t))return s;if(i(t)){var e=o(t.valueOf)?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(a,"");var n=f.test(t);return n||l.test(t)?p(t.slice(2),n?2:8):c.test(t)?s:+t}var o=n(5),i=n(2),u=n(6),s=NaN,a=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,l=/^0o[0-7]+$/i,p=parseInt;t.exports=r},function(t,e,n){function r(t){var e=o(t)?a.call(t):"";return e==i||e==u}var o=n(2),i="[object Function]",u="[object GeneratorFunction]",s=Object.prototype,a=s.toString;t.exports=r},function(t,e,n){function r(t){return"symbol"==typeof t||o(t)&&s.call(t)==i}var o=n(7),i="[object Symbol]",u=Object.prototype,s=u.toString;t.exports=r},function(t,e){function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,e,n){t.exports=n(9)},function(t,e,n){var r=n(10),o=n(12),i=n(13),u=n(15),s=n(24),a=n(25),c=Object.prototype,f=c.propertyIsEnumerable,l=!f.call({valueOf:1},"valueOf"),p=i(function(t,e){if(l||s(e)||u(e))return void o(e,a(e),t);for(var n in e)r(t,n,e[n])});t.exports=p},function(t,e,n){function r(t,e,n){var r=t[e];u.call(t,e)&&o(r,n)&&(void 0!==n||e in t)||(t[e]=n)}var o=n(11),i=Object.prototype,u=i.hasOwnProperty;t.exports=r},function(t,e){function n(t,e){return t===e||t!==t&&e!==e}t.exports=n},function(t,e,n){function r(t,e,n,r){n||(n={});for(var i=-1,u=e.length;++i<u;){var s=e[i],a=r?r(n[s],t[s],s,n,t):t[s];o(n,s,a)}return n}var o=n(10);t.exports=r},function(t,e,n){function r(t){return i(function(e,n){var r=-1,i=n.length,u=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(u=t.length>3&&"function"==typeof u?(i--,u):void 0,s&&o(n[0],n[1],s)&&(u=i<3?void 0:u,i=1),e=Object(e);++r<i;){var a=n[r];a&&t(e,a,r,u)}return e})}var o=n(14),i=n(20);t.exports=r},function(t,e,n){function r(t,e,n){if(!s(n))return!1;var r=typeof e;return!!("number"==r?i(n)&&u(e,n.length):"string"==r&&e in n)&&o(n[e],t)}var o=n(11),i=n(15),u=n(19),s=n(2);t.exports=r},function(t,e,n){function r(t){return null!=t&&u(o(t))&&!i(t)}var o=n(16),i=n(5),u=n(18);t.exports=r},function(t,e,n){var r=n(17),o=r("length");t.exports=o},function(t,e){function n(t){return function(e){return null==e?void 0:e[t]}}t.exports=n},function(t,e){function n(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}var r=9007199254740991;t.exports=n},function(t,e){function n(t,e){return e=null==e?r:e,!!e&&("number"==typeof t||o.test(t))&&t>-1&&t%1==0&&t<e}var r=9007199254740991,o=/^(?:0|[1-9]\d*)$/;t.exports=n},function(t,e,n){function r(t,e){if("function"!=typeof t)throw new TypeError(u);return e=s(void 0===e?t.length-1:i(e),0),function(){for(var n=arguments,r=-1,i=s(n.length-e,0),u=Array(i);++r<i;)u[r]=n[e+r];switch(e){case 0:return t.call(this,u);case 1:return t.call(this,n[0],u);case 2:return t.call(this,n[0],n[1],u)}var a=Array(e+1);for(r=-1;++r<e;)a[r]=n[r];return a[e]=u,o(t,this,a)}}var o=n(21),i=n(22),u="Expected a function",s=Math.max;t.exports=r},function(t,e){function n(t,e,n){var r=n.length;switch(r){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}t.exports=n},function(t,e,n){function r(t){var e=o(t),n=e%1;return e===e?n?e-n:e:0}var o=n(23);t.exports=r},function(t,e,n){function r(t){if(!t)return 0===t?t:0;if(t=o(t),t===i||t===-i){var e=t<0?-1:1;return e*u}return t===t?t:0}var o=n(4),i=1/0,u=1.7976931348623157e308;t.exports=r},function(t,e){function n(t){var e=t&&t.constructor,n="function"==typeof e&&e.prototype||r;return t===n}var r=Object.prototype;t.exports=n},function(t,e,n){function r(t){for(var e=-1,n=s(t),r=o(t),a=r.length,f=i(t),l=!!f,p=f||[],d=p.length;++e<a;){var h=r[e];l&&("length"==h||u(h,d))||"constructor"==h&&(n||!c.call(t,h))||p.push(h)}return p}var o=n(26),i=n(31),u=n(19),s=n(24),a=Object.prototype,c=a.hasOwnProperty;t.exports=r},function(t,e,n){function r(t){t=null==t?t:Object(t);var e=[];for(var n in t)e.push(n);return e}var o=n(27),i=n(30),u=Object.prototype,s=o?o.enumerate:void 0,a=u.propertyIsEnumerable;s&&!a.call({valueOf:1},"valueOf")&&(r=function(t){return i(s(t))}),t.exports=r},function(t,e,n){var r=n(28),o=r.Reflect;t.exports=o},function(t,e,n){(function(e){var r=n(29),o=r("object"==typeof e&&e),i=r("object"==typeof self&&self),u=r("object"==typeof this&&this),s=o||i||u||Function("return this")();t.exports=s}).call(e,function(){return this}())},function(t,e){function n(t){return t&&t.Object===Object?t:null}t.exports=n},function(t,e){function n(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}t.exports=n},function(t,e,n){function r(t){var e=t?t.length:void 0;return s(e)&&(u(t)||a(t)||i(t))?o(e,String):null}var o=n(32),i=n(33),u=n(35),s=n(18),a=n(36);t.exports=r},function(t,e){function n(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}t.exports=n},function(t,e,n){function r(t){return o(t)&&s.call(t,"callee")&&(!c.call(t,"callee")||a.call(t)==i)}var o=n(34),i="[object Arguments]",u=Object.prototype,s=u.hasOwnProperty,a=u.toString,c=u.propertyIsEnumerable;t.exports=r},function(t,e,n){function r(t){return i(t)&&o(t)}var o=n(15),i=n(7);t.exports=r},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){function r(t){return"string"==typeof t||!o(t)&&i(t)&&a.call(t)==u}var o=n(35),i=n(7),u="[object String]",s=Object.prototype,a=s.toString;t.exports=r},function(t,e,n){t.exports=n(38)},function(t,e,n){"use strict";function r(t){var e=new u(t),n=i(u.prototype.request,e);return o.extend(n,u.prototype,e),o.extend(n,e),n}var o=n(39),i=n(40),u=n(41),s=t.exports=r();s.Axios=u,s.create=function(t){return r(t)},s.all=function(t){return Promise.all(t)},s.spread=n(59)},function(t,e,n){"use strict";function r(t){return"[object Array]"===E.call(t)}function o(t){return"[object ArrayBuffer]"===E.call(t)}function i(t){return"undefined"!=typeof FormData&&t instanceof FormData}function u(t){var e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer}function s(t){return"string"==typeof t}function a(t){return"number"==typeof t}function c(t){return"undefined"==typeof t}function f(t){return null!==t&&"object"==typeof t}function l(t){return"[object Date]"===E.call(t)}function p(t){return"[object File]"===E.call(t)}function d(t){return"[object Blob]"===E.call(t)}function h(t){return"[object Function]"===E.call(t)}function v(t){return f(t)&&h(t.pipe)}function y(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams}function m(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function b(t,e){if(null!==t&&"undefined"!=typeof t)if("object"==typeof t||r(t)||(t=[t]),r(t))for(var n=0,o=t.length;n<o;n++)e.call(null,t[n],n,t);else for(var i in t)t.hasOwnProperty(i)&&e.call(null,t[i],i,t)}function x(){function t(t,n){"object"==typeof e[n]&&"object"==typeof t?e[n]=x(e[n],t):e[n]=t}for(var e={},n=0,r=arguments.length;n<r;n++)b(arguments[n],t);return e}function w(t,e,n){return b(e,function(e,r){n&&"function"==typeof e?t[r]=j(e,n):t[r]=e}),t}var j=n(40),E=Object.prototype.toString;t.exports={isArray:r,isArrayBuffer:o,isFormData:i,isArrayBufferView:u,isString:s,isNumber:a,isObject:f,isUndefined:c,isDate:l,isFile:p,isBlob:d,isFunction:h,isStream:v,isURLSearchParams:y,isStandardBrowserEnv:g,forEach:b,merge:x,extend:w,trim:m}},function(t,e){"use strict";t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}}},function(t,e,n){"use strict";function r(t){this.defaults=i.merge(o,t),this.interceptors={request:new u,response:new u}}var o=n(42),i=n(39),u=n(44),s=n(45),a=n(57),c=n(58);r.prototype.request=function(t){"string"==typeof t&&(t=i.merge({url:arguments[0]},arguments[1])),t=i.merge(o,this.defaults,{method:"get"},t),t.baseURL&&!a(t.url)&&(t.url=c(t.baseURL,t.url));var e=[s,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)n=n.then(e.shift(),e.shift());return n},i.forEach(["delete","get","head"],function(t){r.prototype[t]=function(e,n){return this.request(i.merge(n||{},{method:t,url:e}))}}),i.forEach(["post","put","patch"],function(t){r.prototype[t]=function(e,n,r){return this.request(i.merge(r||{},{method:t,url:e,data:n}))}}),t.exports=r},function(t,e,n){"use strict";function r(t,e){!o.isUndefined(t)&&o.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var o=n(39),i=n(43),u=/^\)\]\}',?\n/,s={"Content-Type":"application/x-www-form-urlencoded"};t.exports={transformRequest:[function(t,e){return i(e,"Content-Type"),o.isFormData(t)||o.isArrayBuffer(t)||o.isStream(t)||o.isFile(t)||o.isBlob(t)?t:o.isArrayBufferView(t)?t.buffer:o.isURLSearchParams(t)?(r(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):o.isObject(t)?(r(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t){t=t.replace(u,"");try{t=JSON.parse(t)}catch(e){}}return t}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:o.merge(s),post:o.merge(s),put:o.merge(s)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(t){return t>=200&&t<300}}},function(t,e,n){"use strict";var r=n(39);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){"use strict";function r(){this.handlers=[]}var o=n(39);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){o.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){(function(e){"use strict";var r=n(39),o=n(47);t.exports=function(t){t.headers=t.headers||{},t.data=o(t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]});var i;return"function"==typeof t.adapter?i=t.adapter:"undefined"!=typeof XMLHttpRequest?i=n(48):"undefined"!=typeof e&&(i=n(48)),Promise.resolve(t).then(i).then(function(e){return e.data=o(e.data,e.headers,t.transformResponse),e},function(e){return e&&e.response&&(e.response.data=o(e.response.data,e.response.headers,t.transformResponse)),Promise.reject(e)})}}).call(e,n(46))},function(t,e){function n(){l&&c&&(l=!1,c.length?f=c.concat(f):p=-1,f.length&&r())}function r(){if(!l){var t=u(n);l=!0;for(var e=f.length;e;){for(c=f,f=[];++p<e;)c&&c[p].run();p=-1,e=f.length}c=null,l=!1,s(t)}}function o(t,e){this.fun=t,this.array=e}function i(){}var u,s,a=t.exports={};!function(){try{u=setTimeout}catch(t){u=function(){throw new Error("setTimeout is not defined")}}try{s=clearTimeout}catch(t){s=function(){throw new Error("clearTimeout is not defined")}}}();var c,f=[],l=!1,p=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];f.push(new o(t,e)),1!==f.length||l||u(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=i,a.addListener=i,a.once=i,a.off=i,a.removeListener=i,a.removeAllListeners=i,a.emit=i,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e,n){"use strict";var r=n(39);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){(function(e){"use strict";var r=n(39),o=n(49),i=n(52),u=n(53),s=n(54),a=n(50),c="undefined"!=typeof window&&window.btoa||n(55);t.exports=function(t){return new Promise(function(f,l){var p=t.data,d=t.headers;r.isFormData(p)&&delete d["Content-Type"];var h=new XMLHttpRequest,v="onreadystatechange",y=!1;if("test"===e.env.NODE_ENV||"undefined"==typeof window||!window.XDomainRequest||"withCredentials"in h||s(t.url)||(h=new window.XDomainRequest,v="onload",y=!0,h.onprogress=function(){},h.ontimeout=function(){}),t.auth){var m=t.auth.username||"",g=t.auth.password||"";d.Authorization="Basic "+c(m+":"+g)}if(h.open(t.method.toUpperCase(),i(t.url,t.params,t.paramsSerializer),!0),h.timeout=t.timeout,h[v]=function(){if(h&&(4===h.readyState||y)&&0!==h.status){var e="getAllResponseHeaders"in h?u(h.getAllResponseHeaders()):null,n=t.responseType&&"text"!==t.responseType?h.response:h.responseText,r={data:n,status:1223===h.status?204:h.status,statusText:1223===h.status?"No Content":h.statusText,headers:e,config:t,request:h};o(f,l,r),h=null}},h.onerror=function(){l(a("Network Error",t)),h=null},h.ontimeout=function(){l(a("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED")),h=null},r.isStandardBrowserEnv()){var b=n(56),x=t.withCredentials||s(t.url)?b.read(t.xsrfCookieName):void 0;x&&(d[t.xsrfHeaderName]=x)}if("setRequestHeader"in h&&r.forEach(d,function(t,e){"undefined"==typeof p&&"content-type"===e.toLowerCase()?delete d[e]:h.setRequestHeader(e,t)}),t.withCredentials&&(h.withCredentials=!0),t.responseType)try{h.responseType=t.responseType}catch(w){if("json"!==h.responseType)throw w}"function"==typeof t.progress&&("post"===t.method||"put"===t.method?h.upload.addEventListener("progress",t.progress):"get"===t.method&&h.addEventListener("progress",t.progress)),void 0===p&&(p=null),h.send(p)})}}).call(e,n(46))},function(t,e,n){"use strict";var r=n(50);t.exports=function(t,e,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n)):t(n)}},function(t,e,n){"use strict";var r=n(51);t.exports=function(t,e,n,o){var i=new Error(t);return r(i,e,n,o)}},function(t,e){"use strict";t.exports=function(t,e,n,r){return t.config=e,n&&(t.code=n),t.response=r,t}},function(t,e,n){"use strict";function r(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(39);t.exports=function(t,e,n){if(!e)return t;var i;if(n)i=n(e);else if(o.isURLSearchParams(e))i=e.toString();else{var u=[];o.forEach(e,function(t,e){null!==t&&"undefined"!=typeof t&&(o.isArray(t)&&(e+="[]"),o.isArray(t)||(t=[t]),o.forEach(t,function(t){o.isDate(t)?t=t.toISOString():o.isObject(t)&&(t=JSON.stringify(t)),u.push(r(e)+"="+r(t))}))}),i=u.join("&")}return i&&(t+=(t.indexOf("?")===-1?"?":"&")+i),t}},function(t,e,n){"use strict";var r=n(39);t.exports=function(t){var e,n,o,i={};return t?(r.forEach(t.split("\n"),function(t){o=t.indexOf(":"),e=r.trim(t.substr(0,o)).toLowerCase(),n=r.trim(t.substr(o+1)),e&&(i[e]=i[e]?i[e]+", "+n:n)}),i):i}},function(t,e,n){"use strict";var r=n(39);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(o.setAttribute("href",e),e=o.href),o.setAttribute("href",e),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return e=t(window.location.href),function(n){var o=r.isString(n)?t(n):n;return o.protocol===e.protocol&&o.host===e.host}}():function(){return function(){return!0}}()},function(t,e){"use strict";function n(){this.message="String contains an invalid character"}function r(t){for(var e,r,i=String(t),u="",s=0,a=o;i.charAt(0|s)||(a="=",s%1);u+=a.charAt(63&e>>8-s%1*8)){if(r=i.charCodeAt(s+=.75),r>255)throw new n;e=e<<8|r}return u}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",t.exports=r},function(t,e,n){"use strict";var r=n(39);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,o,i,u){var s=[];s.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(o)&&s.push("path="+o),r.isString(i)&&s.push("domain="+i),u===!0&&s.push("secure"),document.cookie=s.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e){"use strict";t.exports=function(t,e){return t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,"")}},function(t,e){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("splunk-events",[],e):"object"==typeof exports?exports["splunk-events"]=e():t["splunk-events"]=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),c=n(1),a=r(c),s=n(8),f=r(s),p=n(37),l=r(p),h=n(115),d=r(h),v=n(118),y=r(v),b=function(){function t(){o(this,t)}return u(t,[{key:"config",value:function(t){this.events=[],this.pendingEvents=[],this.isSendingEvents=!1,this.endpoint=t.endpoint,this.token=t.token,this.index=t.index,this.autoFlush=t.autoFlush||!0,this.autoRetryFlush=t.autoRetryFlush||!0,this.source=t.source||"datasource",this.path=t.path||"/services/collector/event",this.sourcetype=t.sourcetype||"log",this.debug=t.debug||!1,this.debounceTime=t.debounceTime||2e3,this.debounceMaxWait=t.debounceMaxWait||5e3,this.debouncedFlush=(0,a["default"])(this.flush,this.debounceTime,{},!1,this.debounceMaxWait),this.axiosInstance=y["default"].create({baseURL:""+this.endpoint,headers:{Authorization:"Splunk "+this.token},responseType:"json"})}},{key:"logEvent",value:function(t){this.validateEvent(t),t=(0,f["default"])(t,this.getAdditionalInfo());var e={time:(new Date).getTime(),host:this.host,source:this.source,event:t};this.events.push(e),this.autoFlush&&this.debouncedFlush()}},{key:"validateEvent",value:function(t){if(null===t)throw"Event must not be null";if(void 0===t)throw"Event must not be undefined";if("object"!==("undefined"==typeof t?"undefined":i(t)))throw"Event must be an object"}},{key:"getAdditionalInfo",value:function(){return{userAgent:navigator.userAgent,language:navigator.browserLanguage||navigator.language,platform:navigator.platform,screenWidth:window.screen.availWidth,screenHeight:window.screen.availHeight,host:window.location.host,path:window.location.pathname,protocol:window.location.protocol,hash:window.location.hash}}},{key:"flush",value:function(){var t=this;if(this.isSendingEvents)return void this.debouncedFlush();this.validateConfig(),this.pendingEvents=(0,l["default"])(this.events),this.events=[],this.isSendingEvents=!0,this.debug&&console.log("sending "+this.pendingEvents.length+" events to splunk");var e=this.formatEventsForSplunkBatch(this.pendingEvents);this.axiosInstance.post(this.path,e).then(function(e){t.debug&&console.log(t.pendingEvents.length+" events successfuly sent to splunk"),t.pendingEvents=[],t.isSendingEvents=!1})["catch"](function(e){t.events=(0,d["default"])(t.events,t.pendingEvents),t.pendingEvents=[],t.isSendingEvents=!1,t.autoRetryFlush?(t.debug&&console.warn("Error sending events to splunk. Retrying in 5 seconds."),t.debouncedFlush()):t.debug&&console.warn("Error sending events to splunk.")})}},{key:"formatEventsForSplunkBatch",value:function(t){for(var e="",n=0;n<t.length;n++)e+="\n"+JSON.stringify(t[n])+"\n";return e}},{key:"validateConfig",value:function(){if(null===this.token)throw"Token must not be null";if(void 0===this.token)throw"Token must not be undefined";if(null===this.endpoint)throw"endpoint must not be null";if(void 0===this.endpoint)throw"endpoint must not be undefined"}}]),t}();e["default"]=b,t.exports=e["default"]},function(t,e,n){function r(t,e,n){function r(e){var n=g,r=x;return g=x=void 0,E=e,w=t.apply(r,n)}function f(t){return E=t,j=setTimeout(h,e),O?r(t):w}function p(t){var n=t-_,r=t-E,o=e-n;return A?s(o,m-r):o}function l(t){var n=t-_,r=t-E;return void 0===_||n>=e||n<0||A&&r>=m}function h(){var t=i();return l(t)?d(t):void(j=setTimeout(h,p(t)))}function d(t){return j=void 0,S&&g?r(t):(g=x=void 0,w)}function v(){E=0,g=_=x=j=void 0}function y(){return void 0===j?w:d(i())}function b(){var t=i(),n=l(t);if(g=arguments,x=this,_=t,n){if(void 0===j)return f(_);if(A)return j=setTimeout(h,e),r(_)}return void 0===j&&(j=setTimeout(h,e)),w}var g,x,m,w,j,_,E=0,O=!1,A=!1,S=!0;if("function"!=typeof t)throw new TypeError(c);return e=u(e)||0,o(n)&&(O=!!n.leading,A="maxWait"in n,m=A?a(u(n.maxWait)||0,e):m,S="trailing"in n?!!n.trailing:S),b.cancel=v,b.flush=y,b}var o=n(2),i=n(3),u=n(4),c="Expected a function",a=Math.max,s=Math.min;t.exports=r},function(t,e){function n(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}t.exports=n},function(t,e){function n(){return Date.now()}t.exports=n},function(t,e,n){function r(t){if("number"==typeof t)return t;if(u(t))return c;if(i(t)){var e=o(t.valueOf)?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(a,"");var n=f.test(t);return n||p.test(t)?l(t.slice(2),n?2:8):s.test(t)?c:+t}var o=n(5),i=n(2),u=n(6),c=NaN,a=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,p=/^0o[0-7]+$/i,l=parseInt;t.exports=r},function(t,e,n){function r(t){var e=o(t)?a.call(t):"";return e==i||e==u}var o=n(2),i="[object Function]",u="[object GeneratorFunction]",c=Object.prototype,a=c.toString;t.exports=r},function(t,e,n){function r(t){return"symbol"==typeof t||o(t)&&c.call(t)==i}var o=n(7),i="[object Symbol]",u=Object.prototype,c=u.toString;t.exports=r},function(t,e){function n(t){return!!t&&"object"==typeof t}t.exports=n},function(t,e,n){t.exports=n(9)},function(t,e,n){var r=n(10),o=n(12),i=n(13),u=n(15),c=n(24),a=n(25),s=Object.prototype,f=s.propertyIsEnumerable,p=!f.call({valueOf:1},"valueOf"),l=i(function(t,e){if(p||c(e)||u(e))return void o(e,a(e),t);for(var n in e)r(t,n,e[n])});t.exports=l},function(t,e,n){function r(t,e,n){var r=t[e];u.call(t,e)&&o(r,n)&&(void 0!==n||e in t)||(t[e]=n)}var o=n(11),i=Object.prototype,u=i.hasOwnProperty;t.exports=r},function(t,e){function n(t,e){return t===e||t!==t&&e!==e}t.exports=n},function(t,e,n){function r(t,e,n,r){n||(n={});for(var i=-1,u=e.length;++i<u;){var c=e[i],a=r?r(n[c],t[c],c,n,t):t[c];o(n,c,a)}return n}var o=n(10);t.exports=r},function(t,e,n){function r(t){return i(function(e,n){var r=-1,i=n.length,u=i>1?n[i-1]:void 0,c=i>2?n[2]:void 0;for(u=t.length>3&&"function"==typeof u?(i--,u):void 0,c&&o(n[0],n[1],c)&&(u=i<3?void 0:u,i=1),e=Object(e);++r<i;){var a=n[r];a&&t(e,a,r,u)}return e})}var o=n(14),i=n(20);t.exports=r},function(t,e,n){function r(t,e,n){if(!c(n))return!1;var r=typeof e;return!!("number"==r?i(n)&&u(e,n.length):"string"==r&&e in n)&&o(n[e],t)}var o=n(11),i=n(15),u=n(19),c=n(2);t.exports=r},function(t,e,n){function r(t){return null!=t&&u(o(t))&&!i(t)}var o=n(16),i=n(5),u=n(18);t.exports=r},function(t,e,n){var r=n(17),o=r("length");t.exports=o},function(t,e){function n(t){return function(e){return null==e?void 0:e[t]}}t.exports=n},function(t,e){function n(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}var r=9007199254740991;t.exports=n},function(t,e){function n(t,e){return e=null==e?r:e,!!e&&("number"==typeof t||o.test(t))&&t>-1&&t%1==0&&t<e}var r=9007199254740991,o=/^(?:0|[1-9]\d*)$/;t.exports=n},function(t,e,n){function r(t,e){if("function"!=typeof t)throw new TypeError(u);return e=c(void 0===e?t.length-1:i(e),0),function(){for(var n=arguments,r=-1,i=c(n.length-e,0),u=Array(i);++r<i;)u[r]=n[e+r];switch(e){case 0:return t.call(this,u);case 1:return t.call(this,n[0],u);case 2:return t.call(this,n[0],n[1],u)}var a=Array(e+1);for(r=-1;++r<e;)a[r]=n[r];return a[e]=u,o(t,this,a)}}var o=n(21),i=n(22),u="Expected a function",c=Math.max;t.exports=r},function(t,e){function n(t,e,n){var r=n.length;switch(r){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}t.exports=n},function(t,e,n){function r(t){var e=o(t),n=e%1;return e===e?n?e-n:e:0}var o=n(23);t.exports=r},function(t,e,n){function r(t){if(!t)return 0===t?t:0;if(t=o(t),t===i||t===-i){var e=t<0?-1:1;return e*u}return t===t?t:0}var o=n(4),i=1/0,u=1.7976931348623157e308;t.exports=r},function(t,e){function n(t){var e=t&&t.constructor,n="function"==typeof e&&e.prototype||r;return t===n}var r=Object.prototype;t.exports=n},function(t,e,n){function r(t){for(var e=-1,n=c(t),r=o(t),a=r.length,f=i(t),p=!!f,l=f||[],h=l.length;++e<a;){var d=r[e];p&&("length"==d||u(d,h))||"constructor"==d&&(n||!s.call(t,d))||l.push(d)}return l}var o=n(26),i=n(31),u=n(19),c=n(24),a=Object.prototype,s=a.hasOwnProperty;t.exports=r},function(t,e,n){function r(t){t=null==t?t:Object(t);var e=[];for(var n in t)e.push(n);return e}var o=n(27),i=n(30),u=Object.prototype,c=o?o.enumerate:void 0,a=u.propertyIsEnumerable;c&&!a.call({valueOf:1},"valueOf")&&(r=function(t){return i(c(t))}),t.exports=r},function(t,e,n){var r=n(28),o=r.Reflect;t.exports=o},function(t,e,n){(function(e){var r=n(29),o=r("object"==typeof e&&e),i=r("object"==typeof self&&self),u=r("object"==typeof this&&this),c=o||i||u||Function("return this")();t.exports=c}).call(e,function(){return this}())},function(t,e){function n(t){return t&&t.Object===Object?t:null}t.exports=n},function(t,e){function n(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}t.exports=n},function(t,e,n){function r(t){var e=t?t.length:void 0;return c(e)&&(u(t)||a(t)||i(t))?o(e,String):null}var o=n(32),i=n(33),u=n(35),c=n(18),a=n(36);t.exports=r},function(t,e){function n(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}t.exports=n},function(t,e,n){function r(t){return o(t)&&c.call(t,"callee")&&(!s.call(t,"callee")||a.call(t)==i)}var o=n(34),i="[object Arguments]",u=Object.prototype,c=u.hasOwnProperty,a=u.toString,s=u.propertyIsEnumerable;t.exports=r},function(t,e,n){function r(t){return i(t)&&o(t)}var o=n(15),i=n(7);t.exports=r},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){function r(t){return"string"==typeof t||!o(t)&&i(t)&&a.call(t)==u}var o=n(35),i=n(7),u="[object String]",c=Object.prototype,a=c.toString;t.exports=r},function(t,e,n){function r(t){return o(t,!1,!0)}var o=n(38);t.exports=r},function(t,e,n){function r(t,e,n,j,_,E,O){var k;if(j&&(k=E?j(t,_,E,O):j(t)),void 0!==k)return k;if(!x(t))return t;var R=y(t);if(R){if(k=h(t),!e)return s(t,k)}else{var F=l(t),C=F==A||F==S;if(b(t))return a(t,e);if(F==T||F==w||C&&!E){if(g(t))return E?t:{};if(k=v(C?{}:t),!e)return f(t,c(k,t))}else{if(!X[F])return E?t:{};k=d(t,F,r,e)}}O||(O=new o);var P=O.get(t);if(P)return P;if(O.set(t,k),!R)var B=n?p(t):m(t);return i(B||t,function(o,i){B&&(i=o,o=t[i]),u(k,i,r(o,e,n,j,i,t,O))}),k}var o=n(39),i=n(75),u=n(10),c=n(76),a=n(81),s=n(82),f=n(83),p=n(86),l=n(89),h=n(94),d=n(95),v=n(110),y=n(35),b=n(112),g=n(59),x=n(2),m=n(77),w="[object Arguments]",j="[object Array]",_="[object Boolean]",E="[object Date]",O="[object Error]",A="[object Function]",S="[object GeneratorFunction]",k="[object Map]",R="[object Number]",T="[object Object]",F="[object RegExp]",C="[object Set]",P="[object String]",B="[object Symbol]",U="[object WeakMap]",D="[object ArrayBuffer]",I="[object DataView]",N="[object Float32Array]",L="[object Float64Array]",M="[object Int8Array]",q="[object Int16Array]",$="[object Int32Array]",H="[object Uint8Array]",W="[object Uint8ClampedArray]",V="[object Uint16Array]",z="[object Uint32Array]",X={};X[w]=X[j]=X[D]=X[I]=X[_]=X[E]=X[N]=X[L]=X[M]=X[q]=X[$]=X[k]=X[R]=X[T]=X[F]=X[C]=X[P]=X[B]=X[H]=X[W]=X[V]=X[z]=!0,X[O]=X[A]=X[U]=!1,t.exports=r},function(t,e,n){function r(t){this.__data__=new o(t)}var o=n(40),i=n(47),u=n(48),c=n(49),a=n(50),s=n(51);r.prototype.clear=i,r.prototype["delete"]=u,r.prototype.get=c,r.prototype.has=a,r.prototype.set=s,t.exports=r},function(t,e,n){function r(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}var o=n(41),i=n(42),u=n(44),c=n(45),a=n(46);r.prototype.clear=o,r.prototype["delete"]=i,r.prototype.get=u,r.prototype.has=c,r.prototype.set=a,t.exports=r},function(t,e){function n(){this.__data__=[]}t.exports=n},function(t,e,n){function r(t){var e=this.__data__,n=o(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():u.call(e,n,1),!0}var o=n(43),i=Array.prototype,u=i.splice;t.exports=r},function(t,e,n){function r(t,e){for(var n=t.length;n--;)if(o(t[n][0],e))return n;return-1}var o=n(11);t.exports=r},function(t,e,n){function r(t){var e=this.__data__,n=o(e,t);return n<0?void 0:e[n][1]}var o=n(43);t.exports=r},function(t,e,n){function r(t){return o(this.__data__,t)>-1}var o=n(43);t.exports=r},function(t,e,n){function r(t,e){var n=this.__data__,r=o(n,t);return r<0?n.push([t,e]):n[r][1]=e,this}var o=n(43);t.exports=r},function(t,e,n){function r(){this.__data__=new o}var o=n(40);t.exports=r},function(t,e){function n(t){return this.__data__["delete"](t)}t.exports=n},function(t,e){function n(t){return this.__data__.get(t)}t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e,n){function r(t,e){var n=this.__data__;return n instanceof o&&n.__data__.length==u&&(n=this.__data__=new i(n.__data__)),n.set(t,e),this}var o=n(40),i=n(52),u=200;t.exports=r},function(t,e,n){function r(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}var o=n(53),i=n(69),u=n(72),c=n(73),a=n(74);r.prototype.clear=o,r.prototype["delete"]=i,r.prototype.get=u,r.prototype.has=c,r.prototype.set=a,t.exports=r},function(t,e,n){function r(){this.__data__={hash:new o,map:new(u||i),string:new o}}var o=n(54),i=n(40),u=n(68);t.exports=r},function(t,e,n){function r(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}var o=n(55),i=n(64),u=n(65),c=n(66),a=n(67);r.prototype.clear=o,r.prototype["delete"]=i,r.prototype.get=u,r.prototype.has=c,r.prototype.set=a,t.exports=r},function(t,e,n){function r(){this.__data__=o?o(null):{}}var o=n(56);t.exports=r},function(t,e,n){var r=n(57),o=r(Object,"create");t.exports=o},function(t,e,n){function r(t,e){var n=i(t,e);return o(n)?n:void 0}var o=n(58),i=n(63);t.exports=r},function(t,e,n){function r(t){if(!c(t)||u(t))return!1;var e=o(t)||i(t)?d:f;return e.test(a(t))}var o=n(5),i=n(59),u=n(60),c=n(2),a=n(62),s=/[\\^$.*+?()[\]{}|]/g,f=/^\[object .+?Constructor\]$/,p=Object.prototype,l=Function.prototype.toString,h=p.hasOwnProperty,d=RegExp("^"+l.call(h).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=r},function(t,e){function n(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(n){}return e}t.exports=n},function(t,e,n){function r(t){return!!i&&i in t}var o=n(61),i=function(){var t=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();t.exports=r},function(t,e,n){var r=n(28),o=r["__core-js_shared__"];t.exports=o},function(t,e){function n(t){if(null!=t){try{return r.call(t)}catch(e){}try{return t+""}catch(e){}}return""}var r=Function.prototype.toString;t.exports=n},function(t,e){function n(t,e){return null==t?void 0:t[e]}t.exports=n},function(t,e){function n(t){return this.has(t)&&delete this.__data__[t]}t.exports=n},function(t,e,n){function r(t){var e=this.__data__;if(o){var n=e[t];return n===i?void 0:n}return c.call(e,t)?e[t]:void 0}var o=n(56),i="__lodash_hash_undefined__",u=Object.prototype,c=u.hasOwnProperty;t.exports=r},function(t,e,n){function r(t){var e=this.__data__;return o?void 0!==e[t]:u.call(e,t)}var o=n(56),i=Object.prototype,u=i.hasOwnProperty;t.exports=r},function(t,e,n){function r(t,e){var n=this.__data__;return n[t]=o&&void 0===e?i:e,this}var o=n(56),i="__lodash_hash_undefined__";t.exports=r},function(t,e,n){var r=n(57),o=n(28),i=r(o,"Map");t.exports=i},function(t,e,n){function r(t){return o(this,t)["delete"](t)}var o=n(70);t.exports=r},function(t,e,n){function r(t,e){var n=t.__data__;return o(e)?n["string"==typeof e?"string":"hash"]:n.map}var o=n(71);t.exports=r},function(t,e){function n(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}t.exports=n},function(t,e,n){function r(t){return o(this,t).get(t)}var o=n(70);t.exports=r},function(t,e,n){function r(t){return o(this,t).has(t)}var o=n(70);t.exports=r},function(t,e,n){function r(t,e){return o(this,t).set(t,e),this}var o=n(70);t.exports=r},function(t,e){function n(t,e){for(var n=-1,r=t?t.length:0;++n<r&&e(t[n],n,t)!==!1;);return t}t.exports=n},function(t,e,n){function r(t,e){return t&&o(e,i(e),t)}var o=n(12),i=n(77);t.exports=r},function(t,e,n){function r(t){var e=s(t);if(!e&&!c(t))return i(t);var n=u(t),r=!!n,f=n||[],p=f.length;for(var l in t)!o(t,l)||r&&("length"==l||a(l,p))||e&&"constructor"==l||f.push(l);return f}var o=n(78),i=n(80),u=n(31),c=n(15),a=n(19),s=n(24);t.exports=r},function(t,e,n){function r(t,e){return null!=t&&(u.call(t,e)||"object"==typeof t&&e in t&&null===o(t))}var o=n(79),i=Object.prototype,u=i.hasOwnProperty;t.exports=r},function(t,e){function n(t){return r(Object(t))}var r=Object.getPrototypeOf;t.exports=n},function(t,e){function n(t){return r(Object(t))}var r=Object.keys;t.exports=n},function(t,e){function n(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}t.exports=n},function(t,e){function n(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}t.exports=n},function(t,e,n){function r(t,e){return o(t,i(t),e)}var o=n(12),i=n(84);t.exports=r},function(t,e,n){function r(t){return i(Object(t))}var o=n(85),i=Object.getOwnPropertySymbols;i||(r=o),t.exports=r},function(t,e){function n(){return[]}t.exports=n},function(t,e,n){function r(t){return o(t,u,i)}var o=n(87),i=n(84),u=n(77);t.exports=r},function(t,e,n){function r(t,e,n){var r=e(t);return i(t)?r:o(r,n(t))}var o=n(88),i=n(35);t.exports=r},function(t,e){function n(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}t.exports=n},function(t,e,n){function r(t){return b.call(t)}var o=n(90),i=n(68),u=n(91),c=n(92),a=n(93),s=n(62),f="[object Map]",p="[object Object]",l="[object Promise]",h="[object Set]",d="[object WeakMap]",v="[object DataView]",y=Object.prototype,b=y.toString,g=s(o),x=s(i),m=s(u),w=s(c),j=s(a);(o&&r(new o(new ArrayBuffer(1)))!=v||i&&r(new i)!=f||u&&r(u.resolve())!=l||c&&r(new c)!=h||a&&r(new a)!=d)&&(r=function(t){var e=b.call(t),n=e==p?t.constructor:void 0,r=n?s(n):void 0;if(r)switch(r){case g:return v;case x:return f;case m:return l;case w:return h;case j:return d}return e}),t.exports=r},function(t,e,n){var r=n(57),o=n(28),i=r(o,"DataView");t.exports=i},function(t,e,n){var r=n(57),o=n(28),i=r(o,"Promise");t.exports=i},function(t,e,n){var r=n(57),o=n(28),i=r(o,"Set");t.exports=i},function(t,e,n){var r=n(57),o=n(28),i=r(o,"WeakMap");t.exports=i},function(t,e){function n(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&o.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var r=Object.prototype,o=r.hasOwnProperty;t.exports=n},function(t,e,n){function r(t,e,n,r){var T=t.constructor;switch(e){case x:return o(t);case p:case l:return new T((+t));case m:return i(t,r);case w:case j:case _:case E:case O:case A:case S:case k:case R:return f(t,r);case h:return u(t,r,n);case d:case b:return new T(t);case v:return c(t);case y:return a(t,r,n);case g:return s(t)}}var o=n(96),i=n(98),u=n(99),c=n(103),a=n(104),s=n(107),f=n(109),p="[object Boolean]",l="[object Date]",h="[object Map]",d="[object Number]",v="[object RegExp]",y="[object Set]",b="[object String]",g="[object Symbol]",x="[object ArrayBuffer]",m="[object DataView]",w="[object Float32Array]",j="[object Float64Array]",_="[object Int8Array]",E="[object Int16Array]",O="[object Int32Array]",A="[object Uint8Array]",S="[object Uint8ClampedArray]",k="[object Uint16Array]",R="[object Uint32Array]";t.exports=r},function(t,e,n){function r(t){var e=new t.constructor(t.byteLength);return new o(e).set(new o(t)),e}var o=n(97);t.exports=r},function(t,e,n){var r=n(28),o=r.Uint8Array;t.exports=o},function(t,e,n){function r(t,e){var n=e?o(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}var o=n(96);t.exports=r},function(t,e,n){function r(t,e,n){var r=e?n(u(t),!0):u(t);return i(r,o,new t.constructor)}var o=n(100),i=n(101),u=n(102);t.exports=r},function(t,e){function n(t,e){return t.set(e[0],e[1]),t}t.exports=n},function(t,e){function n(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}t.exports=n},function(t,e){function n(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}t.exports=n},function(t,e){function n(t){var e=new t.constructor(t.source,r.exec(t));return e.lastIndex=t.lastIndex,e}var r=/\w*$/;t.exports=n},function(t,e,n){function r(t,e,n){var r=e?n(u(t),!0):u(t);return i(r,o,new t.constructor)}var o=n(105),i=n(101),u=n(106);t.exports=r},function(t,e){function n(t,e){return t.add(e),t}t.exports=n},function(t,e){function n(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}t.exports=n},function(t,e,n){function r(t){return u?Object(u.call(t)):{}}var o=n(108),i=o?o.prototype:void 0,u=i?i.valueOf:void 0;t.exports=r},function(t,e,n){var r=n(28),o=r.Symbol;t.exports=o},function(t,e,n){function r(t,e){var n=e?o(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}var o=n(96);t.exports=r},function(t,e,n){function r(t){return"function"!=typeof t.constructor||u(t)?{}:o(i(t))}var o=n(111),i=n(79),u=n(24);t.exports=r},function(t,e,n){function r(t){return o(t)?i(t):{}}var o=n(2),i=Object.create;t.exports=r},function(t,e,n){(function(t){var r=n(28),o=n(114),i="object"==typeof e&&e,u=i&&"object"==typeof t&&t,c=u&&u.exports===i,a=c?r.Buffer:void 0,s=a?function(t){return t instanceof a}:o;t.exports=s}).call(e,n(113)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){function n(){return!1}t.exports=n},function(t,e,n){function r(){for(var t=arguments.length,e=Array(t?t-1:0),n=arguments[0],r=t;r--;)e[r-1]=arguments[r];return t?o(c(n)?u(n):[n],i(e,1)):[]}var o=n(88),i=n(116),u=n(82),c=n(35);t.exports=r},function(t,e,n){function r(t,e,n,u,c){var a=-1,s=t.length;for(n||(n=i),c||(c=[]);++a<s;){var f=t[a];e>0&&n(f)?e>1?r(f,e-1,n,u,c):o(c,f):u||(c[c.length]=f)}return c}var o=n(88),i=n(117);t.exports=r},function(t,e,n){function r(t){return i(t)||o(t)}var o=n(33),i=n(35);t.exports=r},function(t,e,n){t.exports=n(119)},function(t,e,n){"use strict";function r(t){var e=new u(t),n=i(u.prototype.request,e);return o.extend(n,u.prototype,e),o.extend(n,e),n}var o=n(120),i=n(121),u=n(122),c=t.exports=r();c.Axios=u,c.create=function(t){return r(t)},c.all=function(t){return Promise.all(t)},c.spread=n(140)},function(t,e,n){"use strict";function r(t){return"[object Array]"===_.call(t)}function o(t){return"[object ArrayBuffer]"===_.call(t)}function i(t){return"undefined"!=typeof FormData&&t instanceof FormData}function u(t){var e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer}function c(t){return"string"==typeof t}function a(t){return"number"==typeof t}function s(t){return"undefined"==typeof t}function f(t){return null!==t&&"object"==typeof t}function p(t){return"[object Date]"===_.call(t)}function l(t){return"[object File]"===_.call(t)}function h(t){return"[object Blob]"===_.call(t)}function d(t){return"[object Function]"===_.call(t)}function v(t){return f(t)&&d(t.pipe)}function y(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams}function b(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function x(t,e){if(null!==t&&"undefined"!=typeof t)if("object"==typeof t||r(t)||(t=[t]),r(t))for(var n=0,o=t.length;n<o;n++)e.call(null,t[n],n,t);else for(var i in t)t.hasOwnProperty(i)&&e.call(null,t[i],i,t)}function m(){function t(t,n){"object"==typeof e[n]&&"object"==typeof t?e[n]=m(e[n],t):e[n]=t}for(var e={},n=0,r=arguments.length;n<r;n++)x(arguments[n],t);return e}function w(t,e,n){return x(e,function(e,r){n&&"function"==typeof e?t[r]=j(e,n):t[r]=e}),t}var j=n(121),_=Object.prototype.toString;t.exports={isArray:r,isArrayBuffer:o,isFormData:i,isArrayBufferView:u,isString:c,isNumber:a,isObject:f,isUndefined:s,isDate:p,isFile:l,isBlob:h,isFunction:d,isStream:v,isURLSearchParams:y,isStandardBrowserEnv:g,forEach:x,merge:m,extend:w,trim:b}},function(t,e){"use strict";t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}}},function(t,e,n){"use strict";function r(t){this.defaults=i.merge(o,t),this.interceptors={request:new u,response:new u}}var o=n(123),i=n(120),u=n(125),c=n(126),a=n(138),s=n(139);r.prototype.request=function(t){"string"==typeof t&&(t=i.merge({url:arguments[0]},arguments[1])),t=i.merge(o,this.defaults,{method:"get"},t),t.baseURL&&!a(t.url)&&(t.url=s(t.baseURL,t.url));var e=[c,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach(function(t){e.unshift(t.fulfilled,t.rejected)}),this.interceptors.response.forEach(function(t){e.push(t.fulfilled,t.rejected)});e.length;)n=n.then(e.shift(),e.shift());return n},i.forEach(["delete","get","head"],function(t){r.prototype[t]=function(e,n){return this.request(i.merge(n||{},{method:t,url:e}))}}),i.forEach(["post","put","patch"],function(t){r.prototype[t]=function(e,n,r){return this.request(i.merge(r||{},{method:t,url:e,data:n}))}}),t.exports=r},function(t,e,n){"use strict";function r(t,e){!o.isUndefined(t)&&o.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var o=n(120),i=n(124),u=/^\)\]\}',?\n/,c={"Content-Type":"application/x-www-form-urlencoded"};t.exports={transformRequest:[function(t,e){return i(e,"Content-Type"),o.isFormData(t)||o.isArrayBuffer(t)||o.isStream(t)||o.isFile(t)||o.isBlob(t)?t:o.isArrayBufferView(t)?t.buffer:o.isURLSearchParams(t)?(r(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):o.isObject(t)?(r(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t){t=t.replace(u,"");try{t=JSON.parse(t)}catch(e){}}return t}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:o.merge(c),post:o.merge(c),put:o.merge(c)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(t){return t>=200&&t<300}}},function(t,e,n){"use strict";var r=n(120);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){"use strict";function r(){this.handlers=[]}var o=n(120);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){o.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){(function(e){"use strict";var r=n(120),o=n(128);t.exports=function(t){t.headers=t.headers||{},t.data=o(t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]});var i;return"function"==typeof t.adapter?i=t.adapter:"undefined"!=typeof XMLHttpRequest?i=n(129):"undefined"!=typeof e&&(i=n(129)),Promise.resolve(t).then(i).then(function(e){return e.data=o(e.data,e.headers,t.transformResponse),e},function(e){return e&&e.response&&(e.response.data=o(e.response.data,e.response.headers,t.transformResponse)),Promise.reject(e)})}}).call(e,n(127))},function(t,e){function n(){p&&s&&(p=!1,s.length?f=s.concat(f):l=-1,f.length&&r())}function r(){if(!p){var t=u(n);p=!0;for(var e=f.length;e;){for(s=f,f=[];++l<e;)s&&s[l].run();l=-1,e=f.length}s=null,p=!1,c(t)}}function o(t,e){this.fun=t,this.array=e}function i(){}var u,c,a=t.exports={};!function(){try{u=setTimeout}catch(t){u=function(){throw new Error("setTimeout is not defined")}}try{c=clearTimeout}catch(t){c=function(){throw new Error("clearTimeout is not defined")}}}();var s,f=[],p=!1,l=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];f.push(new o(t,e)),1!==f.length||p||u(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=i,a.addListener=i,a.once=i,a.off=i,a.removeListener=i,a.removeAllListeners=i,a.emit=i,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e,n){"use strict";var r=n(120);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){(function(e){"use strict";var r=n(120),o=n(130),i=n(133),u=n(134),c=n(135),a=n(131),s="undefined"!=typeof window&&window.btoa||n(136);t.exports=function(t){return new Promise(function(f,p){var l=t.data,h=t.headers;r.isFormData(l)&&delete h["Content-Type"];var d=new XMLHttpRequest,v="onreadystatechange",y=!1;if("test"===e.env.NODE_ENV||"undefined"==typeof window||!window.XDomainRequest||"withCredentials"in d||c(t.url)||(d=new window.XDomainRequest,v="onload",y=!0,d.onprogress=function(){},d.ontimeout=function(){}),t.auth){var b=t.auth.username||"",g=t.auth.password||"";h.Authorization="Basic "+s(b+":"+g)}if(d.open(t.method.toUpperCase(),i(t.url,t.params,t.paramsSerializer),!0),d.timeout=t.timeout,d[v]=function(){if(d&&(4===d.readyState||y)&&0!==d.status){var e="getAllResponseHeaders"in d?u(d.getAllResponseHeaders()):null,n=t.responseType&&"text"!==t.responseType?d.response:d.responseText,r={data:n,status:1223===d.status?204:d.status,statusText:1223===d.status?"No Content":d.statusText,headers:e,config:t,request:d};o(f,p,r),d=null}},d.onerror=function(){p(a("Network Error",t)),d=null},d.ontimeout=function(){p(a("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED")),d=null},r.isStandardBrowserEnv()){var x=n(137),m=t.withCredentials||c(t.url)?x.read(t.xsrfCookieName):void 0;m&&(h[t.xsrfHeaderName]=m)}if("setRequestHeader"in d&&r.forEach(h,function(t,e){"undefined"==typeof l&&"content-type"===e.toLowerCase()?delete h[e]:d.setRequestHeader(e,t)}),t.withCredentials&&(d.withCredentials=!0),t.responseType)try{d.responseType=t.responseType}catch(w){if("json"!==d.responseType)throw w}"function"==typeof t.progress&&("post"===t.method||"put"===t.method?d.upload.addEventListener("progress",t.progress):"get"===t.method&&d.addEventListener("progress",t.progress)),void 0===l&&(l=null),d.send(l)})}}).call(e,n(127))},function(t,e,n){"use strict";var r=n(131);t.exports=function(t,e,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n)):t(n)}},function(t,e,n){"use strict";var r=n(132);t.exports=function(t,e,n,o){var i=new Error(t);return r(i,e,n,o)}},function(t,e){"use strict";t.exports=function(t,e,n,r){return t.config=e,n&&(t.code=n),t.response=r,t}},function(t,e,n){"use strict";function r(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(120);t.exports=function(t,e,n){if(!e)return t;var i;if(n)i=n(e);else if(o.isURLSearchParams(e))i=e.toString();else{var u=[];o.forEach(e,function(t,e){null!==t&&"undefined"!=typeof t&&(o.isArray(t)&&(e+="[]"),o.isArray(t)||(t=[t]),o.forEach(t,function(t){o.isDate(t)?t=t.toISOString():o.isObject(t)&&(t=JSON.stringify(t)),u.push(r(e)+"="+r(t))}))}),i=u.join("&"); | ||
}return i&&(t+=(t.indexOf("?")===-1?"?":"&")+i),t}},function(t,e,n){"use strict";var r=n(120);t.exports=function(t){var e,n,o,i={};return t?(r.forEach(t.split("\n"),function(t){o=t.indexOf(":"),e=r.trim(t.substr(0,o)).toLowerCase(),n=r.trim(t.substr(o+1)),e&&(i[e]=i[e]?i[e]+", "+n:n)}),i):i}},function(t,e,n){"use strict";var r=n(120);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(o.setAttribute("href",e),e=o.href),o.setAttribute("href",e),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return e=t(window.location.href),function(n){var o=r.isString(n)?t(n):n;return o.protocol===e.protocol&&o.host===e.host}}():function(){return function(){return!0}}()},function(t,e){"use strict";function n(){this.message="String contains an invalid character"}function r(t){for(var e,r,i=String(t),u="",c=0,a=o;i.charAt(0|c)||(a="=",c%1);u+=a.charAt(63&e>>8-c%1*8)){if(r=i.charCodeAt(c+=.75),r>255)throw new n;e=e<<8|r}return u}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",t.exports=r},function(t,e,n){"use strict";var r=n(120);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,o,i,u){var c=[];c.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),r.isString(o)&&c.push("path="+o),r.isString(i)&&c.push("domain="+i),u===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e){"use strict";t.exports=function(t,e){return t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,"")}},function(t,e){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}}])}); | ||
//# sourceMappingURL=splunk-events.min.js.map |
{ | ||
"name": "splunk-events", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"description": "Javascript lib to create Splunk Logs via HTTP", | ||
@@ -5,0 +5,0 @@ "main": "dist/splunk-events.js", |
import debounce from 'lodash/debounce'; | ||
import extend from 'lodash/extend'; | ||
import clone from 'lodash/clone'; | ||
import concat from 'lodash/concat'; | ||
import axios from 'axios'; | ||
@@ -9,2 +11,4 @@ | ||
this.events = []; | ||
this.pendingEvents = []; | ||
this.isSendingEvents = false; | ||
@@ -81,16 +85,30 @@ this.endpoint = config.endpoint; // required | ||
flush() { | ||
if (this.isSendingEvents) { | ||
this.debouncedFlush(); | ||
return; | ||
} | ||
this.validateConfig(); | ||
this.pendingEvents = clone(this.events); | ||
this.events = []; | ||
this.isSendingEvents = true; | ||
if (this.debug) { | ||
console.log(`sending ${this.events.length} events to splunk`); | ||
console.log(`sending ${this.pendingEvents.length} events to splunk`); | ||
} | ||
let splunkBatchedFormattedEvents = this.formatEventsForSplunkBatch(this.events); | ||
let splunkBatchedFormattedEvents = this.formatEventsForSplunkBatch(this.pendingEvents); | ||
this.axiosInstance.post(this.path, splunkBatchedFormattedEvents).then((response) => { | ||
if (this.debug) { | ||
console.log(`${this.events.length} events successfuly sent to splunk`); | ||
console.log(`${this.pendingEvents.length} events successfuly sent to splunk`); | ||
} | ||
this.events = []; | ||
this.pendingEvents = []; | ||
this.isSendingEvents = false; | ||
}).catch((e) => { | ||
this.events = concat(this.events, this.pendingEvents); | ||
this.pendingEvents = []; | ||
this.isSendingEvents = false; | ||
if (this.autoRetryFlush) { | ||
@@ -97,0 +115,0 @@ if (this.debug) { |
Sorry, the diff of this file is too big to display
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
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
724291
4843