Socket
Socket
Sign inDemoInstall

analytics-node

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-node - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

5

History.md

@@ -0,1 +1,6 @@

1.l.0 - 2014-08-22
==================
* add: proxy requests
1.0.4 - 2014-08-14

@@ -2,0 +7,0 @@ ==================

15

lib/index.js

@@ -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)

6

package.json
{
"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']);

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