Comparing version 2.0.1 to 2.0.2
@@ -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", |
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
96467
2404
4
+ Addedbabel-eslint@^10.0.3
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/generator@7.26.2(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.25.9(transitive)
+ Added@babel/types@7.26.0(transitive)
+ Added@eslint-community/eslint-utils@4.4.1(transitive)
+ Added@eslint-community/regexpp@4.12.1(transitive)
+ Added@eslint/config-array@0.18.0(transitive)
+ Added@eslint/core@0.7.0(transitive)
+ Added@eslint/eslintrc@3.1.0(transitive)
+ Added@eslint/js@9.14.0(transitive)
+ Added@eslint/object-schema@2.1.4(transitive)
+ Added@eslint/plugin-kit@0.2.2(transitive)
+ Added@humanfs/core@0.19.1(transitive)
+ Added@humanfs/node@0.16.6(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/retry@0.3.10.4.1(transitive)
+ Added@jridgewell/gen-mapping@0.3.5(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/json-schema@7.0.15(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedbabel-eslint@10.1.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcross-spawn@7.0.5(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedeslint@9.14.0(transitive)
+ Addedeslint-scope@8.2.0(transitive)
+ Addedeslint-visitor-keys@1.3.03.4.34.2.0(transitive)
+ Addedespree@10.3.0(transitive)
+ Addedesquery@1.6.0(transitive)
+ Addedesrecurse@4.3.0(transitive)
+ Addedestraverse@5.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfile-entry-cache@8.0.0(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedflat-cache@4.0.1(transitive)
+ Addedflatted@3.3.1(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedglobals@11.12.014.0.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjsesc@3.0.2(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stable-stringify-without-jsonify@1.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlevn@0.4.1(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addednatural-compare@1.4.0(transitive)
+ Addedoptionator@0.9.4(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedprelude-ls@1.2.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtext-table@0.2.0(transitive)
+ Addedtype-check@0.4.0(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedyocto-queue@0.1.0(transitive)