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

mixpanel-data-export

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixpanel-data-export - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

33

npm/lib/mixpanel_data_export.js

@@ -15,3 +15,2 @@ if (typeof window !== "object" && typeof require === "function") {

this.api_secret = this.opts.api_secret;
this.api_stub = this.opts.api_stub || "https://mixpanel.com/api/2.0/";
this.timeout_after = this.opts.timeout_after || 10;

@@ -21,2 +20,7 @@ this._requestNumber = 0;

MixpanelExport.prototype.export = function(parameters, callback) {
if (typeof window === 'object') throw new Error("Export is only supported server-side at the moment. If you can figure out how to get the jsonp working for it drop us a PR!");
return this.get("export", parameters, callback);
}
MixpanelExport.prototype.events = function(parameters, callback) {

@@ -79,7 +83,13 @@ return this.get("events", parameters, callback);

MixpanelExport.prototype.get = function(method, parameters, callback) {
var self = this;
// JSONP
if (typeof window === 'object') {
if (typeof window === 'object' && method !== "export") {
var requestNumber = this._getNewRequestNumber();
var requestUrl = this._buildRequestURL(method, parameters) + "&callback=mpSuccess" + requestNumber;
window['mpSuccess' + requestNumber] = callback;
var success = function(data) {
var resultJSON = (method == "export") ? self.parseExportResult(data) : data;
callback(resultJSON);
}
window['mpSuccess' + requestNumber] = success;
var script = document.createElement("script");

@@ -89,3 +99,3 @@ script.src = requestUrl;

}
// Node
// Node and "export".
else {

@@ -95,4 +105,4 @@ var requestUrl = this._buildRequestURL(method, parameters)

var success = function() {
result = JSON.parse(this.responseText);
callback(result);
var resultJSON = (method == "export") ? self.parseExportResult(this.responseText) : JSON.parse(this.responseText);
callback(resultJSON);
}

@@ -105,4 +115,13 @@ request.onload = success;

// Parses Mixpanel's strange formatting for the export endpoint.
MixpanelExport.prototype.parseExportResult = function(result){
var step1 = result.replace(new RegExp('\n', 'g'), ',');
var step2 = '['+step1+']';
var result = step2.replace(',]', ']');
return JSON.parse(result);
};
MixpanelExport.prototype._buildRequestURL = function(method, parameters) {
return "" + this.api_stub + ((typeof method.join === "function" ? method.join("/") : void 0) || method) + "/?" + (this._requestParameterString(parameters));
var apiStub = (method === "export") ? "https://data.mixpanel.com/api/2.0/" : "https://mixpanel.com/api/2.0/";
return "" + apiStub + ((typeof method.join === "function" ? method.join("/") : void 0) || method) + "/?" + (this._requestParameterString(parameters));
};

@@ -109,0 +128,0 @@

{
"name": "mixpanel-data-export",
"version": "v1.2.2",
"version": "v1.3.0",
"description": "A wrapper for Mixpanel's data export API. Simply instantiate the class with your API secret and key and then make calls to api methods and get json back.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,2 +0,2 @@

Mixpanel Data Export (v 1.2.2)
Mixpanel Data Export (v 1.3.0)
==============================

@@ -21,2 +21,3 @@

- `export(parameters, callback)` (node only, see: https://github.com/michaelcarter/mixpanel-data-export-js/issues/3)
- `events(paramters, callback)`

@@ -23,0 +24,0 @@ - `topEvents(paramters, callback)`

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