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

mixpanel

Package Overview
Dependencies
Maintainers
6
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.17.0 to 0.18.0

4

history.md

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

0.18.0 / 2023-09-12
==================
* custom logger support (thanks iatsiuk)
0.17.0 / 2022-08-11

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

@@ -9,4 +9,20 @@ declare const mixpanel: mixpanel.Mixpanel;

export interface CustomLogger {
trace(message?: any, ...optionalParams: any[]): void;
debug(message?: any, ...optionalParams: any[]): void;
info(message?: any, ...optionalParams: any[]): void;
warn(message?: any, ...optionalParams: any[]): void;
error(message?: any, ...optionalParams: any[]): void;
}
export interface InitConfig {
[key: string]: any;
test: boolean;
debug: boolean;
verbose: boolean;
host: string;
protocol: string;
path: string;
keepAlive: boolean;
geolocate: boolean;
logger: CustomLogger;
}

@@ -49,3 +65,3 @@

interface Mixpanel {
init(mixpanelToken: string, config?: InitConfig): Mixpanel;
init(mixpanelToken: string, config?: Partial<InitConfig>): Mixpanel;

@@ -52,0 +68,0 @@ track(eventName: string, callback?: Callback): void;

18

lib/mixpanel-node.js

@@ -18,3 +18,3 @@ /*

const {async_all, ensure_timestamp} = require('./utils');
const {async_all, ensure_timestamp, assert_logger} = require('./utils');
const {MixpanelGroups} = require('./groups');

@@ -34,2 +34,3 @@ const {MixpanelPeople} = require('./people');

geolocate: false,
logger: console,
};

@@ -157,3 +158,3 @@

if (metrics.config.debug) {
console.log("Got Error: " + e.message);
metrics.config.logger.error("Got Error: " + e.message);
}

@@ -187,3 +188,3 @@ callback(e);

if (metrics.config.debug) {
console.log("Sending the following event to Mixpanel:\n", data);
metrics.config.logger.debug("Sending the following event to Mixpanel", { data });
}

@@ -276,3 +277,3 @@

if (metrics.config.debug) {
console.log(
metrics.config.logger.debug(
"Sending " + event_list.length + " events to Mixpanel in " +

@@ -454,2 +455,5 @@ total_event_batches + " batches of events and " +

metrics.set_config = function(config) {
if (config && config.logger !== undefined) {
assert_logger(config.logger);
}
Object.assign(metrics.config, config);

@@ -475,7 +479,3 @@ if (config.host) {

module.exports = {
Client: function(token) {
console.warn("The function `Client(token)` is deprecated. It is now called `init(token)`.");
return create_client(token);
},
init: create_client
init: create_client,
};

@@ -84,4 +84,6 @@ const {merge_modifiers, ProfileHelpers} = require('./profile_helpers');

if (this.mixpanel.config.debug) {
console.error("Invalid increment value passed to mixpanel.people.increment - must be a number");
console.error("Passed " + key + ":" + val);
this.mixpanel.config.logger.error(
"Invalid increment value passed to mixpanel.people.increment - must be a number",
{key, value: val}
);
}

@@ -118,4 +120,3 @@ } else {

if (this.mixpanel.config.debug) {
console.log("Sending the following data to Mixpanel (Engage):");
console.log(data);
this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
}

@@ -173,4 +174,3 @@

if (this.mixpanel.config.debug) {
console.log("Sending the following data to Mixpanel (Engage):");
console.log(data);
this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
}

@@ -215,3 +215,3 @@

if (isNaN(amount)) {
console.error("Invalid value passed to mixpanel.people.track_charge - must be a number");
this.mixpanel.config.logger.error("Invalid value passed to mixpanel.people.track_charge - must be a number");
return;

@@ -239,4 +239,3 @@ }

if (this.mixpanel.config.debug) {
console.log("Sending the following data to Mixpanel (Engage):");
console.log(data);
this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
}

@@ -268,3 +267,3 @@

if (this.mixpanel.config.debug) {
console.log("Clearing this user's charges:", distinct_id);
this.mixpanel.config.logger.debug("Clearing this user's charges", { '$distinct_id': distinct_id });
}

@@ -271,0 +270,0 @@

@@ -79,4 +79,3 @@ /**

if (this.config.debug) {
console.log(`Sending the following data to Mixpanel (${this.endpoint}):`);
console.log(data);
this.mixpanel.config.logger.debug(`Sending the following data to Mixpanel (${this.endpoint})`, { data });
}

@@ -99,3 +98,3 @@

if (this.config.debug) {
console.log(`Deleting profile ${JSON.stringify(identifiers)}`);
this.mixpanel.config.logger.debug('Deleting profile', { identifiers });
}

@@ -111,3 +110,3 @@

if (this.config.debug) {
console.error("Invalid value passed to #remove - data must be an object with scalar values");
this.mixpanel.config.logger.error("Invalid value passed to #remove - data must be an object with scalar values");
}

@@ -122,4 +121,6 @@ return;

if (this.config.debug) {
console.error("Invalid argument passed to #remove - values must be scalar");
console.error("Passed " + key + ':', val);
this.mixpanel.config.logger.error(
"Invalid argument passed to #remove - values must be scalar",
{ key, value: val }
);
}

@@ -147,4 +148,6 @@ return;

if (this.config.debug) {
console.log(`Sending the following data to Mixpanel (${this.endpoint}):`);
console.log(data);
this.mixpanel.config.logger.debug(
`Sending the following data to Mixpanel (${this.endpoint})`,
{ data }
);
}

@@ -160,3 +163,3 @@

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

@@ -178,4 +181,6 @@ return;

if (this.config.debug) {
console.error("Invalid argument passed to #union - values must be a scalar value or array");
console.error("Passed " + key + ':', val);
this.mixpanel.config.logger.error(
"Invalid argument passed to #union - values must be a scalar value or array",
{ key, value: val }
);
}

@@ -202,4 +207,6 @@ }

if (this.config.debug) {
console.log(`Sending the following data to Mixpanel (${this.endpoint}):`);
console.log(data);
this.mixpanel.config.logger.debug(
`Sending the following data to Mixpanel (${this.endpoint})`,
{ data }
);
}

@@ -219,4 +226,6 @@

if (this.config.debug) {
console.error("Invalid argument passed to #unset - must be a string or array");
console.error("Passed: " + prop);
this.mixpanel.config.logger.error(
"Invalid argument passed to #unset - must be a string or array",
{ prop }
);
}

@@ -239,4 +248,6 @@ return;

if (this.config.debug) {
console.log(`Sending the following data to Mixpanel (${this.endpoint}):`);
console.log(data);
this.mixpanel.config.logger.debug(
`Sending the following data to Mixpanel (${this.endpoint})`,
{ data }
);
}

@@ -243,0 +254,0 @@

@@ -44,1 +44,19 @@ /**

};
/**
* Asserts that the provided logger object is valid
* @param {CustomLogger} logger - The logger object to be validated
* @throws {TypeError} If the logger object is not a valid Logger object or
* if it is missing any of the required methods
*/
exports.assert_logger = function(logger) {
if (typeof logger !== 'object') {
throw new TypeError(`"logger" must be a valid Logger object`);
}
['trace', 'debug', 'info', 'warn', 'error'].forEach((method) => {
if (typeof logger[method] !== 'function') {
throw new TypeError(`Logger object missing "${method}" method`);
}
});
};

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

],
"version": "0.17.0",
"version": "0.18.0",
"homepage": "https://github.com/mixpanel/mixpanel-node",

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

"type": "git",
"url": "http://github.com/mixpanel/mixpanel-node.git"
"url": "git+ssh://git@github.com/mixpanel/mixpanel-node.git"
},

@@ -24,0 +24,0 @@ "engines": {

@@ -33,2 +33,8 @@ Mixpanel-node

// pass the custom logger (default is console)
var mixpanel = Mixpanel.init('<YOUR_TOKEN>', {
debug: true,
logger: pinoLogger, // or bunyan, or any other logger that implements the same interface
});
// track an event with optional properties

@@ -260,2 +266,3 @@ mixpanel.track('my event', {

- [Arsal Imam](https://github.com/ArsalImam)
- [Aleksei Iatsiuk](https://github.com/iatsiuk)

@@ -262,0 +269,0 @@ License

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