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

volos-analytics-apigee

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volos-analytics-apigee - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

45

lib/apigeeanalytics.js

@@ -52,2 +52,3 @@ /****************************************************************************

this.proxy = options.proxy;
this.compress = !!options.compress;
if (options.proxy_revision) { this.proxy_revision = options.proxy_revision; }

@@ -78,2 +79,3 @@

ApigeeAnalyticsSpi.prototype.flush = function(recordsQueue, cb) {
var recordsToBeUploaded = {

@@ -83,19 +85,21 @@ records: recordsQueue

var req = superagent.post(this.uri);
function sendResponse(err, resp) {
if (err || resp.statusCode != 200) {
cb(err || new Error('error from server: ' + resp.statusCode), recordsToBeUploaded);
} else {
resp.body.rejected > 0 ? cb(undefined, recordsQueue.slice(recordsQueue.length - resp.body.rejected)) : cb();
}
}
if (this.microgateway) {
req.auth(this.key, this.secret);
if (this.compress) {
var zlib = require('zlib');
var uncompressed = JSON.stringify(recordsToBeUploaded);
var self = this;
zlib.gzip(uncompressed, function(err, compressed) {
self.send(compressed, sendResponse);
});
} else {
req.set('x-DNA-Api-Key', this.key);
this.send(recordsToBeUploaded, sendResponse);
}
req
.send(recordsToBeUploaded)
.end(function(err, resp) {
if (err || resp.statusCode != 200) {
cb(err || new Error('error from server: ' + resp.statusCode), recordsToBeUploaded);
} else {
resp.body.rejected > 0 ? cb(undefined, recordsQueue.slice(recordsQueue.length - resp.body.rejected)) : cb();
}
});
};

@@ -125,1 +129,16 @@

};
ApigeeAnalyticsSpi.prototype.send = function send(data, cb) {
var req = superagent.post(this.uri);
if (this.microgateway) {
req.auth(this.key, this.secret);
} else {
req.set('x-DNA-Api-Key', this.key);
}
req
.send(data)
.end(cb);
};
{
"name": "volos-analytics-apigee",
"version": "0.3.2",
"version": "0.3.3",
"main": "lib/apigeeanalytics.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -111,3 +111,3 @@ /****************************************************************************

should.not.exist(err);
if(retryRecords) {
if (retryRecords) {
assert(retryRecords.length <= recordsQueue.length);

@@ -118,2 +118,25 @@ }

});
it('should compress before sending if so configured', function(done) {
var options = extend(config, {
recordLimit: 10000,
proxy: 'testAnalytics',
flushInterval: 100,
uploadLength : 100,
compress: true
});
var analytics = Spi.create(options);
var recordsQueue = [record, record, record];
analytics.spi.send = function send(compressed) {
var zlib = require('zlib');
zlib.gunzip(compressed, function(err, uncompressed) {
var data = JSON.parse(uncompressed);
recordsQueue.should.eql(data.records);
done();
});
};
analytics.spi.flush(recordsQueue);
});

@@ -120,0 +143,0 @@ describe('Common', function() {

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