mixpanel-browser 2.46.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.
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [14.x, 16.x]
16
+ node-version: [16.x, 18.x, 20.x]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ **2.47.0** (27 Apr 2023)
2
+ - Collect richer marketing attribution properties for multi-touch attribution
3
+ - New implementation of previously-deprecated track_pageview() method and init option to send automatically
4
+ - Use performance.now when available for time-based entropy component of UUID-generation (thanks @adrianherd)
5
+ - looser API Host check for default JSON-payload sending to mipxanel.com hosts
6
+
1
7
  **2.46.0** (20 Mar 2023)
2
8
  - Updates for new identity management system
3
9
  - More aggressive deduplication within batch sender
@@ -2,7 +2,7 @@ define(function () { 'use strict';
2
2
 
3
3
  var Config = {
4
4
  DEBUG: false,
5
- LIB_VERSION: '2.46.0'
5
+ LIB_VERSION: '2.47.0'
6
6
  };
7
7
 
8
8
  // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -832,20 +832,24 @@ define(function () { 'use strict';
832
832
 
833
833
  _.UUID = (function() {
834
834
 
835
- // Time/ticks information
836
- // 1*new Date() is a cross browser version of Date.now()
835
+ // Time-based entropy
837
836
  var T = function() {
838
- var d = 1 * new Date(),
839
- i = 0;
840
-
841
- // this while loop figures how many browser ticks go by
842
- // before 1*new Date() returns a new number, ie the amount
843
- // of ticks that go by per millisecond
844
- while (d == 1 * new Date()) {
845
- i++;
837
+ var time = 1 * new Date(); // cross-browser version of Date.now()
838
+ var ticks;
839
+ if (window$1.performance && window$1.performance.now) {
840
+ ticks = window$1.performance.now();
841
+ } else {
842
+ // fall back to busy loop
843
+ ticks = 0;
844
+
845
+ // this while loop figures how many browser ticks go by
846
+ // before 1*new Date() returns a new number, ie the amount
847
+ // of ticks that go by per millisecond
848
+ while (time == 1 * new Date()) {
849
+ ticks++;
850
+ }
846
851
  }
847
-
848
- return d.toString(16) + i.toString(16);
852
+ return time.toString(16) + Math.floor(ticks).toString(16);
849
853
  };
850
854
 
851
855
  // Math.Random entropy
@@ -1412,21 +1416,42 @@ define(function () { 'use strict';
1412
1416
  };
1413
1417
  })();
1414
1418
 
1419
+ var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'];
1420
+ var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'ttclid', 'twclid', 'wbraid'];
1421
+
1415
1422
  _.info = {
1416
- campaignParams: function() {
1417
- var campaign_keywords = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' '),
1418
- kw = '',
1423
+ campaignParams: function(default_value) {
1424
+ var kw = '',
1419
1425
  params = {};
1420
- _.each(campaign_keywords, function(kwkey) {
1426
+ _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
1421
1427
  kw = _.getQueryParam(document$1.URL, kwkey);
1422
1428
  if (kw.length) {
1423
1429
  params[kwkey] = kw;
1430
+ } else if (default_value !== undefined) {
1431
+ params[kwkey] = default_value;
1432
+ }
1433
+ });
1434
+
1435
+ return params;
1436
+ },
1437
+
1438
+ clickParams: function() {
1439
+ var id = '',
1440
+ params = {};
1441
+ _.each(CLICK_IDS, function(idkey) {
1442
+ id = _.getQueryParam(document$1.URL, idkey);
1443
+ if (id.length) {
1444
+ params[idkey] = id;
1424
1445
  }
1425
1446
  });
1426
1447
 
1427
1448
  return params;
1428
1449
  },
1429
1450
 
1451
+ marketingParams: function() {
1452
+ return _.extend(_.info.campaignParams(), _.info.clickParams());
1453
+ },
1454
+
1430
1455
  searchEngine: function(referrer) {
1431
1456
  if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
1432
1457
  return 'google';
@@ -1623,12 +1648,13 @@ define(function () { 'use strict';
1623
1648
  });
1624
1649
  },
1625
1650
 
1626
- pageviewInfo: function(page) {
1651
+ mpPageViewProperties: function() {
1627
1652
  return _.strip_empty_properties({
1628
- 'mp_page': page,
1629
- 'mp_referrer': document$1.referrer,
1630
- 'mp_browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
1631
- 'mp_platform': _.info.os()
1653
+ 'current_page_title': document$1.title,
1654
+ 'current_domain': window$1.location.hostname,
1655
+ 'current_url_path': window$1.location.pathname,
1656
+ 'current_url_protocol': window$1.location.protocol,
1657
+ 'current_url_search': window$1.location.search
1632
1658
  });
1633
1659
  }
1634
1660
  };
@@ -3806,13 +3832,6 @@ define(function () { 'use strict';
3806
3832
  }
3807
3833
  };
3808
3834
 
3809
- MixpanelPersistence.prototype.update_campaign_params = function() {
3810
- if (!this.campaign_params_saved) {
3811
- this.register_once(_.info.campaignParams());
3812
- this.campaign_params_saved = true;
3813
- }
3814
- };
3815
-
3816
3835
  MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
3817
3836
  this.register(_.info.searchInfo(referrer));
3818
3837
  };
@@ -4137,6 +4156,9 @@ define(function () { 'use strict';
4137
4156
  'cookie_domain': '',
4138
4157
  'cookie_name': '',
4139
4158
  'loaded': NOOP_FUNC,
4159
+ 'track_marketing': true,
4160
+ 'track_pageview': false,
4161
+ 'skip_first_touch_marketing': false,
4140
4162
  'store_google': true,
4141
4163
  'save_referrer': true,
4142
4164
  'test': false,
@@ -4203,6 +4225,25 @@ define(function () { 'use strict';
4203
4225
  instance['people'] = new MixpanelPeople();
4204
4226
  instance['people']._init(instance);
4205
4227
 
4228
+ if (!instance.get_config('skip_first_touch_marketing')) {
4229
+ // We need null UTM params in the object because
4230
+ // UTM parameters act as a tuple. If any UTM param
4231
+ // is present, then we set all UTM params including
4232
+ // empty ones together
4233
+ var utm_params = _.info.campaignParams(null);
4234
+ var initial_utm_params = {};
4235
+ var has_utm = false;
4236
+ _.each(utm_params, function(utm_value, utm_key) {
4237
+ initial_utm_params['initial_' + utm_key] = utm_value;
4238
+ if (utm_value) {
4239
+ has_utm = true;
4240
+ }
4241
+ });
4242
+ if (has_utm) {
4243
+ instance['people'].set_once(initial_utm_params);
4244
+ }
4245
+ }
4246
+
4206
4247
  // if any instance on the page has debug = true, we set the
4207
4248
  // global debug to be true
4208
4249
  Config.DEBUG = Config.DEBUG || instance.get_config('debug');
@@ -4234,7 +4275,7 @@ define(function () { 'use strict';
4234
4275
  * mixpanel.library_name.track(...);
4235
4276
  *
4236
4277
  * @param {String} token Your Mixpanel API token
4237
- * @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/8b2e1f7b/src/mixpanel-core.js#L87-L110">See a list of default config options</a>.
4278
+ * @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>.
4238
4279
  * @param {String} [name] The name for the new mixpanel instance that you want created
4239
4280
  */
4240
4281
  MixpanelLib.prototype.init = function (token, config, name) {
@@ -4272,7 +4313,7 @@ define(function () { 'use strict';
4272
4313
  // default to JSON payload for standard mixpanel.com API hosts
4273
4314
  if (!('api_payload_format' in config)) {
4274
4315
  var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
4275
- if (api_host.match(/\.mixpanel\.com$/)) {
4316
+ if (api_host.match(/\.mixpanel\.com/)) {
4276
4317
  variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
4277
4318
  }
4278
4319
  }
@@ -4347,6 +4388,10 @@ define(function () { 'use strict';
4347
4388
  '$device_id': uuid
4348
4389
  }, '');
4349
4390
  }
4391
+
4392
+ if (this.get_config('track_pageview')) {
4393
+ this.track_pageview();
4394
+ }
4350
4395
  };
4351
4396
 
4352
4397
  // Private methods
@@ -4360,7 +4405,7 @@ define(function () { 'use strict';
4360
4405
  MixpanelLib.prototype._set_default_superprops = function() {
4361
4406
  this['persistence'].update_search_keyword(document$1.referrer);
4362
4407
  if (this.get_config('store_google')) {
4363
- this['persistence'].update_campaign_params();
4408
+ this.register(_.info.campaignParams(), {persistent: false});
4364
4409
  }
4365
4410
  if (this.get_config('save_referrer')) {
4366
4411
  this['persistence'].update_referrer_info(document$1.referrer);
@@ -4842,6 +4887,10 @@ define(function () { 'use strict';
4842
4887
 
4843
4888
  this._set_default_superprops();
4844
4889
 
4890
+ var marketing_properties = this.get_config('track_marketing')
4891
+ ? _.info.marketingParams()
4892
+ : {};
4893
+
4845
4894
  // note: extend writes to the first object, so lets make sure we
4846
4895
  // don't write to the persistence properties object and info
4847
4896
  // properties object by passing in a new object
@@ -4850,6 +4899,7 @@ define(function () { 'use strict';
4850
4899
  properties = _.extend(
4851
4900
  {},
4852
4901
  _.info.properties(),
4902
+ marketing_properties,
4853
4903
  this['persistence'].properties(),
4854
4904
  this.unpersisted_superprops,
4855
4905
  properties
@@ -5010,17 +5060,54 @@ define(function () { 'use strict';
5010
5060
  };
5011
5061
 
5012
5062
  /**
5013
- * Track mp_page_view event. This is now ignored by the server.
5063
+ * Track a default Mixpanel page view event, which includes extra default event properties to
5064
+ * improve page view data. The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
5065
+ * may be turned on for tracking page loads automatically.
5014
5066
  *
5015
- * @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
5016
- * @deprecated
5067
+ * ### Usage
5068
+ *
5069
+ * // track a default $mp_web_page_view event
5070
+ * mixpanel.track_pageview();
5071
+ *
5072
+ * // track a page view event with additional event properties
5073
+ * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
5074
+ *
5075
+ * // example approach to track page views on different page types as event properties
5076
+ * mixpanel.track_pageview({'page': 'pricing'});
5077
+ * mixpanel.track_pageview({'page': 'homepage'});
5078
+ *
5079
+ * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
5080
+ * // individual pages on the same site or product. Use cases for custom event_name may be page
5081
+ * // views on different products or internal applications that are considered completely separate
5082
+ * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
5083
+ *
5084
+ * @param {Object} [properties] An optional set of additional properties to send with the page view event
5085
+ * @param {Object} [options] Page view tracking options
5086
+ * @param {String} [options.event_name] - Alternate name for the tracking event
5087
+ * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
5088
+ * with the tracking payload sent to the API server is returned; otherwise false.
5017
5089
  */
5018
- MixpanelLib.prototype.track_pageview = function(page) {
5019
- if (_.isUndefined(page)) {
5020
- page = document$1.location.href;
5090
+ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
5091
+ if (typeof properties !== 'object') {
5092
+ properties = {};
5021
5093
  }
5022
- this.track('mp_page_view', _.info.pageviewInfo(page));
5023
- };
5094
+ options = options || {};
5095
+ var event_name = options['event_name'] || '$mp_web_page_view';
5096
+
5097
+ var default_page_properties = _.extend(
5098
+ _.info.mpPageViewProperties(),
5099
+ _.info.campaignParams(),
5100
+ _.info.clickParams()
5101
+ );
5102
+
5103
+ var event_properties = _.extend(
5104
+ {},
5105
+ default_page_properties,
5106
+ properties
5107
+ );
5108
+
5109
+ return this.track(event_name, event_properties);
5110
+ });
5024
5111
 
5025
5112
  /**
5026
5113
  * Track clicks on a set of document elements. Selector must be a
@@ -5516,10 +5603,20 @@ define(function () { 'use strict';
5516
5603
  * // secure, meaning they will only be transmitted over https
5517
5604
  * secure_cookie: false
5518
5605
  *
5606
+ * // disables enriching user profiles with first touch marketing data
5607
+ * skip_first_touch_marketing: false
5608
+ *
5519
5609
  * // the amount of time track_links will
5520
5610
  * // wait for Mixpanel's servers to respond
5521
5611
  * track_links_timeout: 300
5522
5612
  *
5613
+ * // adds any UTM parameters and click IDs present on the page to any events fired
5614
+ * track_marketing: true
5615
+ *
5616
+ * // enables automatic page view tracking using default page view events through
5617
+ * // the track_pageview() method
5618
+ * track_pageview: false
5619
+ *
5523
5620
  * // if you set upgrade to be true, the library will check for
5524
5621
  * // a cookie from our old js library and import super
5525
5622
  * // properties from it, then the old cookie is deleted
@@ -2,7 +2,7 @@
2
2
 
3
3
  var Config = {
4
4
  DEBUG: false,
5
- LIB_VERSION: '2.46.0'
5
+ LIB_VERSION: '2.47.0'
6
6
  };
7
7
 
8
8
  // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -832,20 +832,24 @@ _.utf8Encode = function(string) {
832
832
 
833
833
  _.UUID = (function() {
834
834
 
835
- // Time/ticks information
836
- // 1*new Date() is a cross browser version of Date.now()
835
+ // Time-based entropy
837
836
  var T = function() {
838
- var d = 1 * new Date(),
839
- i = 0;
840
-
841
- // this while loop figures how many browser ticks go by
842
- // before 1*new Date() returns a new number, ie the amount
843
- // of ticks that go by per millisecond
844
- while (d == 1 * new Date()) {
845
- i++;
837
+ var time = 1 * new Date(); // cross-browser version of Date.now()
838
+ var ticks;
839
+ if (window$1.performance && window$1.performance.now) {
840
+ ticks = window$1.performance.now();
841
+ } else {
842
+ // fall back to busy loop
843
+ ticks = 0;
844
+
845
+ // this while loop figures how many browser ticks go by
846
+ // before 1*new Date() returns a new number, ie the amount
847
+ // of ticks that go by per millisecond
848
+ while (time == 1 * new Date()) {
849
+ ticks++;
850
+ }
846
851
  }
847
-
848
- return d.toString(16) + i.toString(16);
852
+ return time.toString(16) + Math.floor(ticks).toString(16);
849
853
  };
850
854
 
851
855
  // Math.Random entropy
@@ -1412,21 +1416,42 @@ _.dom_query = (function() {
1412
1416
  };
1413
1417
  })();
1414
1418
 
1419
+ var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'];
1420
+ var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'ttclid', 'twclid', 'wbraid'];
1421
+
1415
1422
  _.info = {
1416
- campaignParams: function() {
1417
- var campaign_keywords = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' '),
1418
- kw = '',
1423
+ campaignParams: function(default_value) {
1424
+ var kw = '',
1419
1425
  params = {};
1420
- _.each(campaign_keywords, function(kwkey) {
1426
+ _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
1421
1427
  kw = _.getQueryParam(document$1.URL, kwkey);
1422
1428
  if (kw.length) {
1423
1429
  params[kwkey] = kw;
1430
+ } else if (default_value !== undefined) {
1431
+ params[kwkey] = default_value;
1432
+ }
1433
+ });
1434
+
1435
+ return params;
1436
+ },
1437
+
1438
+ clickParams: function() {
1439
+ var id = '',
1440
+ params = {};
1441
+ _.each(CLICK_IDS, function(idkey) {
1442
+ id = _.getQueryParam(document$1.URL, idkey);
1443
+ if (id.length) {
1444
+ params[idkey] = id;
1424
1445
  }
1425
1446
  });
1426
1447
 
1427
1448
  return params;
1428
1449
  },
1429
1450
 
1451
+ marketingParams: function() {
1452
+ return _.extend(_.info.campaignParams(), _.info.clickParams());
1453
+ },
1454
+
1430
1455
  searchEngine: function(referrer) {
1431
1456
  if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
1432
1457
  return 'google';
@@ -1623,12 +1648,13 @@ _.info = {
1623
1648
  });
1624
1649
  },
1625
1650
 
1626
- pageviewInfo: function(page) {
1651
+ mpPageViewProperties: function() {
1627
1652
  return _.strip_empty_properties({
1628
- 'mp_page': page,
1629
- 'mp_referrer': document$1.referrer,
1630
- 'mp_browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
1631
- 'mp_platform': _.info.os()
1653
+ 'current_page_title': document$1.title,
1654
+ 'current_domain': window$1.location.hostname,
1655
+ 'current_url_path': window$1.location.pathname,
1656
+ 'current_url_protocol': window$1.location.protocol,
1657
+ 'current_url_search': window$1.location.search
1632
1658
  });
1633
1659
  }
1634
1660
  };
@@ -3806,13 +3832,6 @@ MixpanelPersistence.prototype.unregister = function(prop) {
3806
3832
  }
3807
3833
  };
3808
3834
 
3809
- MixpanelPersistence.prototype.update_campaign_params = function() {
3810
- if (!this.campaign_params_saved) {
3811
- this.register_once(_.info.campaignParams());
3812
- this.campaign_params_saved = true;
3813
- }
3814
- };
3815
-
3816
3835
  MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
3817
3836
  this.register(_.info.searchInfo(referrer));
3818
3837
  };
@@ -4137,6 +4156,9 @@ var DEFAULT_CONFIG = {
4137
4156
  'cookie_domain': '',
4138
4157
  'cookie_name': '',
4139
4158
  'loaded': NOOP_FUNC,
4159
+ 'track_marketing': true,
4160
+ 'track_pageview': false,
4161
+ 'skip_first_touch_marketing': false,
4140
4162
  'store_google': true,
4141
4163
  'save_referrer': true,
4142
4164
  'test': false,
@@ -4203,6 +4225,25 @@ var create_mplib = function(token, config, name) {
4203
4225
  instance['people'] = new MixpanelPeople();
4204
4226
  instance['people']._init(instance);
4205
4227
 
4228
+ if (!instance.get_config('skip_first_touch_marketing')) {
4229
+ // We need null UTM params in the object because
4230
+ // UTM parameters act as a tuple. If any UTM param
4231
+ // is present, then we set all UTM params including
4232
+ // empty ones together
4233
+ var utm_params = _.info.campaignParams(null);
4234
+ var initial_utm_params = {};
4235
+ var has_utm = false;
4236
+ _.each(utm_params, function(utm_value, utm_key) {
4237
+ initial_utm_params['initial_' + utm_key] = utm_value;
4238
+ if (utm_value) {
4239
+ has_utm = true;
4240
+ }
4241
+ });
4242
+ if (has_utm) {
4243
+ instance['people'].set_once(initial_utm_params);
4244
+ }
4245
+ }
4246
+
4206
4247
  // if any instance on the page has debug = true, we set the
4207
4248
  // global debug to be true
4208
4249
  Config.DEBUG = Config.DEBUG || instance.get_config('debug');
@@ -4234,7 +4275,7 @@ var create_mplib = function(token, config, name) {
4234
4275
  * mixpanel.library_name.track(...);
4235
4276
  *
4236
4277
  * @param {String} token Your Mixpanel API token
4237
- * @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/8b2e1f7b/src/mixpanel-core.js#L87-L110">See a list of default config options</a>.
4278
+ * @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>.
4238
4279
  * @param {String} [name] The name for the new mixpanel instance that you want created
4239
4280
  */
4240
4281
  MixpanelLib.prototype.init = function (token, config, name) {
@@ -4272,7 +4313,7 @@ MixpanelLib.prototype._init = function(token, config, name) {
4272
4313
  // default to JSON payload for standard mixpanel.com API hosts
4273
4314
  if (!('api_payload_format' in config)) {
4274
4315
  var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
4275
- if (api_host.match(/\.mixpanel\.com$/)) {
4316
+ if (api_host.match(/\.mixpanel\.com/)) {
4276
4317
  variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
4277
4318
  }
4278
4319
  }
@@ -4347,6 +4388,10 @@ MixpanelLib.prototype._init = function(token, config, name) {
4347
4388
  '$device_id': uuid
4348
4389
  }, '');
4349
4390
  }
4391
+
4392
+ if (this.get_config('track_pageview')) {
4393
+ this.track_pageview();
4394
+ }
4350
4395
  };
4351
4396
 
4352
4397
  // Private methods
@@ -4360,7 +4405,7 @@ MixpanelLib.prototype._loaded = function() {
4360
4405
  MixpanelLib.prototype._set_default_superprops = function() {
4361
4406
  this['persistence'].update_search_keyword(document$1.referrer);
4362
4407
  if (this.get_config('store_google')) {
4363
- this['persistence'].update_campaign_params();
4408
+ this.register(_.info.campaignParams(), {persistent: false});
4364
4409
  }
4365
4410
  if (this.get_config('save_referrer')) {
4366
4411
  this['persistence'].update_referrer_info(document$1.referrer);
@@ -4842,6 +4887,10 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
4842
4887
 
4843
4888
  this._set_default_superprops();
4844
4889
 
4890
+ var marketing_properties = this.get_config('track_marketing')
4891
+ ? _.info.marketingParams()
4892
+ : {};
4893
+
4845
4894
  // note: extend writes to the first object, so lets make sure we
4846
4895
  // don't write to the persistence properties object and info
4847
4896
  // properties object by passing in a new object
@@ -4850,6 +4899,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
4850
4899
  properties = _.extend(
4851
4900
  {},
4852
4901
  _.info.properties(),
4902
+ marketing_properties,
4853
4903
  this['persistence'].properties(),
4854
4904
  this.unpersisted_superprops,
4855
4905
  properties
@@ -5010,17 +5060,54 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
5010
5060
  };
5011
5061
 
5012
5062
  /**
5013
- * Track mp_page_view event. This is now ignored by the server.
5063
+ * Track a default Mixpanel page view event, which includes extra default event properties to
5064
+ * improve page view data. The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
5065
+ * may be turned on for tracking page loads automatically.
5014
5066
  *
5015
- * @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
5016
- * @deprecated
5067
+ * ### Usage
5068
+ *
5069
+ * // track a default $mp_web_page_view event
5070
+ * mixpanel.track_pageview();
5071
+ *
5072
+ * // track a page view event with additional event properties
5073
+ * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
5074
+ *
5075
+ * // example approach to track page views on different page types as event properties
5076
+ * mixpanel.track_pageview({'page': 'pricing'});
5077
+ * mixpanel.track_pageview({'page': 'homepage'});
5078
+ *
5079
+ * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
5080
+ * // individual pages on the same site or product. Use cases for custom event_name may be page
5081
+ * // views on different products or internal applications that are considered completely separate
5082
+ * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
5083
+ *
5084
+ * @param {Object} [properties] An optional set of additional properties to send with the page view event
5085
+ * @param {Object} [options] Page view tracking options
5086
+ * @param {String} [options.event_name] - Alternate name for the tracking event
5087
+ * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
5088
+ * with the tracking payload sent to the API server is returned; otherwise false.
5017
5089
  */
5018
- MixpanelLib.prototype.track_pageview = function(page) {
5019
- if (_.isUndefined(page)) {
5020
- page = document$1.location.href;
5090
+ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
5091
+ if (typeof properties !== 'object') {
5092
+ properties = {};
5021
5093
  }
5022
- this.track('mp_page_view', _.info.pageviewInfo(page));
5023
- };
5094
+ options = options || {};
5095
+ var event_name = options['event_name'] || '$mp_web_page_view';
5096
+
5097
+ var default_page_properties = _.extend(
5098
+ _.info.mpPageViewProperties(),
5099
+ _.info.campaignParams(),
5100
+ _.info.clickParams()
5101
+ );
5102
+
5103
+ var event_properties = _.extend(
5104
+ {},
5105
+ default_page_properties,
5106
+ properties
5107
+ );
5108
+
5109
+ return this.track(event_name, event_properties);
5110
+ });
5024
5111
 
5025
5112
  /**
5026
5113
  * Track clicks on a set of document elements. Selector must be a
@@ -5516,10 +5603,20 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
5516
5603
  * // secure, meaning they will only be transmitted over https
5517
5604
  * secure_cookie: false
5518
5605
  *
5606
+ * // disables enriching user profiles with first touch marketing data
5607
+ * skip_first_touch_marketing: false
5608
+ *
5519
5609
  * // the amount of time track_links will
5520
5610
  * // wait for Mixpanel's servers to respond
5521
5611
  * track_links_timeout: 300
5522
5612
  *
5613
+ * // adds any UTM parameters and click IDs present on the page to any events fired
5614
+ * track_marketing: true
5615
+ *
5616
+ * // enables automatic page view tracking using default page view events through
5617
+ * // the track_pageview() method
5618
+ * track_pageview: false
5619
+ *
5523
5620
  * // if you set upgrade to be true, the library will check for
5524
5621
  * // a cookie from our old js library and import super
5525
5622
  * // properties from it, then the old cookie is deleted