analytics-node
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -0,1 +1,6 @@ | ||
1.l.0 - 2014-08-22 | ||
================== | ||
* add: proxy requests | ||
1.0.4 - 2014-08-14 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -7,2 +7,4 @@ | ||
var request = require('superagent'); | ||
// extend with Request#proxy() | ||
require('superagent-proxy')(request); | ||
var type = require('component-type'); | ||
@@ -31,2 +33,3 @@ var join = require('join-component'); | ||
* @property {String} host (default: 'https://api.segment.io') | ||
* @property {String|Object} proxy (default: null) | ||
*/ | ||
@@ -43,2 +46,3 @@ | ||
this.flushAfter = options.flushAfter || 10000; | ||
this.proxy = options.proxy || null; | ||
} | ||
@@ -146,4 +150,11 @@ | ||
debug('flush: %o', data); | ||
request | ||
.post(this.host + '/v1/batch') | ||
var req = request | ||
.post(this.host + '/v1/batch'); | ||
if (this.proxy) { | ||
req = req.proxy(this.proxy); | ||
} | ||
req | ||
.auth(this.writeKey, '') | ||
@@ -150,0 +161,0 @@ .send(data) |
{ | ||
"name": "analytics-node", | ||
"repository": "git://github.com/segmentio/analytics-node", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "The hassle-free way to integrate analytics into any node application.", | ||
@@ -21,2 +21,3 @@ "keywords": [ | ||
"superagent": "~0.16.0", | ||
"superagent-proxy": "~0.3.1", | ||
"debug": "~1.0.4", | ||
@@ -27,3 +28,4 @@ "uid": "0.0.2" | ||
"mocha": "1.8.1", | ||
"express": "~3.4.8" | ||
"express": "~3.4.8", | ||
"http-proxy": "~1.3.0" | ||
}, | ||
@@ -30,0 +32,0 @@ "engines": { |
var express = require('express'); | ||
var port = 4063; | ||
var ports = { source: 4063, proxy: 4064 }; | ||
var httpProxy = require('http-proxy'); | ||
var http = require('http'); | ||
var debug = require('debug')('analytics-node:server') | ||
/** | ||
* Proxy. | ||
*/ | ||
var proxy = httpProxy.createProxyServer(); | ||
http.createServer(function(req, res) { | ||
proxy.web(req, res, { target: 'http://localhost:' + ports.source }); | ||
}).listen(ports.proxy, function(){ | ||
console.log(); | ||
console.log(' Testing proxy listening on port ' + ports.proxy + '...'); | ||
console.log(); | ||
}); | ||
proxy.on('proxyRes', function (proxyRes, req, res) { | ||
proxyRes.statusCode = 408; | ||
}); | ||
/** | ||
* App. | ||
@@ -13,5 +34,5 @@ */ | ||
.post('/v1/batch', fixture) | ||
.listen(port, function(){ | ||
.listen(ports.source, function(){ | ||
console.log(); | ||
console.log(' Testing server listening on port ' + port + '...'); | ||
console.log(' Testing server listening on port ' + ports.source + '...'); | ||
console.log(); | ||
@@ -18,0 +39,0 @@ }); |
@@ -51,3 +51,4 @@ | ||
flushAt: 1, | ||
flushAfter: 2 | ||
flushAfter: 2, | ||
proxy: 'http://localhost:9001' | ||
}); | ||
@@ -57,2 +58,3 @@ assert.equal(a.host, 'a'); | ||
assert.equal(a.flushAfter, 2); | ||
assert.equal(a.proxy, 'http://localhost:9001'); | ||
}); | ||
@@ -138,2 +140,17 @@ | ||
it('should proxy', function(done) { | ||
a = Analytics('key', { | ||
host: 'http://localhost:4063', | ||
flushAt: Infinity, | ||
flushAfter: Infinity, | ||
proxy: 'http://localhost:4064' | ||
}); | ||
a.enqueue('type', { event: 'test' }, noop); | ||
a.flush(function(err, data){ | ||
// our proxy turns all responses into 408/errs | ||
assert(err); | ||
done(); | ||
}); | ||
}); | ||
it('should callback with an HTTP error', function(done){ | ||
@@ -140,0 +157,0 @@ enqueue(a, ['error']); |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19559
556
8
3
3
+ Addedsuperagent-proxy@~0.3.1
+ Addedacorn@5.7.4(transitive)
+ Addedagent-base@1.0.2(transitive)
+ Addedalign-text@0.1.4(transitive)
+ Addedalter@0.2.0(transitive)
+ Addedast-traverse@0.1.1(transitive)
+ Addedast-types@0.16.10.8.120.9.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbreakable@1.0.0(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addedcenter-align@0.1.3(transitive)
+ Addedcliui@2.1.0(transitive)
+ Addedco@3.0.6(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommoner@0.10.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddata-uri-to-buffer@0.0.4(transitive)
+ Addeddebug@2.2.02.6.9(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addeddefined@1.0.1(transitive)
+ Addeddefs@1.1.1(transitive)
+ Addeddegenerator@1.0.4(transitive)
+ Addeddetective@4.7.1(transitive)
+ Addedescodegen@1.14.3(transitive)
+ Addedesprima@3.1.34.0.1(transitive)
+ Addedesprima-fb@15001.1001.0-dev-harmony-fb(transitive)
+ Addedestraverse@4.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedextend@1.2.13.0.2(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedfile-uri-to-path@0.0.2(transitive)
+ Addedftp@0.3.10(transitive)
+ Addedget-uri@0.1.4(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhttp-proxy-agent@0.2.7(transitive)
+ Addedhttps-proxy-agent@0.3.6(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedinvert-kv@1.0.0(transitive)
+ Addedip@1.1.9(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedlcid@1.0.0(transitive)
+ Addedlevn@0.3.0(transitive)
+ Addedlongest@1.0.1(transitive)
+ Addedlru-cache@2.5.2(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@0.7.1(transitive)
+ Addednetmask@1.0.6(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptionator@0.8.3(transitive)
+ Addedos-locale@1.4.0(transitive)
+ Addedpac-proxy-agent@0.2.0(transitive)
+ Addedpac-resolver@1.2.6(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedproxy-agent@1.1.1(transitive)
+ Addedq@1.5.1(transitive)
+ Addedreadable-stream@1.1.142.3.8(transitive)
+ Addedrecast@0.10.330.11.23(transitive)
+ Addedregenerator@0.8.46(transitive)
+ Addedregenerator-runtime@0.9.6(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedright-align@0.1.3(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsimple-fmt@0.1.0(transitive)
+ Addedsimple-is@0.2.0(transitive)
+ Addedsmart-buffer@1.1.15(transitive)
+ Addedsocks@1.1.10(transitive)
+ Addedsocks-proxy-agent@1.0.2(transitive)
+ Addedsource-map@0.5.70.6.1(transitive)
+ Addedstable@0.1.8(transitive)
+ Addedstream-to-array@1.0.0(transitive)
+ Addedstring_decoder@0.10.311.1.1(transitive)
+ Addedstringmap@0.2.2(transitive)
+ Addedstringset@0.2.1(transitive)
+ Addedsuperagent-proxy@0.3.2(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedthunkify@2.1.2(transitive)
+ Addedtryor@0.1.2(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwindow-size@0.1.4(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedwordwrap@0.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxregexp@2.0.0(transitive)
+ Addedy18n@3.2.2(transitive)
+ Addedyargs@3.27.0(transitive)