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

libhoney

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libhoney - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

155

dist/libhoney.cjs.js

@@ -5,3 +5,21 @@ 'use strict';

var proxy = _interopDefault(require('superagent-proxy'));
function _interopNamespace(e) {
if (e && e.__esModule) { return e; } else {
var n = {};
if (e) {
Object.keys(e).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
});
}
n['default'] = e;
return n;
}
}
var superagent = _interopDefault(require('superagent'));

@@ -179,3 +197,3 @@ var url = _interopDefault(require('url'));

const USER_AGENT = "libhoney-js/2.0.1";
const USER_AGENT = "libhoney-js/2.0.2";

@@ -453,75 +471,82 @@ const _global =

let url = urljoin(batch.apiHost, "/1/batch", batch.dataset);
let req = superagent.post(url);
if (this._proxy) {
req = proxy(req, this._proxy);
}
let postReq = superagent.post(url);
const reqPromise = Promise.resolve(
this._proxy
? new Promise(function (resolve) { resolve(_interopNamespace(require('superagent-proxy'))); }).then(({ default: proxy }) => ({
req: proxy(postReq, this._proxy)
}))
: { req: postReq }
);
let { encoded, numEncoded } = batchAgg.encodeBatchEvents(batch.events);
return new Promise(resolve => {
// if we failed to encode any of the events, no point in sending anything to honeycomb
if (numEncoded === 0) {
this._responseCallback(
batch.events.map(ev => ({
metadata: ev.metadata,
error: ev.encodeError
}))
);
resolve();
return;
}
let userAgent = USER_AGENT;
let trimmedAddition = this._userAgentAddition.trim();
if (trimmedAddition) {
userAgent = `${USER_AGENT} ${trimmedAddition}`;
}
let start = Date.now();
req
.set("X-Honeycomb-Team", batch.writeKey)
.set("User-Agent", userAgent)
.type("json")
.send(encoded)
.end((err, res) => {
let end = Date.now();
if (err) {
return reqPromise.then(
({ req }) =>
new Promise(resolve => {
// if we failed to encode any of the events, no point in sending anything to honeycomb
if (numEncoded === 0) {
this._responseCallback(
batch.events.map(ev => ({
// eslint-disable-next-line camelcase
status_code: ev.encodeError ? undefined : err.status,
duration: end - start,
metadata: ev.metadata,
error: ev.encodeError || err
error: ev.encodeError
}))
);
} else {
let response = JSON.parse(res.text);
let respIdx = 0;
this._responseCallback(
batch.events.map(ev => {
if (ev.encodeError) {
return {
duration: end - start,
metadata: ev.metadata,
error: ev.encodeError
};
} else {
let nextResponse = response[respIdx++];
return {
resolve();
return;
}
let userAgent = USER_AGENT;
let trimmedAddition = this._userAgentAddition.trim();
if (trimmedAddition) {
userAgent = `${USER_AGENT} ${trimmedAddition}`;
}
let start = Date.now();
req
.set("X-Honeycomb-Team", batch.writeKey)
.set("User-Agent", userAgent)
.type("json")
.send(encoded)
.end((err, res) => {
let end = Date.now();
if (err) {
this._responseCallback(
batch.events.map(ev => ({
// eslint-disable-next-line camelcase
status_code: nextResponse.status,
status_code: ev.encodeError ? undefined : err.status,
duration: end - start,
metadata: ev.metadata,
error: nextResponse.err
};
}
})
);
}
// we resolve unconditionally to continue the iteration in eachSeries. errors will cause
// the event to be re-enqueued/dropped.
resolve();
});
});
error: ev.encodeError || err
}))
);
} else {
let response = JSON.parse(res.text);
let respIdx = 0;
this._responseCallback(
batch.events.map(ev => {
if (ev.encodeError) {
return {
duration: end - start,
metadata: ev.metadata,
error: ev.encodeError
};
} else {
let nextResponse = response[respIdx++];
return {
// eslint-disable-next-line camelcase
status_code: nextResponse.status,
duration: end - start,
metadata: ev.metadata,
error: nextResponse.err
};
}
})
);
}
// we resolve unconditionally to continue the iteration in eachSeries. errors will cause
// the event to be re-enqueued/dropped.
resolve();
});
})
);
})

@@ -528,0 +553,0 @@ .then(finishBatch)

@@ -1,2 +0,1 @@

import proxy from 'superagent-proxy';
import superagent from 'superagent';

@@ -174,3 +173,3 @@ import url from 'url';

const USER_AGENT = "libhoney-js/2.0.1";
const USER_AGENT = "libhoney-js/2.0.2";

@@ -448,75 +447,82 @@ const _global =

let url = urljoin(batch.apiHost, "/1/batch", batch.dataset);
let req = superagent.post(url);
if (this._proxy) {
req = proxy(req, this._proxy);
}
let postReq = superagent.post(url);
const reqPromise = Promise.resolve(
this._proxy
? import('superagent-proxy').then(({ default: proxy }) => ({
req: proxy(postReq, this._proxy)
}))
: { req: postReq }
);
let { encoded, numEncoded } = batchAgg.encodeBatchEvents(batch.events);
return new Promise(resolve => {
// if we failed to encode any of the events, no point in sending anything to honeycomb
if (numEncoded === 0) {
this._responseCallback(
batch.events.map(ev => ({
metadata: ev.metadata,
error: ev.encodeError
}))
);
resolve();
return;
}
let userAgent = USER_AGENT;
let trimmedAddition = this._userAgentAddition.trim();
if (trimmedAddition) {
userAgent = `${USER_AGENT} ${trimmedAddition}`;
}
let start = Date.now();
req
.set("X-Honeycomb-Team", batch.writeKey)
.set("User-Agent", userAgent)
.type("json")
.send(encoded)
.end((err, res) => {
let end = Date.now();
if (err) {
return reqPromise.then(
({ req }) =>
new Promise(resolve => {
// if we failed to encode any of the events, no point in sending anything to honeycomb
if (numEncoded === 0) {
this._responseCallback(
batch.events.map(ev => ({
// eslint-disable-next-line camelcase
status_code: ev.encodeError ? undefined : err.status,
duration: end - start,
metadata: ev.metadata,
error: ev.encodeError || err
error: ev.encodeError
}))
);
} else {
let response = JSON.parse(res.text);
let respIdx = 0;
this._responseCallback(
batch.events.map(ev => {
if (ev.encodeError) {
return {
duration: end - start,
metadata: ev.metadata,
error: ev.encodeError
};
} else {
let nextResponse = response[respIdx++];
return {
resolve();
return;
}
let userAgent = USER_AGENT;
let trimmedAddition = this._userAgentAddition.trim();
if (trimmedAddition) {
userAgent = `${USER_AGENT} ${trimmedAddition}`;
}
let start = Date.now();
req
.set("X-Honeycomb-Team", batch.writeKey)
.set("User-Agent", userAgent)
.type("json")
.send(encoded)
.end((err, res) => {
let end = Date.now();
if (err) {
this._responseCallback(
batch.events.map(ev => ({
// eslint-disable-next-line camelcase
status_code: nextResponse.status,
status_code: ev.encodeError ? undefined : err.status,
duration: end - start,
metadata: ev.metadata,
error: nextResponse.err
};
}
})
);
}
// we resolve unconditionally to continue the iteration in eachSeries. errors will cause
// the event to be re-enqueued/dropped.
resolve();
});
});
error: ev.encodeError || err
}))
);
} else {
let response = JSON.parse(res.text);
let respIdx = 0;
this._responseCallback(
batch.events.map(ev => {
if (ev.encodeError) {
return {
duration: end - start,
metadata: ev.metadata,
error: ev.encodeError
};
} else {
let nextResponse = response[respIdx++];
return {
// eslint-disable-next-line camelcase
status_code: nextResponse.status,
duration: end - start,
metadata: ev.metadata,
error: nextResponse.err
};
}
})
);
}
// we resolve unconditionally to continue the iteration in eachSeries. errors will cause
// the event to be re-enqueued/dropped.
resolve();
});
})
);
})

@@ -523,0 +529,0 @@ .then(finishBatch)

{
"name": "libhoney",
"version": "2.0.1",
"version": "2.0.2",
"description": " Honeycomb.io Javascript library",

@@ -54,2 +54,3 @@ "bugs": "https://github.com/honeycombio/libhoney-js/issues",

"dependencies": {
"babel-eslint": "^10.0.3",
"superagent": "^3.8.3",

@@ -56,0 +57,0 @@ "superagent-proxy": "^2.0.0",

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