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

mixpanel

Package Overview
Dependencies
Maintainers
7
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.12.0 to 0.13.0

2

example.js

@@ -72,3 +72,3 @@ // grab the Mixpanel factory

var mixpanel_importer = Mixpanel.init('valid mixpanel token', {
key: "valid api key for project"
secret: "valid api secret for project"
});

@@ -75,0 +75,0 @@ mixpanel_importer.set_config({ debug: true });

@@ -0,1 +1,5 @@

0.13.0 / 2020-09-04
==================
* support API Secret auth for imports and deprecate use of API Key
0.12.0 / 2020-08-31

@@ -2,0 +6,0 @@ ==================

@@ -113,24 +113,24 @@ declare const mixpanel: mixpanel.Mixpanel;

interface Groups {
set(groupKey: string, groupId: string, properties: PropertyDict, callback?: Callback): void;
set(groupKey: string, groupId: string, properties: PropertyDict, modifiers?: Modifiers, callback?: Callback): void;
set(groupKey: string, groupId: string, propertyName: string, value: string | number, modifiers: Modifiers): void;
set(groupKey: string, groupId: string, propertyName: string, value: string | number, callback?: Callback): void;
set(groupKey: string, groupId: string, propertyName: string, value: string | number, modifiers: Modifiers, callback: Callback): void;
set(groupKey: string, groupId: string, properties: PropertyDict, callback?: Callback): void;
set(groupKey: string, groupId: string, properties: PropertyDict, modifiers?: Modifiers, callback?: Callback): void;
set(groupKey: string, groupId: string, propertyName: string, value: string | number, modifiers: Modifiers): void;
set(groupKey: string, groupId: string, propertyName: string, value: string | number, callback?: Callback): void;
set(groupKey: string, groupId: string, propertyName: string, value: string | number, modifiers: Modifiers, callback: Callback): void;
unset(groupKey: string, groupId: string, propertyName: string | string[], callback?: Callback): void;
unset(groupKey: string, groupId: string, propertyName: string | string[], modifiers?: Modifiers, callback?: Callback): void;
unset(groupKey: string, groupId: string, propertyName: string | string[], callback?: Callback): void;
unset(groupKey: string, groupId: string, propertyName: string | string[], modifiers?: Modifiers, callback?: Callback): void;
set_once(groupKey: string, groupId: string, propertyName: string, value: string, callback?: Callback): void;
set_once( groupKey: string, groupId: string, propertyName: string, value: string, modifiers: Modifiers, callback?: Callback): void;
set_once(groupKey: string, groupId: string, properties: PropertyDict, callback?: Callback): void;
set_once(groupKey: string, groupId: string, properties: PropertyDict, modifiers?: Modifiers, callback?: Callback): void;
set_once(groupKey: string, groupId: string, propertyName: string, value: string, callback?: Callback): void;
set_once( groupKey: string, groupId: string, propertyName: string, value: string, modifiers: Modifiers, callback?: Callback): void;
set_once(groupKey: string, groupId: string, properties: PropertyDict, callback?: Callback): void;
set_once(groupKey: string, groupId: string, properties: PropertyDict, modifiers?: Modifiers, callback?: Callback): void;
union(groupKey: string, groupId: string, data: UnionData, modifiers?: Modifiers, callback?: Callback): void;
union(groupKey: string, groupId: string, data: UnionData, callback: Callback): void;
union(groupKey: string, groupId: string, data: UnionData, modifiers?: Modifiers, callback?: Callback): void;
union(groupKey: string, groupId: string, data: UnionData, callback: Callback): void;
remove(groupKey: string, groupId: string, data: RemoveData, modifiers?: Modifiers, callback?: Callback): void;
remove(groupKey: string, groupId: string, data: RemoveData, callback: Callback): void;
remove(groupKey: string, groupId: string, data: RemoveData, modifiers?: Modifiers, callback?: Callback): void;
remove(groupKey: string, groupId: string, data: RemoveData, callback: Callback): void;
delete_group(groupKey: string, groupId: string, modifiers?: Modifiers, callback?: Callback): void;
delete_group(groupKey: string, groupId: string, callback: Callback): void;
delete_group(groupKey: string, groupId: string, modifiers?: Modifiers, callback?: Callback): void;
delete_group(groupKey: string, groupId: string, callback: Callback): void;
}

@@ -137,0 +137,0 @@ }

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

const key = metrics.config.key;
const secret = metrics.config.secret;
const request_lib = REQUEST_LIBS[metrics.config.protocol];

@@ -93,7 +94,13 @@ let request_options = {

// add `key` query params
if (key) {
// add auth params
if (secret) {
if (request_lib !== https) {
throw new Error("Must use HTTPS if authenticating with API Secret");
}
const encoded = Buffer.from(secret + ':').toString('base64');
request_options.headers['Authorization'] = 'Basic ' + encoded;
} else if (key) {
query_params.api_key = key;
} else if (endpoint === '/import') {
throw new Error("The Mixpanel Client needs a Mixpanel api key when importing old events: `init(token, { key: ... })`");
throw new Error("The Mixpanel Client needs a Mixpanel API Secret when importing old events: `init(token, { secret: ... })`");
}

@@ -100,0 +107,0 @@

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

],
"version": "0.12.0",
"version": "0.13.0",
"homepage": "https://github.com/mixpanel/mixpanel-node",

@@ -13,0 +13,0 @@ "author": "Carl Sverre",

@@ -141,3 +141,3 @@ Mixpanel-node

var mixpanel_importer = Mixpanel.init('valid mixpanel token', {
key: 'valid api key for project'
secret: 'valid api secret for project'
});

@@ -144,0 +144,0 @@

@@ -12,3 +12,3 @@ var proxyquire = require('proxyquire'),

setUp: function(next) {
this.mixpanel = Mixpanel.init('token', { key: 'key' });
this.mixpanel = Mixpanel.init('token', { secret: 'my api secret' });
this.clock = Sinon.useFakeTimers(mock_now_time);

@@ -144,3 +144,3 @@

setUp: function(next) {
this.mixpanel = Mixpanel.init('token', { key: 'key' });
this.mixpanel = Mixpanel.init('token', { secret: 'my api secret' });
this.clock = Sinon.useFakeTimers();

@@ -221,3 +221,3 @@

setUp: function(next) {
this.mixpanel = Mixpanel.init('token', { key: 'key' });
this.mixpanel = Mixpanel.init('token', { secret: 'my api secret' });
this.clock = Sinon.useFakeTimers();

@@ -334,3 +334,3 @@

async_all_stub.callsArgWith(2, null);
this.mixpanel = PatchedMixpanel.init('token', { key: 'key' });
this.mixpanel = PatchedMixpanel.init('token', { secret: 'my api secret' });

@@ -337,0 +337,0 @@ test.expect(2);

@@ -244,3 +244,43 @@ let Mixpanel;

test.done();
}
},
"requires credentials for import requests": function(test) {
test.throws(
this.mixpanel.send_request.bind(this, {
endpoint: `/import`,
data: {event: `test event`},
}),
/The Mixpanel Client needs a Mixpanel API Secret when importing old events/,
"import request didn't throw error when no credentials provided"
);
test.done();
},
"sets basic auth header if API secret is provided": function(test) {
this.mixpanel.set_config({secret: `foobar`});
this.mixpanel.send_request({
endpoint: `/import`,
data: {event: `test event`},
});
test.ok(https.request.calledOnce);
test.deepEqual(https.request.args[0][0].headers, {
'Authorization': `Basic Zm9vYmFyOg==`, // base64 of "foobar:"
}, "send_request didn't pass correct auth header to https.request");
test.done();
},
"still supports import with api_key (legacy)": function(test) {
this.mixpanel.set_config({key: `barbaz`});
this.mixpanel.send_request({
endpoint: `/import`,
data: {},
});
test.ok(https.request.calledOnce);
test.equal(
https.request.args[0][0].path,
`/import?ip=0&verbose=0&data=e30%3D&api_key=barbaz`,
"send_request didn't pass correct query params to https.request"
);
test.done();
},
};
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