New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mixpanel

Package Overview
Dependencies
Maintainers
9
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixpanel - npm Package Compare versions

Comparing version 0.9.2 to 0.10.0

10

lib/mixpanel-node.js

@@ -64,3 +64,3 @@ /*

var content = (new Buffer(JSON.stringify(options.data))).toString('base64'),
var content = Buffer.from(JSON.stringify(options.data)).toString('base64'),
endpoint = options.endpoint,

@@ -632,6 +632,6 @@ method = (options.method || 'GET').toUpperCase(),

// append a value to a list, creating it if needed
mixpanel.people.append('pages_visited', 'homepage');
mixpanel.people.append('bob', 'pages_visited', 'homepage');
// like mixpanel.people.set(), you can append multiple properties at once:
mixpanel.people.append({
mixpanel.people.append('bob', {
list1: 'bob',

@@ -804,3 +804,3 @@ list2: 123

mixpanel.people.union('bob', {'browsers', ['chrome'], os: ['linux']});
mixpanel.people.union('bob', {'browsers': ['chrome'], os: ['linux']});
*/

@@ -812,3 +812,3 @@ union: function(distinct_id, data, modifiers, callback) {

if (metrics.config.debug) {
console.error("Invalid value passed to mixpanel.people.union - data must be an object with array values");
console.error("Invalid value passed to mixpanel.people.union - data must be an object with scalar or array values");
}

@@ -815,0 +815,0 @@ return;

@@ -10,3 +10,3 @@ {

],
"version": "0.9.2",
"version": "0.10.0",
"homepage": "https://github.com/mixpanel/mixpanel-node",

@@ -24,3 +24,3 @@ "author": "Carl Sverre",

"engines": {
"node": ">=4.2"
"node": ">=6.9"
},

@@ -34,3 +34,3 @@ "scripts": {

"proxyquire": "^1.7.11",
"sinon": "^1.14.1"
"sinon": "^7.1.1"
},

@@ -37,0 +37,0 @@ "dependencies": {

var proxyquire = require('proxyquire'),
Sinon = require('sinon'),
http = require('http'),
https = require('https'),
events = require('events'),

@@ -222,18 +222,16 @@ Mixpanel = require('../lib/mixpanel-node');

Sinon.stub(http, 'request');
Sinon.stub(https, 'request');
this.http_emitter = new events.EventEmitter();
// stub sequence of http responses
// stub sequence of https responses
this.res = [];
for (var ri = 0; ri < 5; ri++) {
this.res.push(new events.EventEmitter());
http.request
.onCall(ri)
.callsArgWith(1, this.res[ri])
.returns({
write: function () {},
end: function () {},
on: function(event) {}
});
https.request.onCall(ri).callsArgWith(1, this.res[ri]);
https.request.onCall(ri).returns({
write: function () {},
end: function () {},
on: function(event) {},
});
}

@@ -250,3 +248,3 @@

tearDown: function(next) {
http.request.restore();
https.request.restore();
this.clock.restore();

@@ -261,3 +259,3 @@

test.equals(
3, http.request.callCount,
3, https.request.callCount,
"import_batch didn't call send_request correct number of times before callback"

@@ -296,3 +294,3 @@ );

test.equals(
3, http.request.callCount,
3, https.request.callCount,
"import_batch didn't call send_request correct number of times before callback"

@@ -316,3 +314,3 @@ );

test.equals(
5, http.request.callCount, // 30 + 30 + 30 + 30 + 10
5, https.request.callCount, // 30 + 30 + 30 + 30 + 10
"import_batch didn't call send_request correct number of times before callback"

@@ -348,3 +346,3 @@ );

3, async_all_stub.callCount,
"import_batch didn't batch concurrent http requests correctly"
"import_batch didn't batch concurrent https requests correctly"
);

@@ -367,3 +365,3 @@ test.equals(

test.equals(
3, http.request.callCount,
3, https.request.callCount,
"import_batch didn't call send_request correct number of times"

@@ -373,3 +371,3 @@ );

test.equals(
5, http.request.callCount, // 3 + 100 / 50; last request starts async
5, https.request.callCount, // 3 + 100 / 50; last request starts async
"import_batch didn't call send_request correct number of times"

@@ -376,0 +374,0 @@ );

var Mixpanel,
Sinon = require('sinon'),
proxyquire = require('proxyquire'),
http = require('http'),
https = require('https'),
events = require('events'),

@@ -12,4 +12,9 @@ httpProxyOrig = process.env.HTTP_PROXY,

setUp: function(next) {
Sinon.stub(http, 'request');
HttpsProxyAgent = Sinon.stub();
Mixpanel = proxyquire('../lib/mixpanel-node', {
'https-proxy-agent': HttpsProxyAgent
});
Sinon.stub(https, 'request');
this.http_emitter = new events.EventEmitter;

@@ -21,11 +26,5 @@ this.http_end_spy = Sinon.spy();

this.res = new events.EventEmitter;
http.request.returns(this.http_emitter);
http.request.callsArgWith(1, this.res);
https.request.returns(this.http_emitter);
https.request.callsArgWith(1, this.res);
HttpsProxyAgent = Sinon.stub();
Mixpanel = proxyquire('../lib/mixpanel-node', {
'https-proxy-agent': HttpsProxyAgent
});
this.mixpanel = Mixpanel.init('token');

@@ -37,3 +36,3 @@

tearDown: function(next) {
http.request.restore();
https.request.restore();

@@ -67,4 +66,4 @@ // restore proxy variables

test.expect(3);
test.ok(http.request.calledWithMatch(expected_http_request), "send_request didn't call http.request with correct arguments");
test.ok(this.http_end_spy.callCount === 1, "send_request didn't end http.request");
test.ok(https.request.calledWithMatch(expected_http_request), "send_request didn't call https.request with correct arguments");
test.ok(this.http_end_spy.callCount === 1, "send_request didn't end https.request");
test.ok(this.http_write_spy.callCount === 0, "send_request called write for a GET");

@@ -94,3 +93,3 @@

test.ok(http.request.calledWithMatch(expected_http_request), "send_request didn't call http.request with correct method argument");
test.ok(https.request.calledWithMatch(expected_http_request), "send_request didn't call https.request with correct method argument");

@@ -121,4 +120,4 @@ test.done();

test.expect(3);
test.ok(http.request.calledWithMatch(expected_http_request), "send_request didn't call http.request with correct arguments");
test.ok(this.http_end_spy.callCount === 1, "send_request didn't end http.request");
test.ok(https.request.calledWithMatch(expected_http_request), "send_request didn't call https.request with correct arguments");
test.ok(this.http_end_spy.callCount === 1, "send_request didn't end https.request");
test.ok(this.http_write_spy.calledWithExactly(expected_http_request_body), "send_request did not write data correctly for a POST");

@@ -140,3 +139,3 @@

"handles http.request errors": function(test) {
"handles https.request errors": function(test) {
test.expect(1);

@@ -160,3 +159,3 @@ this.mixpanel.send_request({ endpoint: "/track", data: { event: "test" } }, function(e) {

test.ok(http.request.calledWithMatch(expected_http_request), "send_request didn't call http.request with correct hostname");
test.ok(https.request.calledWithMatch(expected_http_request), "send_request didn't call https.request with correct hostname");

@@ -176,3 +175,3 @@ test.done();

test.ok(http.request.calledWithMatch(expected_http_request), "send_request didn't call http.request with correct hostname and port");
test.ok(https.request.calledWithMatch(expected_http_request), "send_request didn't call https.request with correct hostname and port");

@@ -185,3 +184,3 @@ test.done();

delete process.env.HTTPS_PROXY;
process.env.HTTP_PROXY = 'this.aint.real.http';
process.env.HTTP_PROXY = 'this.aint.real.https';

@@ -194,6 +193,6 @@ var proxyMixpanel = Mixpanel.init('token');

var proxyPath = HttpsProxyAgent.firstCall.args[0];
test.ok(proxyPath === 'this.aint.real.http', "HttpsProxyAgent was not called with the correct proxy path");
test.ok(proxyPath === 'this.aint.real.https', "HttpsProxyAgent was not called with the correct proxy path");
var getConfig = http.request.firstCall.args[0];
test.ok(getConfig.agent !== undefined, "send_request didn't call http.request with agent");
var getConfig = https.request.firstCall.args[0];
test.ok(getConfig.agent !== undefined, "send_request didn't call https.request with agent");

@@ -216,4 +215,4 @@ test.done();

var getConfig = http.request.firstCall.args[0];
test.ok(getConfig.agent !== undefined, "send_request didn't call http.request with agent");
var getConfig = https.request.firstCall.args[0];
test.ok(getConfig.agent !== undefined, "send_request didn't call https.request with agent");

@@ -220,0 +219,0 @@ test.done();

var proxyquire = require('proxyquire'),
Sinon = require('sinon'),
http = require('http'),
https = require('https'),
events = require('events'),

@@ -237,18 +237,16 @@ Mixpanel = require('../lib/mixpanel-node');

Sinon.stub(http, 'request');
Sinon.stub(https, 'request');
this.http_emitter = new events.EventEmitter();
// stub sequence of http responses
// stub sequence of https responses
this.res = [];
for (var ri = 0; ri < 5; ri++) {
this.res.push(new events.EventEmitter());
http.request
.onCall(ri)
.callsArgWith(1, this.res[ri])
.returns({
write: function () {},
end: function () {},
on: function(event) {}
});
https.request.onCall(ri).callsArgWith(1, this.res[ri]);
https.request.onCall(ri).returns({
write: function () {},
end: function () {},
on: function(event) {}
});
}

@@ -265,3 +263,3 @@

tearDown: function(next) {
http.request.restore();
https.request.restore();
this.clock.restore();

@@ -276,3 +274,3 @@

test.equals(
3, http.request.callCount,
3, https.request.callCount,
"track_batch didn't call send_request correct number of times before callback"

@@ -311,3 +309,3 @@ );

test.equals(
3, http.request.callCount,
3, https.request.callCount,
"track_batch didn't call send_request correct number of times before callback"

@@ -331,3 +329,3 @@ );

test.equals(
5, http.request.callCount, // 30 + 30 + 30 + 30 + 10
5, https.request.callCount, // 30 + 30 + 30 + 30 + 10
"track_batch didn't call send_request correct number of times before callback"

@@ -363,3 +361,3 @@ );

3, async_all_stub.callCount,
"track_batch didn't batch concurrent http requests correctly"
"track_batch didn't batch concurrent https requests correctly"
);

@@ -382,3 +380,3 @@ test.equals(

test.equals(
3, http.request.callCount,
3, https.request.callCount,
"track_batch didn't call send_request correct number of times"

@@ -388,3 +386,3 @@ );

test.equals(
5, http.request.callCount, // 3 + 100 / 50; last request starts async
5, https.request.callCount, // 3 + 100 / 50; last request starts async
"track_batch didn't call send_request correct number of times"

@@ -391,0 +389,0 @@ );

Sorry, the diff of this file is not supported yet

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