mixpanel-browser 2.45.0 → 2.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/tests.yml +1 -1
- package/CHANGELOG.md +11 -1
- package/README.md +1 -1
- package/build.sh +2 -0
- package/dist/mixpanel.amd.js +229 -73
- package/dist/mixpanel.cjs.js +229 -73
- package/dist/mixpanel.globals.js +229 -73
- package/dist/mixpanel.min.js +104 -101
- package/dist/mixpanel.umd.js +229 -73
- package/doc/readme.io/javascript-full-api-reference.md +3 -55
- package/doc/template.md +1 -1
- package/package.json +5 -5
- package/src/config.js +1 -1
- package/src/mixpanel-core.js +103 -16
- package/src/mixpanel-people.js +29 -27
- package/src/mixpanel-persistence.js +0 -7
- package/src/request-batcher.js +50 -1
- package/src/utils.js +47 -21
package/dist/mixpanel.umd.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
var Config = {
|
|
8
8
|
DEBUG: false,
|
|
9
|
-
LIB_VERSION: '2.
|
|
9
|
+
LIB_VERSION: '2.47.0'
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
@@ -836,20 +836,24 @@
|
|
|
836
836
|
|
|
837
837
|
_.UUID = (function() {
|
|
838
838
|
|
|
839
|
-
// Time
|
|
840
|
-
// 1*new Date() is a cross browser version of Date.now()
|
|
839
|
+
// Time-based entropy
|
|
841
840
|
var T = function() {
|
|
842
|
-
var
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
841
|
+
var time = 1 * new Date(); // cross-browser version of Date.now()
|
|
842
|
+
var ticks;
|
|
843
|
+
if (window$1.performance && window$1.performance.now) {
|
|
844
|
+
ticks = window$1.performance.now();
|
|
845
|
+
} else {
|
|
846
|
+
// fall back to busy loop
|
|
847
|
+
ticks = 0;
|
|
848
|
+
|
|
849
|
+
// this while loop figures how many browser ticks go by
|
|
850
|
+
// before 1*new Date() returns a new number, ie the amount
|
|
851
|
+
// of ticks that go by per millisecond
|
|
852
|
+
while (time == 1 * new Date()) {
|
|
853
|
+
ticks++;
|
|
854
|
+
}
|
|
850
855
|
}
|
|
851
|
-
|
|
852
|
-
return d.toString(16) + i.toString(16);
|
|
856
|
+
return time.toString(16) + Math.floor(ticks).toString(16);
|
|
853
857
|
};
|
|
854
858
|
|
|
855
859
|
// Math.Random entropy
|
|
@@ -1416,21 +1420,42 @@
|
|
|
1416
1420
|
};
|
|
1417
1421
|
})();
|
|
1418
1422
|
|
|
1423
|
+
var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'];
|
|
1424
|
+
var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'ttclid', 'twclid', 'wbraid'];
|
|
1425
|
+
|
|
1419
1426
|
_.info = {
|
|
1420
|
-
campaignParams: function() {
|
|
1421
|
-
var
|
|
1422
|
-
kw = '',
|
|
1427
|
+
campaignParams: function(default_value) {
|
|
1428
|
+
var kw = '',
|
|
1423
1429
|
params = {};
|
|
1424
|
-
_.each(
|
|
1430
|
+
_.each(CAMPAIGN_KEYWORDS, function(kwkey) {
|
|
1425
1431
|
kw = _.getQueryParam(document$1.URL, kwkey);
|
|
1426
1432
|
if (kw.length) {
|
|
1427
1433
|
params[kwkey] = kw;
|
|
1434
|
+
} else if (default_value !== undefined) {
|
|
1435
|
+
params[kwkey] = default_value;
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
return params;
|
|
1440
|
+
},
|
|
1441
|
+
|
|
1442
|
+
clickParams: function() {
|
|
1443
|
+
var id = '',
|
|
1444
|
+
params = {};
|
|
1445
|
+
_.each(CLICK_IDS, function(idkey) {
|
|
1446
|
+
id = _.getQueryParam(document$1.URL, idkey);
|
|
1447
|
+
if (id.length) {
|
|
1448
|
+
params[idkey] = id;
|
|
1428
1449
|
}
|
|
1429
1450
|
});
|
|
1430
1451
|
|
|
1431
1452
|
return params;
|
|
1432
1453
|
},
|
|
1433
1454
|
|
|
1455
|
+
marketingParams: function() {
|
|
1456
|
+
return _.extend(_.info.campaignParams(), _.info.clickParams());
|
|
1457
|
+
},
|
|
1458
|
+
|
|
1434
1459
|
searchEngine: function(referrer) {
|
|
1435
1460
|
if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
|
|
1436
1461
|
return 'google';
|
|
@@ -1627,12 +1652,13 @@
|
|
|
1627
1652
|
});
|
|
1628
1653
|
},
|
|
1629
1654
|
|
|
1630
|
-
|
|
1655
|
+
mpPageViewProperties: function() {
|
|
1631
1656
|
return _.strip_empty_properties({
|
|
1632
|
-
'
|
|
1633
|
-
'
|
|
1634
|
-
'
|
|
1635
|
-
'
|
|
1657
|
+
'current_page_title': document$1.title,
|
|
1658
|
+
'current_domain': window$1.location.hostname,
|
|
1659
|
+
'current_url_path': window$1.location.pathname,
|
|
1660
|
+
'current_url_protocol': window$1.location.protocol,
|
|
1661
|
+
'current_url_search': window$1.location.search
|
|
1636
1662
|
});
|
|
1637
1663
|
}
|
|
1638
1664
|
};
|
|
@@ -2299,6 +2325,9 @@
|
|
|
2299
2325
|
|
|
2300
2326
|
this.stopped = !this.libConfig['batch_autostart'];
|
|
2301
2327
|
this.consecutiveRemovalFailures = 0;
|
|
2328
|
+
|
|
2329
|
+
// extra client-side dedupe
|
|
2330
|
+
this.itemIdsSentSuccessfully = {};
|
|
2302
2331
|
};
|
|
2303
2332
|
|
|
2304
2333
|
/**
|
|
@@ -2391,7 +2420,34 @@
|
|
|
2391
2420
|
payload = this.beforeSendHook(payload);
|
|
2392
2421
|
}
|
|
2393
2422
|
if (payload) {
|
|
2394
|
-
|
|
2423
|
+
// mp_sent_by_lib_version prop captures which lib version actually
|
|
2424
|
+
// sends each event (regardless of which version originally queued
|
|
2425
|
+
// it for sending)
|
|
2426
|
+
if (payload['event'] && payload['properties']) {
|
|
2427
|
+
payload['properties'] = _.extend(
|
|
2428
|
+
{},
|
|
2429
|
+
payload['properties'],
|
|
2430
|
+
{'mp_sent_by_lib_version': Config.LIB_VERSION}
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2433
|
+
var addPayload = true;
|
|
2434
|
+
var itemId = item['id'];
|
|
2435
|
+
if (itemId) {
|
|
2436
|
+
if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
|
|
2437
|
+
this.reportError('[dupe] item ID sent too many times, not sending', {
|
|
2438
|
+
item: item,
|
|
2439
|
+
batchSize: batch.length,
|
|
2440
|
+
timesSent: this.itemIdsSentSuccessfully[itemId]
|
|
2441
|
+
});
|
|
2442
|
+
addPayload = false;
|
|
2443
|
+
}
|
|
2444
|
+
} else {
|
|
2445
|
+
this.reportError('[dupe] found item with no ID', {item: item});
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
if (addPayload) {
|
|
2449
|
+
dataForRequest.push(payload);
|
|
2450
|
+
}
|
|
2395
2451
|
}
|
|
2396
2452
|
transformedItems[item['id']] = payload;
|
|
2397
2453
|
}, this);
|
|
@@ -2474,6 +2530,24 @@
|
|
|
2474
2530
|
}
|
|
2475
2531
|
}, this)
|
|
2476
2532
|
);
|
|
2533
|
+
|
|
2534
|
+
// client-side dedupe
|
|
2535
|
+
_.each(batch, _.bind(function(item) {
|
|
2536
|
+
var itemId = item['id'];
|
|
2537
|
+
if (itemId) {
|
|
2538
|
+
this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
|
|
2539
|
+
this.itemIdsSentSuccessfully[itemId]++;
|
|
2540
|
+
if (this.itemIdsSentSuccessfully[itemId] > 5) {
|
|
2541
|
+
this.reportError('[dupe] item ID sent too many times', {
|
|
2542
|
+
item: item,
|
|
2543
|
+
batchSize: batch.length,
|
|
2544
|
+
timesSent: this.itemIdsSentSuccessfully[itemId]
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
} else {
|
|
2548
|
+
this.reportError('[dupe] found item with no ID while removing', {item: item});
|
|
2549
|
+
}
|
|
2550
|
+
}, this));
|
|
2477
2551
|
}
|
|
2478
2552
|
|
|
2479
2553
|
} catch(err) {
|
|
@@ -3319,24 +3393,25 @@
|
|
|
3319
3393
|
});
|
|
3320
3394
|
|
|
3321
3395
|
/*
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3396
|
+
* Record that you have charged the current user a certain amount
|
|
3397
|
+
* of money. Charges recorded with track_charge() will appear in the
|
|
3398
|
+
* Mixpanel revenue report.
|
|
3399
|
+
*
|
|
3400
|
+
* ### Usage:
|
|
3401
|
+
*
|
|
3402
|
+
* // charge a user $50
|
|
3403
|
+
* mixpanel.people.track_charge(50);
|
|
3404
|
+
*
|
|
3405
|
+
* // charge a user $30.50 on the 2nd of january
|
|
3406
|
+
* mixpanel.people.track_charge(30.50, {
|
|
3407
|
+
* '$time': new Date('jan 1 2012')
|
|
3408
|
+
* });
|
|
3409
|
+
*
|
|
3410
|
+
* @param {Number} amount The amount of money charged to the current user
|
|
3411
|
+
* @param {Object} [properties] An associative array of properties associated with the charge
|
|
3412
|
+
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
3413
|
+
* @deprecated
|
|
3414
|
+
*/
|
|
3340
3415
|
MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(amount, properties, callback) {
|
|
3341
3416
|
if (!_.isNumber(amount)) {
|
|
3342
3417
|
amount = parseFloat(amount);
|
|
@@ -3352,15 +3427,16 @@
|
|
|
3352
3427
|
});
|
|
3353
3428
|
|
|
3354
3429
|
/*
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3430
|
+
* Permanently clear all revenue report transactions from the
|
|
3431
|
+
* current user's people analytics profile.
|
|
3432
|
+
*
|
|
3433
|
+
* ### Usage:
|
|
3434
|
+
*
|
|
3435
|
+
* mixpanel.people.clear_charges();
|
|
3436
|
+
*
|
|
3437
|
+
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
3438
|
+
* @deprecated
|
|
3439
|
+
*/
|
|
3364
3440
|
MixpanelPeople.prototype.clear_charges = function(callback) {
|
|
3365
3441
|
return this.set('$transactions', [], callback);
|
|
3366
3442
|
};
|
|
@@ -3760,13 +3836,6 @@
|
|
|
3760
3836
|
}
|
|
3761
3837
|
};
|
|
3762
3838
|
|
|
3763
|
-
MixpanelPersistence.prototype.update_campaign_params = function() {
|
|
3764
|
-
if (!this.campaign_params_saved) {
|
|
3765
|
-
this.register_once(_.info.campaignParams());
|
|
3766
|
-
this.campaign_params_saved = true;
|
|
3767
|
-
}
|
|
3768
|
-
};
|
|
3769
|
-
|
|
3770
3839
|
MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
|
|
3771
3840
|
this.register(_.info.searchInfo(referrer));
|
|
3772
3841
|
};
|
|
@@ -4049,6 +4118,7 @@
|
|
|
4049
4118
|
/** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
|
|
4050
4119
|
/** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
|
|
4051
4120
|
/** @const */ var PAYLOAD_TYPE_JSON = 'json';
|
|
4121
|
+
/** @const */ var DEVICE_ID_PREFIX = '$device:';
|
|
4052
4122
|
|
|
4053
4123
|
|
|
4054
4124
|
/*
|
|
@@ -4090,6 +4160,9 @@
|
|
|
4090
4160
|
'cookie_domain': '',
|
|
4091
4161
|
'cookie_name': '',
|
|
4092
4162
|
'loaded': NOOP_FUNC,
|
|
4163
|
+
'track_marketing': true,
|
|
4164
|
+
'track_pageview': false,
|
|
4165
|
+
'skip_first_touch_marketing': false,
|
|
4093
4166
|
'store_google': true,
|
|
4094
4167
|
'save_referrer': true,
|
|
4095
4168
|
'test': false,
|
|
@@ -4156,6 +4229,25 @@
|
|
|
4156
4229
|
instance['people'] = new MixpanelPeople();
|
|
4157
4230
|
instance['people']._init(instance);
|
|
4158
4231
|
|
|
4232
|
+
if (!instance.get_config('skip_first_touch_marketing')) {
|
|
4233
|
+
// We need null UTM params in the object because
|
|
4234
|
+
// UTM parameters act as a tuple. If any UTM param
|
|
4235
|
+
// is present, then we set all UTM params including
|
|
4236
|
+
// empty ones together
|
|
4237
|
+
var utm_params = _.info.campaignParams(null);
|
|
4238
|
+
var initial_utm_params = {};
|
|
4239
|
+
var has_utm = false;
|
|
4240
|
+
_.each(utm_params, function(utm_value, utm_key) {
|
|
4241
|
+
initial_utm_params['initial_' + utm_key] = utm_value;
|
|
4242
|
+
if (utm_value) {
|
|
4243
|
+
has_utm = true;
|
|
4244
|
+
}
|
|
4245
|
+
});
|
|
4246
|
+
if (has_utm) {
|
|
4247
|
+
instance['people'].set_once(initial_utm_params);
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4159
4251
|
// if any instance on the page has debug = true, we set the
|
|
4160
4252
|
// global debug to be true
|
|
4161
4253
|
Config.DEBUG = Config.DEBUG || instance.get_config('debug');
|
|
@@ -4187,7 +4279,7 @@
|
|
|
4187
4279
|
* mixpanel.library_name.track(...);
|
|
4188
4280
|
*
|
|
4189
4281
|
* @param {String} token Your Mixpanel API token
|
|
4190
|
-
* @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/
|
|
4282
|
+
* @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/v2.46.0/src/mixpanel-core.js#L88-L127">See a list of default config options</a>.
|
|
4191
4283
|
* @param {String} [name] The name for the new mixpanel instance that you want created
|
|
4192
4284
|
*/
|
|
4193
4285
|
MixpanelLib.prototype.init = function (token, config, name) {
|
|
@@ -4225,7 +4317,7 @@
|
|
|
4225
4317
|
// default to JSON payload for standard mixpanel.com API hosts
|
|
4226
4318
|
if (!('api_payload_format' in config)) {
|
|
4227
4319
|
var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
|
|
4228
|
-
if (api_host.match(/\.mixpanel\.com
|
|
4320
|
+
if (api_host.match(/\.mixpanel\.com/)) {
|
|
4229
4321
|
variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
|
|
4230
4322
|
}
|
|
4231
4323
|
}
|
|
@@ -4296,10 +4388,14 @@
|
|
|
4296
4388
|
// or the device id if something was already stored
|
|
4297
4389
|
// in the persitence
|
|
4298
4390
|
this.register_once({
|
|
4299
|
-
'distinct_id': uuid,
|
|
4391
|
+
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
4300
4392
|
'$device_id': uuid
|
|
4301
4393
|
}, '');
|
|
4302
4394
|
}
|
|
4395
|
+
|
|
4396
|
+
if (this.get_config('track_pageview')) {
|
|
4397
|
+
this.track_pageview();
|
|
4398
|
+
}
|
|
4303
4399
|
};
|
|
4304
4400
|
|
|
4305
4401
|
// Private methods
|
|
@@ -4313,7 +4409,7 @@
|
|
|
4313
4409
|
MixpanelLib.prototype._set_default_superprops = function() {
|
|
4314
4410
|
this['persistence'].update_search_keyword(document$1.referrer);
|
|
4315
4411
|
if (this.get_config('store_google')) {
|
|
4316
|
-
this
|
|
4412
|
+
this.register(_.info.campaignParams(), {persistent: false});
|
|
4317
4413
|
}
|
|
4318
4414
|
if (this.get_config('save_referrer')) {
|
|
4319
4415
|
this['persistence'].update_referrer_info(document$1.referrer);
|
|
@@ -4795,6 +4891,10 @@
|
|
|
4795
4891
|
|
|
4796
4892
|
this._set_default_superprops();
|
|
4797
4893
|
|
|
4894
|
+
var marketing_properties = this.get_config('track_marketing')
|
|
4895
|
+
? _.info.marketingParams()
|
|
4896
|
+
: {};
|
|
4897
|
+
|
|
4798
4898
|
// note: extend writes to the first object, so lets make sure we
|
|
4799
4899
|
// don't write to the persistence properties object and info
|
|
4800
4900
|
// properties object by passing in a new object
|
|
@@ -4803,6 +4903,7 @@
|
|
|
4803
4903
|
properties = _.extend(
|
|
4804
4904
|
{},
|
|
4805
4905
|
_.info.properties(),
|
|
4906
|
+
marketing_properties,
|
|
4806
4907
|
this['persistence'].properties(),
|
|
4807
4908
|
this.unpersisted_superprops,
|
|
4808
4909
|
properties
|
|
@@ -4963,17 +5064,54 @@
|
|
|
4963
5064
|
};
|
|
4964
5065
|
|
|
4965
5066
|
/**
|
|
4966
|
-
* Track
|
|
5067
|
+
* Track a default Mixpanel page view event, which includes extra default event properties to
|
|
5068
|
+
* improve page view data. The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
|
|
5069
|
+
* may be turned on for tracking page loads automatically.
|
|
4967
5070
|
*
|
|
4968
|
-
*
|
|
4969
|
-
*
|
|
5071
|
+
* ### Usage
|
|
5072
|
+
*
|
|
5073
|
+
* // track a default $mp_web_page_view event
|
|
5074
|
+
* mixpanel.track_pageview();
|
|
5075
|
+
*
|
|
5076
|
+
* // track a page view event with additional event properties
|
|
5077
|
+
* mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
|
|
5078
|
+
*
|
|
5079
|
+
* // example approach to track page views on different page types as event properties
|
|
5080
|
+
* mixpanel.track_pageview({'page': 'pricing'});
|
|
5081
|
+
* mixpanel.track_pageview({'page': 'homepage'});
|
|
5082
|
+
*
|
|
5083
|
+
* // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
|
|
5084
|
+
* // individual pages on the same site or product. Use cases for custom event_name may be page
|
|
5085
|
+
* // views on different products or internal applications that are considered completely separate
|
|
5086
|
+
* mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
|
|
5087
|
+
*
|
|
5088
|
+
* @param {Object} [properties] An optional set of additional properties to send with the page view event
|
|
5089
|
+
* @param {Object} [options] Page view tracking options
|
|
5090
|
+
* @param {String} [options.event_name] - Alternate name for the tracking event
|
|
5091
|
+
* @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
|
|
5092
|
+
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
4970
5093
|
*/
|
|
4971
|
-
MixpanelLib.prototype.track_pageview = function(
|
|
4972
|
-
if (
|
|
4973
|
-
|
|
5094
|
+
MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
|
|
5095
|
+
if (typeof properties !== 'object') {
|
|
5096
|
+
properties = {};
|
|
4974
5097
|
}
|
|
4975
|
-
|
|
4976
|
-
|
|
5098
|
+
options = options || {};
|
|
5099
|
+
var event_name = options['event_name'] || '$mp_web_page_view';
|
|
5100
|
+
|
|
5101
|
+
var default_page_properties = _.extend(
|
|
5102
|
+
_.info.mpPageViewProperties(),
|
|
5103
|
+
_.info.campaignParams(),
|
|
5104
|
+
_.info.clickParams()
|
|
5105
|
+
);
|
|
5106
|
+
|
|
5107
|
+
var event_properties = _.extend(
|
|
5108
|
+
{},
|
|
5109
|
+
default_page_properties,
|
|
5110
|
+
properties
|
|
5111
|
+
);
|
|
5112
|
+
|
|
5113
|
+
return this.track(event_name, event_properties);
|
|
5114
|
+
});
|
|
4977
5115
|
|
|
4978
5116
|
/**
|
|
4979
5117
|
* Track clicks on a set of document elements. Selector must be a
|
|
@@ -5222,7 +5360,15 @@
|
|
|
5222
5360
|
// _unset_callback:function A callback to be run if and when the People unset queue is flushed
|
|
5223
5361
|
|
|
5224
5362
|
var previous_distinct_id = this.get_distinct_id();
|
|
5225
|
-
|
|
5363
|
+
if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
|
|
5364
|
+
// we allow the following condition if previous distinct_id is same as new_distinct_id
|
|
5365
|
+
// so that you can force flush people updates for anonymous profiles.
|
|
5366
|
+
if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
|
|
5367
|
+
this.report_error('distinct_id cannot have $device: prefix');
|
|
5368
|
+
return -1;
|
|
5369
|
+
}
|
|
5370
|
+
this.register({'$user_id': new_distinct_id});
|
|
5371
|
+
}
|
|
5226
5372
|
|
|
5227
5373
|
if (!this.get_property('$device_id')) {
|
|
5228
5374
|
// The persisted distinct id might not actually be a device id at all
|
|
@@ -5263,7 +5409,7 @@
|
|
|
5263
5409
|
this._flags.identify_called = false;
|
|
5264
5410
|
var uuid = _.UUID();
|
|
5265
5411
|
this.register_once({
|
|
5266
|
-
'distinct_id': uuid,
|
|
5412
|
+
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
5267
5413
|
'$device_id': uuid
|
|
5268
5414
|
}, '');
|
|
5269
5415
|
};
|
|
@@ -5388,8 +5534,8 @@
|
|
|
5388
5534
|
* // batching or retry mechanisms.
|
|
5389
5535
|
* api_transport: 'XHR'
|
|
5390
5536
|
*
|
|
5391
|
-
* //
|
|
5392
|
-
* batch_requests:
|
|
5537
|
+
* // request-batching/queueing/retry
|
|
5538
|
+
* batch_requests: true,
|
|
5393
5539
|
*
|
|
5394
5540
|
* // maximum number of events/updates to send in a single
|
|
5395
5541
|
* // network request
|
|
@@ -5461,10 +5607,20 @@
|
|
|
5461
5607
|
* // secure, meaning they will only be transmitted over https
|
|
5462
5608
|
* secure_cookie: false
|
|
5463
5609
|
*
|
|
5610
|
+
* // disables enriching user profiles with first touch marketing data
|
|
5611
|
+
* skip_first_touch_marketing: false
|
|
5612
|
+
*
|
|
5464
5613
|
* // the amount of time track_links will
|
|
5465
5614
|
* // wait for Mixpanel's servers to respond
|
|
5466
5615
|
* track_links_timeout: 300
|
|
5467
5616
|
*
|
|
5617
|
+
* // adds any UTM parameters and click IDs present on the page to any events fired
|
|
5618
|
+
* track_marketing: true
|
|
5619
|
+
*
|
|
5620
|
+
* // enables automatic page view tracking using default page view events through
|
|
5621
|
+
* // the track_pageview() method
|
|
5622
|
+
* track_pageview: false
|
|
5623
|
+
*
|
|
5468
5624
|
* // if you set upgrade to be true, the library will check for
|
|
5469
5625
|
* // a cookie from our old js library and import super
|
|
5470
5626
|
* // properties from it, then the old cookie is deleted
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
category:
|
|
2
|
+
category: 62ec0192a94ae90a45602b13
|
|
3
3
|
title: JavaScript Full API Reference
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -450,8 +450,8 @@ The default config is:
|
|
|
450
450
|
// batching or retry mechanisms.
|
|
451
451
|
api_transport: 'XHR'
|
|
452
452
|
|
|
453
|
-
//
|
|
454
|
-
batch_requests:
|
|
453
|
+
// request-batching/queueing/retry
|
|
454
|
+
batch_requests: true,
|
|
455
455
|
|
|
456
456
|
// maximum number of events/updates to send in a single
|
|
457
457
|
// network request
|
|
@@ -538,14 +538,6 @@ The default config is:
|
|
|
538
538
|
// the format {'Header-Name': value}
|
|
539
539
|
xhr_headers: {}
|
|
540
540
|
|
|
541
|
-
// protocol for fetching in-app message resources, e.g.
|
|
542
|
-
// 'https://' or 'http://'; defaults to '//' (which defers to the
|
|
543
|
-
// current page's protocol)
|
|
544
|
-
inapp_protocol: '//'
|
|
545
|
-
|
|
546
|
-
// whether to open in-app message link in new tab/window
|
|
547
|
-
inapp_link_new_window: false
|
|
548
|
-
|
|
549
541
|
// whether to ignore or respect the web browser's Do Not Track setting
|
|
550
542
|
ignore_dnt: false
|
|
551
543
|
}
|
|
@@ -761,24 +753,6 @@ mixpanel.people.append({
|
|
|
761
753
|
| **callback** | <span class="mp-arg-type">Function</span></br></span><span class="mp-arg-optional">optional</span> | If provided, the callback will be called after tracking the event. |
|
|
762
754
|
|
|
763
755
|
|
|
764
|
-
___
|
|
765
|
-
## mixpanel.people.clear_charges
|
|
766
|
-
Permanently clear all revenue report transactions from the current user's people analytics profile.
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
### Usage:
|
|
770
|
-
|
|
771
|
-
```javascript
|
|
772
|
-
mixpanel.people.clear_charges();
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
| Argument | Type | Description |
|
|
778
|
-
| ------------- | ------------- | ----- |
|
|
779
|
-
| **callback** | <span class="mp-arg-type">Function</span></br></span><span class="mp-arg-optional">optional</span> | If provided, the callback will be called after tracking the event. |
|
|
780
|
-
|
|
781
|
-
|
|
782
756
|
___
|
|
783
757
|
## mixpanel.people.delete_user
|
|
784
758
|
Permanently deletes the current people analytics profile from Mixpanel (using the current distinct_id).
|
|
@@ -904,32 +878,6 @@ mixpanel.people.set_once({
|
|
|
904
878
|
| **callback** | <span class="mp-arg-type">Function</span></br></span><span class="mp-arg-optional">optional</span> | If provided, the callback will be called after tracking the event. |
|
|
905
879
|
|
|
906
880
|
|
|
907
|
-
___
|
|
908
|
-
## mixpanel.people.track_charge
|
|
909
|
-
Record that you have charged the current user a certain amount of money. Charges recorded with track_charge() will appear in the Mixpanel revenue report.
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
### Usage:
|
|
913
|
-
|
|
914
|
-
```javascript
|
|
915
|
-
// charge a user $50
|
|
916
|
-
mixpanel.people.track_charge(50);
|
|
917
|
-
|
|
918
|
-
// charge a user $30.50 on the 2nd of january
|
|
919
|
-
mixpanel.people.track_charge(30.50, {
|
|
920
|
-
'$time': new Date('jan 1 2012')
|
|
921
|
-
});
|
|
922
|
-
```
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
| Argument | Type | Description |
|
|
927
|
-
| ------------- | ------------- | ----- |
|
|
928
|
-
| **amount** | <span class="mp-arg-type">Number</span></br></span><span class="mp-arg-required">required</span> | The amount of money charged to the current user |
|
|
929
|
-
| **properties** | <span class="mp-arg-type">Object</span></br></span><span class="mp-arg-optional">optional</span> | An associative array of properties associated with the charge |
|
|
930
|
-
| **callback** | <span class="mp-arg-type">Function</span></br></span><span class="mp-arg-optional">optional</span> | If provided, the callback will be called when the server responds |
|
|
931
|
-
|
|
932
|
-
|
|
933
881
|
___
|
|
934
882
|
## mixpanel.people.union
|
|
935
883
|
Merge a given list with a list-valued people analytics property, excluding duplicate values.
|
package/doc/template.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mixpanel-browser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.47.0",
|
|
4
4
|
"description": "The official Mixpanel JavaScript browser client library",
|
|
5
5
|
"main": "dist/mixpanel.cjs.js",
|
|
6
6
|
"directories": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build-full": "FULL=1 ./build.sh",
|
|
13
13
|
"build-test-polyfill": "webpack tests/vendor/core-js-polyfills.src.js tests/vendor/core-js-polyfills.js",
|
|
14
14
|
"dox": "node doc/build-docs.js",
|
|
15
|
-
"dox-publish": "rdme docs doc/readme.io --key=$RDME_API_KEY --version
|
|
15
|
+
"dox-publish": "rdme docs:single doc/readme.io/javascript-full-api-reference.md --key=$RDME_API_KEY --version=$RDME_DOC_VERSION",
|
|
16
16
|
"integration_test": "echo 'Browse to localhost:3000/tests' && node testServer.js",
|
|
17
17
|
"lint": "eslint ./src",
|
|
18
18
|
"prepublishOnly": "npm run build-dist",
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
"babel-preset-es2015": "6.6.0",
|
|
38
38
|
"babelify": "6.1.2",
|
|
39
39
|
"browserify": "10.2.4",
|
|
40
|
-
"chai": "
|
|
40
|
+
"chai": "4.0.0",
|
|
41
41
|
"cookie-parser": "1.3.4",
|
|
42
42
|
"core-js": "3.6.5",
|
|
43
43
|
"dox": "0.9.0",
|
|
44
44
|
"eslint": "4.18.2",
|
|
45
45
|
"express": "4.12.2",
|
|
46
|
-
"jsdom": "
|
|
46
|
+
"jsdom": "16.5.0",
|
|
47
47
|
"jsdom-global": "3.0.2",
|
|
48
48
|
"localStorage": "1.0.4",
|
|
49
49
|
"lodash": "4.17.21",
|
|
50
50
|
"mocha": "7.1.1",
|
|
51
51
|
"morgan": "1.9.1",
|
|
52
|
-
"rdme": "
|
|
52
|
+
"rdme": "7.5.0",
|
|
53
53
|
"request": "2.88.0",
|
|
54
54
|
"rollup": "0.25.8",
|
|
55
55
|
"rollup-plugin-npm": "1.4.0",
|