Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

splunk-events

Package Overview
Dependencies
Maintainers
5
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

splunk-events - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

26

package.json
{
"name": "splunk-events",
"version": "1.2.0",
"version": "1.2.1",
"description": "Javascript lib to create Splunk Logs via HTTP",

@@ -12,14 +12,20 @@ "main": "SplunkEvents.js",

"devDependencies": {
"babel": "6.3.13",
"babel-cli": "^6.18.0",
"babel-core": "6.1.18",
"babel-eslint": "5.0.0",
"babel-plugin-add-module-exports": "0.1.2",
"babel-plugin-transform-object-rest-spread": "^6.19.0",
"babel-preset-es2015": "6.3.13",
"eslint": "1.7.2",
"extend": "^3.0.0"
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"eslint": "^4.12.1"
},
"contributors": [
{
"name": "Guilherme Heynemann Bruzzi"
},
{
"name": "Guilherme Freitas"
},
{
"name": "Tiago Neves"

@@ -26,0 +32,0 @@ },

@@ -14,3 +14,3 @@ # Splunk Events

```npm install splunk-events```
```npm install splunk-events``` or ```yarn add splunk-events```

@@ -193,1 +193,19 @@ -------

http://dev.splunk.com/view/event-collector/SP-CAAAE6P
### Development
After setting up the project with ```npm install``` or ```yarn```, you can run ```npm build``` and ```npm link``` to test it on another project (see examples on how to test it above).
### Deploy
To deploy this package to npm, install the releasy package with ```npm install -g releasy```
Make sure you are logged with the correct user (use ```npm login``` command)
Then choose between patch, minor and major version to release with the commands:
* ```releasy patch --stable```
* ```releasy minor --stable```
* ```releasy major --stable```
After that, SplunkEvents.js will be generated with babel and uploaded to the npm registry with the new version.
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -81,32 +77,9 @@

function SplunkEvents() {
var _this = this;
_classCallCheck(this, SplunkEvents);
}
_createClass(SplunkEvents, [{
key: 'config',
value: function config(_config) {
this.events = [];
this.pendingEvents = [];
this.isSendingEvents = false;
this.endpoint = _config.endpoint; // required
this.token = _config.token; // required
this.injectAditionalInfo = _config.injectAditionalInfo !== undefined ? _config.injectAditionalInfo : false;
this.autoFlush = _config.autoFlush !== undefined ? _config.autoFlush : true;
this.autoRetryFlush = _config.autoRetryFlush !== undefined ? _config.autoRetryFlush : true;
this.source = _config.source !== undefined ? _config.source : 'log';
this.path = _config.path !== undefined ? _config.path : '/services/collector/event';
this.host = _config.host !== undefined ? _config.host : '-';
this.debug = _config.debug !== undefined ? _config.debug : false;
this.debounceTime = _config.debounceTime !== undefined ? _config.debounceTime : 2000;
this.debouncedFlush = debounce(this.flush, this.debounceTime);
this.request = _config.request !== undefined ? _config.request : fetchRequest;
this.headers = {
Authorization: 'Splunk ' + this.token
};
}
}, {
key: 'logEvent',
value: function logEvent(level, type, workflowType, workflowInstance, event, account) {
this.validateEvent(event);
var parsedEvent = this.parseEventData({
this.logEvent = function (level, type, workflowType, workflowInstance, event, account) {
_this.validateEvent(event);
var parsedEvent = _this.parseEventData({
level: level,

@@ -119,93 +92,44 @@ type: type,

parsedEvent += this.parseEventData(event);
parsedEvent += _this.parseEventData(event);
if (this.injectAditionalInfo) {
parsedEvent += this.getAdditionalInfo();
if (_this.injectAditionalInfo) {
parsedEvent += _this.getAdditionalInfo();
}
var data = {
sourcetype: this.source,
host: this.host,
sourcetype: _this.source,
host: _this.host,
event: parsedEvent
};
this.events.push(data);
_this.events.push(data);
if (this.autoFlush) {
this.debouncedFlush();
if (_this.autoFlush) {
_this.debouncedFlush();
}
}
}, {
key: 'parseEventData',
value: function parseEventData(event) {
var parsedEvent = '';
for (var key in event) {
if (event.hasOwnProperty(key) && event[key] != null) {
switch (_typeof(event[key])) {
case 'string':
parsedEvent += key + '="' + event[key].replace(/\"/g, '') + '" ';
break;
case 'boolean':
case 'number':
parsedEvent += key + '=' + event[key] + ' ';
break;
default:
throw 'Event property must be string, number or boolean';
}
}
}
return parsedEvent;
}
}, {
key: 'validateEvent',
value: function validateEvent(event) {
if (event === null) {
throw 'Event must not be null';
}
};
if (event === undefined) {
throw 'Event must not be undefined';
}
if ((typeof event === 'undefined' ? 'undefined' : _typeof(event)) !== 'object') {
throw 'Event must be an object';
}
}
}, {
key: 'getAdditionalInfo',
value: function getAdditionalInfo() {
if (typeof navigator === 'undefined' || typeof window === 'undefined') {
return '';
}
var screen = window.screen ? window.screen : {};
var location = window.location ? window.location : {};
return 'additional_info="' + navigator.userAgent.replace(/\,/g, ';') + ',' + ((navigator.browserLanguage || navigator.language) + ',') + (navigator.platform + ',' + (screen.availWidth || '-') + ',' + (screen.availHeight || '-') + ',' + location.hostname + ',') + (location.pathname + ',' + location.protocol.replace(':', '') + ',' + (location.hash || '-') + '"');
}
}, {
key: 'flush',
value: function flush() {
var _this = this;
if (this.isSendingEvents) {
this.debouncedFlush();
this.flush = function () {
if (_this.isSendingEvents) {
_this.debouncedFlush();
return;
}
this.validateConfig();
_this.validateConfig();
this.pendingEvents = [].concat(this.events);
this.events = [];
this.isSendingEvents = true;
_this.pendingEvents = [].concat(_this.events);
_this.events = [];
_this.isSendingEvents = true;
if (this.debug) {
console.log('sending ' + this.pendingEvents.length + ' events to splunk');
if (_this.debug) {
console.log('sending ' + _this.pendingEvents.length + ' events to splunk');
}
var splunkBatchedFormattedEvents = this.formatEventsForSplunkBatch(this.pendingEvents);
var splunkBatchedFormattedEvents = _this.formatEventsForSplunkBatch(_this.pendingEvents);
this.request({
url: '' + this.endpoint + this.path,
_this.request({
url: '' + _this.endpoint + _this.path,
method: 'POST',
data: splunkBatchedFormattedEvents,
headers: this.headers,
headers: _this.headers,
responseType: 'json'

@@ -234,35 +158,97 @@ }).then(function (response) {

});
}
}, {
key: 'formatEventsForSplunkBatch',
value: function formatEventsForSplunkBatch(events) {
var splunkBatchedFormattedEvents = '';
};
}
for (var i = 0; i < events.length; i++) {
splunkBatchedFormattedEvents += '\n' + JSON.stringify(events[i]) + '\n';
SplunkEvents.prototype.config = function config(_config) {
this.events = [];
this.pendingEvents = [];
this.isSendingEvents = false;
this.endpoint = _config.endpoint; // required
this.token = _config.token; // required
this.injectAditionalInfo = _config.injectAditionalInfo !== undefined ? _config.injectAditionalInfo : false;
this.autoFlush = _config.autoFlush !== undefined ? _config.autoFlush : true;
this.autoRetryFlush = _config.autoRetryFlush !== undefined ? _config.autoRetryFlush : true;
this.source = _config.source !== undefined ? _config.source : 'log';
this.path = _config.path !== undefined ? _config.path : '/services/collector/event';
this.host = _config.host !== undefined ? _config.host : '-';
this.debug = _config.debug !== undefined ? _config.debug : false;
this.debounceTime = _config.debounceTime !== undefined ? _config.debounceTime : 2000;
this.debouncedFlush = debounce(this.flush, this.debounceTime);
this.request = _config.request !== undefined ? _config.request : fetchRequest;
this.headers = {
Authorization: 'Splunk ' + this.token
};
};
SplunkEvents.prototype.parseEventData = function parseEventData(event) {
var parsedEvent = '';
for (var key in event) {
if (event.hasOwnProperty(key) && event[key] != null) {
switch (_typeof(event[key])) {
case 'string':
parsedEvent += key + '="' + event[key].replace(/\"/g, '') + '" ';
break;
case 'boolean':
case 'number':
parsedEvent += key + '=' + event[key] + ' ';
break;
default:
throw 'Event property must be string, number or boolean';
}
}
}
return parsedEvent;
};
return splunkBatchedFormattedEvents;
SplunkEvents.prototype.validateEvent = function validateEvent(event) {
if (event === null) {
throw 'Event must not be null';
}
}, {
key: 'validateConfig',
value: function validateConfig() {
if (this.token === null) {
throw 'Token must not be null';
}
if (this.token === undefined) {
throw 'Token must not be undefined';
}
if (event === undefined) {
throw 'Event must not be undefined';
}
if (this.endpoint === null) {
throw 'endpoint must not be null';
}
if ((typeof event === 'undefined' ? 'undefined' : _typeof(event)) !== 'object') {
throw 'Event must be an object';
}
};
if (this.endpoint === undefined) {
throw 'endpoint must not be undefined';
}
SplunkEvents.prototype.getAdditionalInfo = function getAdditionalInfo() {
if (typeof navigator === 'undefined' || typeof window === 'undefined') {
return '';
}
}]);
var screen = window.screen ? window.screen : {};
var location = window.location ? window.location : {};
return 'additional_info="' + navigator.userAgent.replace(/\,/g, ';') + ',' + ((navigator.browserLanguage || navigator.language) + ',') + (navigator.platform + ',' + (screen.availWidth || '-') + ',' + (screen.availHeight || '-') + ',' + location.hostname + ',') + (location.pathname + ',' + location.protocol.replace(':', '') + ',' + (location.hash || '-') + '"');
};
SplunkEvents.prototype.formatEventsForSplunkBatch = function formatEventsForSplunkBatch(events) {
var splunkBatchedFormattedEvents = '';
for (var i = 0; i < events.length; i++) {
splunkBatchedFormattedEvents += '\n' + JSON.stringify(events[i]) + '\n';
}
return splunkBatchedFormattedEvents;
};
SplunkEvents.prototype.validateConfig = function validateConfig() {
if (this.token === null) {
throw 'Token must not be null';
}
if (this.token === undefined) {
throw 'Token must not be undefined';
}
if (this.endpoint === null) {
throw 'endpoint must not be null';
}
if (this.endpoint === undefined) {
throw 'endpoint must not be undefined';
}
};
return SplunkEvents;

@@ -269,0 +255,0 @@ }();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc