Skip to content

Commit 1a4a3b6

Browse files
committed
build 2.43.0
1 parent 96fc594 commit 1a4a3b6

File tree

12 files changed

+5637
-244
lines changed

12 files changed

+5637
-244
lines changed

dist/mixpanel.amd.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ define(function () { 'use strict';
22

33
var Config = {
44
DEBUG: false,
5-
LIB_VERSION: '2.42.1'
5+
LIB_VERSION: '2.43.0'
66
};
77

88
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -5843,6 +5843,8 @@ define(function () { 'use strict';
58435843
var NOOP_FUNC = function() {};
58445844

58455845
/** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
5846+
/** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
5847+
/** @const */ var PAYLOAD_TYPE_JSON = 'json';
58465848

58475849

58485850
/*
@@ -5873,6 +5875,7 @@ define(function () { 'use strict';
58735875
'api_host': 'https://api-js.mixpanel.com',
58745876
'api_method': 'POST',
58755877
'api_transport': 'XHR',
5878+
'api_payload_format': PAYLOAD_TYPE_BASE64,
58765879
'app_host': 'https://mixpanel.com',
58775880
'cdn': 'https://cdn.mxpnl.com',
58785881
'cross_site_cookie': false,
@@ -5968,12 +5971,6 @@ define(function () { 'use strict';
59685971
return instance;
59695972
};
59705973

5971-
var encode_data_for_request = function(data) {
5972-
var json_data = _.JSONEncode(data);
5973-
var encoded_data = _.base64Encode(json_data);
5974-
return {'data': encoded_data};
5975-
};
5976-
59775974
// Initialization methods
59785975

59795976
/**
@@ -6023,7 +6020,17 @@ define(function () { 'use strict';
60236020
this['config'] = {};
60246021
this['_triggered_notifs'] = [];
60256022

6026-
this.set_config(_.extend({}, DEFAULT_CONFIG, config, {
6023+
var variable_features = {};
6024+
6025+
// default to JSON payload for standard mixpanel.com API hosts
6026+
if (!('api_payload_format' in config)) {
6027+
var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
6028+
if (api_host.match(/\.mixpanel\.com$/)) {
6029+
variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
6030+
}
6031+
}
6032+
6033+
this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
60276034
'name': name,
60286035
'token': token,
60296036
'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
@@ -6399,7 +6406,7 @@ define(function () { 'use strict';
63996406
sendRequestFunc: _.bind(function(data, options, cb) {
64006407
this._send_request(
64016408
this.get_config('api_host') + attrs.endpoint,
6402-
encode_data_for_request(data),
6409+
this._encode_data_for_request(data),
64036410
options,
64046411
this._prepare_callback(cb, data)
64056412
);
@@ -6473,6 +6480,14 @@ define(function () { 'use strict';
64736480
}
64746481
};
64756482

6483+
MixpanelLib.prototype._encode_data_for_request = function(data) {
6484+
var encoded_data = _.JSONEncode(data);
6485+
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
6486+
encoded_data = _.base64Encode(encoded_data);
6487+
}
6488+
return {'data': encoded_data};
6489+
};
6490+
64766491
// internal method for handling track vs batch-enqueue logic
64776492
MixpanelLib.prototype._track_or_batch = function(options, callback) {
64786493
var truncated_data = _.truncate(options.data, 255);
@@ -6492,7 +6507,7 @@ define(function () { 'use strict';
64926507
console.log(truncated_data);
64936508
return this._send_request(
64946509
endpoint,
6495-
encode_data_for_request(truncated_data),
6510+
this._encode_data_for_request(truncated_data),
64966511
send_request_options,
64976512
this._prepare_callback(callback, truncated_data)
64986513
);

dist/mixpanel.cjs.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var Config = {
44
DEBUG: false,
5-
LIB_VERSION: '2.42.1'
5+
LIB_VERSION: '2.43.0'
66
};
77

88
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -5843,6 +5843,8 @@ var IDENTITY_FUNC = function(x) {return x;};
58435843
var NOOP_FUNC = function() {};
58445844

58455845
/** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
5846+
/** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
5847+
/** @const */ var PAYLOAD_TYPE_JSON = 'json';
58465848

58475849

58485850
/*
@@ -5873,6 +5875,7 @@ var DEFAULT_CONFIG = {
58735875
'api_host': 'https://api-js.mixpanel.com',
58745876
'api_method': 'POST',
58755877
'api_transport': 'XHR',
5878+
'api_payload_format': PAYLOAD_TYPE_BASE64,
58765879
'app_host': 'https://mixpanel.com',
58775880
'cdn': 'https://cdn.mxpnl.com',
58785881
'cross_site_cookie': false,
@@ -5968,12 +5971,6 @@ var create_mplib = function(token, config, name) {
59685971
return instance;
59695972
};
59705973

5971-
var encode_data_for_request = function(data) {
5972-
var json_data = _.JSONEncode(data);
5973-
var encoded_data = _.base64Encode(json_data);
5974-
return {'data': encoded_data};
5975-
};
5976-
59775974
// Initialization methods
59785975

59795976
/**
@@ -6023,7 +6020,17 @@ MixpanelLib.prototype._init = function(token, config, name) {
60236020
this['config'] = {};
60246021
this['_triggered_notifs'] = [];
60256022

6026-
this.set_config(_.extend({}, DEFAULT_CONFIG, config, {
6023+
var variable_features = {};
6024+
6025+
// default to JSON payload for standard mixpanel.com API hosts
6026+
if (!('api_payload_format' in config)) {
6027+
var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
6028+
if (api_host.match(/\.mixpanel\.com$/)) {
6029+
variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
6030+
}
6031+
}
6032+
6033+
this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
60276034
'name': name,
60286035
'token': token,
60296036
'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
@@ -6399,7 +6406,7 @@ MixpanelLib.prototype.init_batchers = function() {
63996406
sendRequestFunc: _.bind(function(data, options, cb) {
64006407
this._send_request(
64016408
this.get_config('api_host') + attrs.endpoint,
6402-
encode_data_for_request(data),
6409+
this._encode_data_for_request(data),
64036410
options,
64046411
this._prepare_callback(cb, data)
64056412
);
@@ -6473,6 +6480,14 @@ MixpanelLib.prototype.disable = function(events) {
64736480
}
64746481
};
64756482

6483+
MixpanelLib.prototype._encode_data_for_request = function(data) {
6484+
var encoded_data = _.JSONEncode(data);
6485+
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
6486+
encoded_data = _.base64Encode(encoded_data);
6487+
}
6488+
return {'data': encoded_data};
6489+
};
6490+
64766491
// internal method for handling track vs batch-enqueue logic
64776492
MixpanelLib.prototype._track_or_batch = function(options, callback) {
64786493
var truncated_data = _.truncate(options.data, 255);
@@ -6492,7 +6507,7 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
64926507
console.log(truncated_data);
64936508
return this._send_request(
64946509
endpoint,
6495-
encode_data_for_request(truncated_data),
6510+
this._encode_data_for_request(truncated_data),
64966511
send_request_options,
64976512
this._prepare_callback(callback, truncated_data)
64986513
);

dist/mixpanel.globals.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
var Config = {
55
DEBUG: false,
6-
LIB_VERSION: '2.42.1'
6+
LIB_VERSION: '2.43.0'
77
};
88

99
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -5844,6 +5844,8 @@
58445844
var NOOP_FUNC = function() {};
58455845

58465846
/** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
5847+
/** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
5848+
/** @const */ var PAYLOAD_TYPE_JSON = 'json';
58475849

58485850

58495851
/*
@@ -5874,6 +5876,7 @@
58745876
'api_host': 'https://api-js.mixpanel.com',
58755877
'api_method': 'POST',
58765878
'api_transport': 'XHR',
5879+
'api_payload_format': PAYLOAD_TYPE_BASE64,
58775880
'app_host': 'https://mixpanel.com',
58785881
'cdn': 'https://cdn.mxpnl.com',
58795882
'cross_site_cookie': false,
@@ -5969,12 +5972,6 @@
59695972
return instance;
59705973
};
59715974

5972-
var encode_data_for_request = function(data) {
5973-
var json_data = _.JSONEncode(data);
5974-
var encoded_data = _.base64Encode(json_data);
5975-
return {'data': encoded_data};
5976-
};
5977-
59785975
// Initialization methods
59795976

59805977
/**
@@ -6024,7 +6021,17 @@
60246021
this['config'] = {};
60256022
this['_triggered_notifs'] = [];
60266023

6027-
this.set_config(_.extend({}, DEFAULT_CONFIG, config, {
6024+
var variable_features = {};
6025+
6026+
// default to JSON payload for standard mixpanel.com API hosts
6027+
if (!('api_payload_format' in config)) {
6028+
var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
6029+
if (api_host.match(/\.mixpanel\.com$/)) {
6030+
variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
6031+
}
6032+
}
6033+
6034+
this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
60286035
'name': name,
60296036
'token': token,
60306037
'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
@@ -6400,7 +6407,7 @@
64006407
sendRequestFunc: _.bind(function(data, options, cb) {
64016408
this._send_request(
64026409
this.get_config('api_host') + attrs.endpoint,
6403-
encode_data_for_request(data),
6410+
this._encode_data_for_request(data),
64046411
options,
64056412
this._prepare_callback(cb, data)
64066413
);
@@ -6474,6 +6481,14 @@
64746481
}
64756482
};
64766483

6484+
MixpanelLib.prototype._encode_data_for_request = function(data) {
6485+
var encoded_data = _.JSONEncode(data);
6486+
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
6487+
encoded_data = _.base64Encode(encoded_data);
6488+
}
6489+
return {'data': encoded_data};
6490+
};
6491+
64776492
// internal method for handling track vs batch-enqueue logic
64786493
MixpanelLib.prototype._track_or_batch = function(options, callback) {
64796494
var truncated_data = _.truncate(options.data, 255);
@@ -6493,7 +6508,7 @@
64936508
console.log(truncated_data);
64946509
return this._send_request(
64956510
endpoint,
6496-
encode_data_for_request(truncated_data),
6511+
this._encode_data_for_request(truncated_data),
64976512
send_request_options,
64986513
this._prepare_callback(callback, truncated_data)
64996514
);

0 commit comments

Comments
 (0)