mixpanel-browser 2.48.1 → 2.49.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/.eslintignore +2 -0
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/build.sh +12 -8
- package/dist/mixpanel-js-wrapper.js +247 -0
- package/dist/mixpanel-js-wrapper.min.js +5 -0
- package/dist/mixpanel.amd.js +105 -17
- package/dist/mixpanel.cjs.js +105 -17
- package/dist/mixpanel.globals.js +105 -17
- package/dist/mixpanel.min.js +105 -102
- package/dist/mixpanel.umd.js +105 -17
- package/doc/readme.io/javascript-full-api-reference.md +107 -1
- package/package.json +1 -1
- package/src/config.js +1 -1
- package/src/loaders/loader-globals.js +4 -0
- package/src/{loader-module.js → loaders/loader-module.js} +1 -1
- package/src/loaders/mixpanel-js-wrapper.js +143 -0
- package/src/loaders/mixpanel-js-wrapper.md +114 -0
- package/src/mixpanel-core.js +93 -12
- package/src/mixpanel-people.js +0 -1
- package/src/utils.js +11 -3
- package/src/loader-globals.js +0 -4
- /package/{mixpanel-jslib-snippet.js → src/loaders/mixpanel-jslib-snippet.js} +0 -0
package/dist/mixpanel.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var Config = {
|
|
4
4
|
DEBUG: false,
|
|
5
|
-
LIB_VERSION: '2.
|
|
5
|
+
LIB_VERSION: '2.49.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
|
|
@@ -901,6 +901,7 @@ _.UUID = (function() {
|
|
|
901
901
|
// sending false tracking data
|
|
902
902
|
var BLOCKED_UA_STRS = [
|
|
903
903
|
'ahrefsbot',
|
|
904
|
+
'ahrefssiteaudit',
|
|
904
905
|
'baiduspider',
|
|
905
906
|
'bingbot',
|
|
906
907
|
'bingpreview',
|
|
@@ -1621,7 +1622,14 @@ _.info = {
|
|
|
1621
1622
|
return '';
|
|
1622
1623
|
},
|
|
1623
1624
|
|
|
1624
|
-
|
|
1625
|
+
currentUrl: function() {
|
|
1626
|
+
return window$1.location.href;
|
|
1627
|
+
},
|
|
1628
|
+
|
|
1629
|
+
properties: function(extra_props) {
|
|
1630
|
+
if (typeof extra_props !== 'object') {
|
|
1631
|
+
extra_props = {};
|
|
1632
|
+
}
|
|
1625
1633
|
return _.extend(_.strip_empty_properties({
|
|
1626
1634
|
'$os': _.info.os(),
|
|
1627
1635
|
'$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
|
|
@@ -1629,7 +1637,7 @@ _.info = {
|
|
|
1629
1637
|
'$referring_domain': _.info.referringDomain(document$1.referrer),
|
|
1630
1638
|
'$device': _.info.device(userAgent)
|
|
1631
1639
|
}), {
|
|
1632
|
-
'$current_url':
|
|
1640
|
+
'$current_url': _.info.currentUrl(),
|
|
1633
1641
|
'$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
|
|
1634
1642
|
'$screen_height': screen.height,
|
|
1635
1643
|
'$screen_width': screen.width,
|
|
@@ -1637,7 +1645,7 @@ _.info = {
|
|
|
1637
1645
|
'$lib_version': Config.LIB_VERSION,
|
|
1638
1646
|
'$insert_id': cheap_guid(),
|
|
1639
1647
|
'time': _.timestamp() / 1000 // epoch time in seconds
|
|
1640
|
-
});
|
|
1648
|
+
}, _.strip_empty_properties(extra_props));
|
|
1641
1649
|
},
|
|
1642
1650
|
|
|
1643
1651
|
people_properties: function() {
|
|
@@ -3203,7 +3211,6 @@ MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, c
|
|
|
3203
3211
|
data[SET_ACTION] = _.extend(
|
|
3204
3212
|
{},
|
|
3205
3213
|
_.info.people_properties(),
|
|
3206
|
-
this._mixpanel['persistence'].get_referrer_info(),
|
|
3207
3214
|
data[SET_ACTION]
|
|
3208
3215
|
);
|
|
3209
3216
|
return this._send_request(data, callback);
|
|
@@ -4163,10 +4170,12 @@ var DEFAULT_CONFIG = {
|
|
|
4163
4170
|
'cookie_domain': '',
|
|
4164
4171
|
'cookie_name': '',
|
|
4165
4172
|
'loaded': NOOP_FUNC,
|
|
4173
|
+
'mp_loader': null,
|
|
4166
4174
|
'track_marketing': true,
|
|
4167
4175
|
'track_pageview': false,
|
|
4168
4176
|
'skip_first_touch_marketing': false,
|
|
4169
4177
|
'store_google': true,
|
|
4178
|
+
'stop_utm_persistence': false,
|
|
4170
4179
|
'save_referrer': true,
|
|
4171
4180
|
'test': false,
|
|
4172
4181
|
'verbose': false,
|
|
@@ -4400,8 +4409,9 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
4400
4409
|
}, '');
|
|
4401
4410
|
}
|
|
4402
4411
|
|
|
4403
|
-
|
|
4404
|
-
|
|
4412
|
+
var track_pageview_option = this.get_config('track_pageview');
|
|
4413
|
+
if (track_pageview_option) {
|
|
4414
|
+
this._init_url_change_tracking(track_pageview_option);
|
|
4405
4415
|
}
|
|
4406
4416
|
};
|
|
4407
4417
|
|
|
@@ -4410,12 +4420,25 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
4410
4420
|
MixpanelLib.prototype._loaded = function() {
|
|
4411
4421
|
this.get_config('loaded')(this);
|
|
4412
4422
|
this._set_default_superprops();
|
|
4423
|
+
this['people'].set_once(this['persistence'].get_referrer_info());
|
|
4424
|
+
|
|
4425
|
+
// The original 'store_google' functionality will be deprecated and the config will be
|
|
4426
|
+
// used to clear previously managed UTM parameters from persistence.
|
|
4427
|
+
// stop_utm_persistence is `false` by default now but will be default `true` in the future.
|
|
4428
|
+
if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
|
|
4429
|
+
var utm_params = _.info.campaignParams(null);
|
|
4430
|
+
_.each(utm_params, function(_utm_value, utm_key) {
|
|
4431
|
+
// We need to unregister persisted UTM parameters so old values
|
|
4432
|
+
// are not mixed with the new UTM parameters
|
|
4433
|
+
this.unregister(utm_key);
|
|
4434
|
+
}.bind(this));
|
|
4435
|
+
}
|
|
4413
4436
|
};
|
|
4414
4437
|
|
|
4415
4438
|
// update persistence with info on referrer, UTM params, etc
|
|
4416
4439
|
MixpanelLib.prototype._set_default_superprops = function() {
|
|
4417
4440
|
this['persistence'].update_search_keyword(document$1.referrer);
|
|
4418
|
-
if (this.get_config('store_google')) {
|
|
4441
|
+
if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
|
|
4419
4442
|
this.register(_.info.campaignParams());
|
|
4420
4443
|
}
|
|
4421
4444
|
if (this.get_config('save_referrer')) {
|
|
@@ -4453,6 +4476,55 @@ MixpanelLib.prototype._track_dom = function(DomClass, args) {
|
|
|
4453
4476
|
return dt.track.apply(dt, args);
|
|
4454
4477
|
};
|
|
4455
4478
|
|
|
4479
|
+
MixpanelLib.prototype._init_url_change_tracking = function(track_pageview_option) {
|
|
4480
|
+
var previous_tracked_url = '';
|
|
4481
|
+
var tracked = this.track_pageview();
|
|
4482
|
+
if (tracked) {
|
|
4483
|
+
previous_tracked_url = _.info.currentUrl();
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
if (_.include(['full-url', 'url-with-path-and-query-string', 'url-with-path'], track_pageview_option)) {
|
|
4487
|
+
window$1.addEventListener('popstate', function() {
|
|
4488
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4489
|
+
});
|
|
4490
|
+
window$1.addEventListener('hashchange', function() {
|
|
4491
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4492
|
+
});
|
|
4493
|
+
var nativePushState = window$1.history.pushState;
|
|
4494
|
+
if (typeof nativePushState === 'function') {
|
|
4495
|
+
window$1.history.pushState = function(state, unused, url) {
|
|
4496
|
+
nativePushState.call(window$1.history, state, unused, url);
|
|
4497
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4498
|
+
};
|
|
4499
|
+
}
|
|
4500
|
+
var nativeReplaceState = window$1.history.replaceState;
|
|
4501
|
+
if (typeof nativeReplaceState === 'function') {
|
|
4502
|
+
window$1.history.replaceState = function(state, unused, url) {
|
|
4503
|
+
nativeReplaceState.call(window$1.history, state, unused, url);
|
|
4504
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4505
|
+
};
|
|
4506
|
+
}
|
|
4507
|
+
window$1.addEventListener('mp_locationchange', function() {
|
|
4508
|
+
var current_url = _.info.currentUrl();
|
|
4509
|
+
var should_track = false;
|
|
4510
|
+
if (track_pageview_option === 'full-url') {
|
|
4511
|
+
should_track = current_url !== previous_tracked_url;
|
|
4512
|
+
} else if (track_pageview_option === 'url-with-path-and-query-string') {
|
|
4513
|
+
should_track = current_url.split('#')[0] !== previous_tracked_url.split('#')[0];
|
|
4514
|
+
} else if (track_pageview_option === 'url-with-path') {
|
|
4515
|
+
should_track = current_url.split('#')[0].split('?')[0] !== previous_tracked_url.split('#')[0].split('?')[0];
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
if (should_track) {
|
|
4519
|
+
var tracked = this.track_pageview();
|
|
4520
|
+
if (tracked) {
|
|
4521
|
+
previous_tracked_url = current_url;
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
}.bind(this));
|
|
4525
|
+
}
|
|
4526
|
+
};
|
|
4527
|
+
|
|
4456
4528
|
/**
|
|
4457
4529
|
* _prepare_callback() should be called by callers of _send_request for use
|
|
4458
4530
|
* as the callback argument.
|
|
@@ -4921,7 +4993,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
4921
4993
|
// update properties with pageview info and super-properties
|
|
4922
4994
|
properties = _.extend(
|
|
4923
4995
|
{},
|
|
4924
|
-
_.info.properties(),
|
|
4996
|
+
_.info.properties({'mp_loader': this.get_config('mp_loader')}),
|
|
4925
4997
|
marketing_properties,
|
|
4926
4998
|
this['persistence'].properties(),
|
|
4927
4999
|
this.unpersisted_superprops,
|
|
@@ -5085,10 +5157,9 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
5085
5157
|
|
|
5086
5158
|
/**
|
|
5087
5159
|
* Track a default Mixpanel page view event, which includes extra default event properties to
|
|
5088
|
-
* improve page view data.
|
|
5089
|
-
* may be turned on for tracking page loads automatically.
|
|
5160
|
+
* improve page view data.
|
|
5090
5161
|
*
|
|
5091
|
-
* ### Usage
|
|
5162
|
+
* ### Usage:
|
|
5092
5163
|
*
|
|
5093
5164
|
* // track a default $mp_web_page_view event
|
|
5094
5165
|
* mixpanel.track_pageview();
|
|
@@ -5105,6 +5176,23 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
5105
5176
|
* // views on different products or internal applications that are considered completely separate
|
|
5106
5177
|
* mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
|
|
5107
5178
|
*
|
|
5179
|
+
* ### Notes:
|
|
5180
|
+
*
|
|
5181
|
+
* The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
|
|
5182
|
+
* may be turned on for tracking page loads automatically.
|
|
5183
|
+
*
|
|
5184
|
+
* // track only page loads
|
|
5185
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
|
|
5186
|
+
*
|
|
5187
|
+
* // track when the URL changes in any manner
|
|
5188
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
|
|
5189
|
+
*
|
|
5190
|
+
* // track when the URL changes, ignoring any changes in the hash part
|
|
5191
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
|
|
5192
|
+
*
|
|
5193
|
+
* // track when the path changes, ignoring any query parameter or hash changes
|
|
5194
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
|
|
5195
|
+
*
|
|
5108
5196
|
* @param {Object} [properties] An optional set of additional properties to send with the page view event
|
|
5109
5197
|
* @param {Object} [options] Page view tracking options
|
|
5110
5198
|
* @param {String} [options.event_name] - Alternate name for the tracking event
|
|
@@ -5855,7 +5943,7 @@ MixpanelLib.prototype._gdpr_call_func = function(func, options) {
|
|
|
5855
5943
|
/**
|
|
5856
5944
|
* Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
5857
5945
|
*
|
|
5858
|
-
* ### Usage
|
|
5946
|
+
* ### Usage:
|
|
5859
5947
|
*
|
|
5860
5948
|
* // opt user in
|
|
5861
5949
|
* mixpanel.opt_in_tracking();
|
|
@@ -5895,7 +5983,7 @@ MixpanelLib.prototype.opt_in_tracking = function(options) {
|
|
|
5895
5983
|
/**
|
|
5896
5984
|
* Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
5897
5985
|
*
|
|
5898
|
-
* ### Usage
|
|
5986
|
+
* ### Usage:
|
|
5899
5987
|
*
|
|
5900
5988
|
* // opt user out
|
|
5901
5989
|
* mixpanel.opt_out_tracking();
|
|
@@ -5936,7 +6024,7 @@ MixpanelLib.prototype.opt_out_tracking = function(options) {
|
|
|
5936
6024
|
/**
|
|
5937
6025
|
* Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
5938
6026
|
*
|
|
5939
|
-
* ### Usage
|
|
6027
|
+
* ### Usage:
|
|
5940
6028
|
*
|
|
5941
6029
|
* var has_opted_in = mixpanel.has_opted_in_tracking();
|
|
5942
6030
|
* // use has_opted_in value
|
|
@@ -5953,7 +6041,7 @@ MixpanelLib.prototype.has_opted_in_tracking = function(options) {
|
|
|
5953
6041
|
/**
|
|
5954
6042
|
* Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
5955
6043
|
*
|
|
5956
|
-
* ### Usage
|
|
6044
|
+
* ### Usage:
|
|
5957
6045
|
*
|
|
5958
6046
|
* var has_opted_out = mixpanel.has_opted_out_tracking();
|
|
5959
6047
|
* // use has_opted_out value
|
|
@@ -5970,7 +6058,7 @@ MixpanelLib.prototype.has_opted_out_tracking = function(options) {
|
|
|
5970
6058
|
/**
|
|
5971
6059
|
* Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
|
|
5972
6060
|
*
|
|
5973
|
-
* ### Usage
|
|
6061
|
+
* ### Usage:
|
|
5974
6062
|
*
|
|
5975
6063
|
* // clear user's opt-in/out status
|
|
5976
6064
|
* mixpanel.clear_opt_in_out_tracking();
|
package/dist/mixpanel.globals.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var Config = {
|
|
5
5
|
DEBUG: false,
|
|
6
|
-
LIB_VERSION: '2.
|
|
6
|
+
LIB_VERSION: '2.49.0'
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
@@ -902,6 +902,7 @@
|
|
|
902
902
|
// sending false tracking data
|
|
903
903
|
var BLOCKED_UA_STRS = [
|
|
904
904
|
'ahrefsbot',
|
|
905
|
+
'ahrefssiteaudit',
|
|
905
906
|
'baiduspider',
|
|
906
907
|
'bingbot',
|
|
907
908
|
'bingpreview',
|
|
@@ -1622,7 +1623,14 @@
|
|
|
1622
1623
|
return '';
|
|
1623
1624
|
},
|
|
1624
1625
|
|
|
1625
|
-
|
|
1626
|
+
currentUrl: function() {
|
|
1627
|
+
return window$1.location.href;
|
|
1628
|
+
},
|
|
1629
|
+
|
|
1630
|
+
properties: function(extra_props) {
|
|
1631
|
+
if (typeof extra_props !== 'object') {
|
|
1632
|
+
extra_props = {};
|
|
1633
|
+
}
|
|
1626
1634
|
return _.extend(_.strip_empty_properties({
|
|
1627
1635
|
'$os': _.info.os(),
|
|
1628
1636
|
'$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
|
|
@@ -1630,7 +1638,7 @@
|
|
|
1630
1638
|
'$referring_domain': _.info.referringDomain(document$1.referrer),
|
|
1631
1639
|
'$device': _.info.device(userAgent)
|
|
1632
1640
|
}), {
|
|
1633
|
-
'$current_url':
|
|
1641
|
+
'$current_url': _.info.currentUrl(),
|
|
1634
1642
|
'$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
|
|
1635
1643
|
'$screen_height': screen.height,
|
|
1636
1644
|
'$screen_width': screen.width,
|
|
@@ -1638,7 +1646,7 @@
|
|
|
1638
1646
|
'$lib_version': Config.LIB_VERSION,
|
|
1639
1647
|
'$insert_id': cheap_guid(),
|
|
1640
1648
|
'time': _.timestamp() / 1000 // epoch time in seconds
|
|
1641
|
-
});
|
|
1649
|
+
}, _.strip_empty_properties(extra_props));
|
|
1642
1650
|
},
|
|
1643
1651
|
|
|
1644
1652
|
people_properties: function() {
|
|
@@ -3204,7 +3212,6 @@
|
|
|
3204
3212
|
data[SET_ACTION] = _.extend(
|
|
3205
3213
|
{},
|
|
3206
3214
|
_.info.people_properties(),
|
|
3207
|
-
this._mixpanel['persistence'].get_referrer_info(),
|
|
3208
3215
|
data[SET_ACTION]
|
|
3209
3216
|
);
|
|
3210
3217
|
return this._send_request(data, callback);
|
|
@@ -4164,10 +4171,12 @@
|
|
|
4164
4171
|
'cookie_domain': '',
|
|
4165
4172
|
'cookie_name': '',
|
|
4166
4173
|
'loaded': NOOP_FUNC,
|
|
4174
|
+
'mp_loader': null,
|
|
4167
4175
|
'track_marketing': true,
|
|
4168
4176
|
'track_pageview': false,
|
|
4169
4177
|
'skip_first_touch_marketing': false,
|
|
4170
4178
|
'store_google': true,
|
|
4179
|
+
'stop_utm_persistence': false,
|
|
4171
4180
|
'save_referrer': true,
|
|
4172
4181
|
'test': false,
|
|
4173
4182
|
'verbose': false,
|
|
@@ -4401,8 +4410,9 @@
|
|
|
4401
4410
|
}, '');
|
|
4402
4411
|
}
|
|
4403
4412
|
|
|
4404
|
-
|
|
4405
|
-
|
|
4413
|
+
var track_pageview_option = this.get_config('track_pageview');
|
|
4414
|
+
if (track_pageview_option) {
|
|
4415
|
+
this._init_url_change_tracking(track_pageview_option);
|
|
4406
4416
|
}
|
|
4407
4417
|
};
|
|
4408
4418
|
|
|
@@ -4411,12 +4421,25 @@
|
|
|
4411
4421
|
MixpanelLib.prototype._loaded = function() {
|
|
4412
4422
|
this.get_config('loaded')(this);
|
|
4413
4423
|
this._set_default_superprops();
|
|
4424
|
+
this['people'].set_once(this['persistence'].get_referrer_info());
|
|
4425
|
+
|
|
4426
|
+
// The original 'store_google' functionality will be deprecated and the config will be
|
|
4427
|
+
// used to clear previously managed UTM parameters from persistence.
|
|
4428
|
+
// stop_utm_persistence is `false` by default now but will be default `true` in the future.
|
|
4429
|
+
if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
|
|
4430
|
+
var utm_params = _.info.campaignParams(null);
|
|
4431
|
+
_.each(utm_params, function(_utm_value, utm_key) {
|
|
4432
|
+
// We need to unregister persisted UTM parameters so old values
|
|
4433
|
+
// are not mixed with the new UTM parameters
|
|
4434
|
+
this.unregister(utm_key);
|
|
4435
|
+
}.bind(this));
|
|
4436
|
+
}
|
|
4414
4437
|
};
|
|
4415
4438
|
|
|
4416
4439
|
// update persistence with info on referrer, UTM params, etc
|
|
4417
4440
|
MixpanelLib.prototype._set_default_superprops = function() {
|
|
4418
4441
|
this['persistence'].update_search_keyword(document$1.referrer);
|
|
4419
|
-
if (this.get_config('store_google')) {
|
|
4442
|
+
if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
|
|
4420
4443
|
this.register(_.info.campaignParams());
|
|
4421
4444
|
}
|
|
4422
4445
|
if (this.get_config('save_referrer')) {
|
|
@@ -4454,6 +4477,55 @@
|
|
|
4454
4477
|
return dt.track.apply(dt, args);
|
|
4455
4478
|
};
|
|
4456
4479
|
|
|
4480
|
+
MixpanelLib.prototype._init_url_change_tracking = function(track_pageview_option) {
|
|
4481
|
+
var previous_tracked_url = '';
|
|
4482
|
+
var tracked = this.track_pageview();
|
|
4483
|
+
if (tracked) {
|
|
4484
|
+
previous_tracked_url = _.info.currentUrl();
|
|
4485
|
+
}
|
|
4486
|
+
|
|
4487
|
+
if (_.include(['full-url', 'url-with-path-and-query-string', 'url-with-path'], track_pageview_option)) {
|
|
4488
|
+
window$1.addEventListener('popstate', function() {
|
|
4489
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4490
|
+
});
|
|
4491
|
+
window$1.addEventListener('hashchange', function() {
|
|
4492
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4493
|
+
});
|
|
4494
|
+
var nativePushState = window$1.history.pushState;
|
|
4495
|
+
if (typeof nativePushState === 'function') {
|
|
4496
|
+
window$1.history.pushState = function(state, unused, url) {
|
|
4497
|
+
nativePushState.call(window$1.history, state, unused, url);
|
|
4498
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4499
|
+
};
|
|
4500
|
+
}
|
|
4501
|
+
var nativeReplaceState = window$1.history.replaceState;
|
|
4502
|
+
if (typeof nativeReplaceState === 'function') {
|
|
4503
|
+
window$1.history.replaceState = function(state, unused, url) {
|
|
4504
|
+
nativeReplaceState.call(window$1.history, state, unused, url);
|
|
4505
|
+
window$1.dispatchEvent(new Event('mp_locationchange'));
|
|
4506
|
+
};
|
|
4507
|
+
}
|
|
4508
|
+
window$1.addEventListener('mp_locationchange', function() {
|
|
4509
|
+
var current_url = _.info.currentUrl();
|
|
4510
|
+
var should_track = false;
|
|
4511
|
+
if (track_pageview_option === 'full-url') {
|
|
4512
|
+
should_track = current_url !== previous_tracked_url;
|
|
4513
|
+
} else if (track_pageview_option === 'url-with-path-and-query-string') {
|
|
4514
|
+
should_track = current_url.split('#')[0] !== previous_tracked_url.split('#')[0];
|
|
4515
|
+
} else if (track_pageview_option === 'url-with-path') {
|
|
4516
|
+
should_track = current_url.split('#')[0].split('?')[0] !== previous_tracked_url.split('#')[0].split('?')[0];
|
|
4517
|
+
}
|
|
4518
|
+
|
|
4519
|
+
if (should_track) {
|
|
4520
|
+
var tracked = this.track_pageview();
|
|
4521
|
+
if (tracked) {
|
|
4522
|
+
previous_tracked_url = current_url;
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
}.bind(this));
|
|
4526
|
+
}
|
|
4527
|
+
};
|
|
4528
|
+
|
|
4457
4529
|
/**
|
|
4458
4530
|
* _prepare_callback() should be called by callers of _send_request for use
|
|
4459
4531
|
* as the callback argument.
|
|
@@ -4922,7 +4994,7 @@
|
|
|
4922
4994
|
// update properties with pageview info and super-properties
|
|
4923
4995
|
properties = _.extend(
|
|
4924
4996
|
{},
|
|
4925
|
-
_.info.properties(),
|
|
4997
|
+
_.info.properties({'mp_loader': this.get_config('mp_loader')}),
|
|
4926
4998
|
marketing_properties,
|
|
4927
4999
|
this['persistence'].properties(),
|
|
4928
5000
|
this.unpersisted_superprops,
|
|
@@ -5086,10 +5158,9 @@
|
|
|
5086
5158
|
|
|
5087
5159
|
/**
|
|
5088
5160
|
* Track a default Mixpanel page view event, which includes extra default event properties to
|
|
5089
|
-
* improve page view data.
|
|
5090
|
-
* may be turned on for tracking page loads automatically.
|
|
5161
|
+
* improve page view data.
|
|
5091
5162
|
*
|
|
5092
|
-
* ### Usage
|
|
5163
|
+
* ### Usage:
|
|
5093
5164
|
*
|
|
5094
5165
|
* // track a default $mp_web_page_view event
|
|
5095
5166
|
* mixpanel.track_pageview();
|
|
@@ -5106,6 +5177,23 @@
|
|
|
5106
5177
|
* // views on different products or internal applications that are considered completely separate
|
|
5107
5178
|
* mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
|
|
5108
5179
|
*
|
|
5180
|
+
* ### Notes:
|
|
5181
|
+
*
|
|
5182
|
+
* The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
|
|
5183
|
+
* may be turned on for tracking page loads automatically.
|
|
5184
|
+
*
|
|
5185
|
+
* // track only page loads
|
|
5186
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
|
|
5187
|
+
*
|
|
5188
|
+
* // track when the URL changes in any manner
|
|
5189
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
|
|
5190
|
+
*
|
|
5191
|
+
* // track when the URL changes, ignoring any changes in the hash part
|
|
5192
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
|
|
5193
|
+
*
|
|
5194
|
+
* // track when the path changes, ignoring any query parameter or hash changes
|
|
5195
|
+
* mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
|
|
5196
|
+
*
|
|
5109
5197
|
* @param {Object} [properties] An optional set of additional properties to send with the page view event
|
|
5110
5198
|
* @param {Object} [options] Page view tracking options
|
|
5111
5199
|
* @param {String} [options.event_name] - Alternate name for the tracking event
|
|
@@ -5856,7 +5944,7 @@
|
|
|
5856
5944
|
/**
|
|
5857
5945
|
* Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
5858
5946
|
*
|
|
5859
|
-
* ### Usage
|
|
5947
|
+
* ### Usage:
|
|
5860
5948
|
*
|
|
5861
5949
|
* // opt user in
|
|
5862
5950
|
* mixpanel.opt_in_tracking();
|
|
@@ -5896,7 +5984,7 @@
|
|
|
5896
5984
|
/**
|
|
5897
5985
|
* Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
5898
5986
|
*
|
|
5899
|
-
* ### Usage
|
|
5987
|
+
* ### Usage:
|
|
5900
5988
|
*
|
|
5901
5989
|
* // opt user out
|
|
5902
5990
|
* mixpanel.opt_out_tracking();
|
|
@@ -5937,7 +6025,7 @@
|
|
|
5937
6025
|
/**
|
|
5938
6026
|
* Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
5939
6027
|
*
|
|
5940
|
-
* ### Usage
|
|
6028
|
+
* ### Usage:
|
|
5941
6029
|
*
|
|
5942
6030
|
* var has_opted_in = mixpanel.has_opted_in_tracking();
|
|
5943
6031
|
* // use has_opted_in value
|
|
@@ -5954,7 +6042,7 @@
|
|
|
5954
6042
|
/**
|
|
5955
6043
|
* Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
5956
6044
|
*
|
|
5957
|
-
* ### Usage
|
|
6045
|
+
* ### Usage:
|
|
5958
6046
|
*
|
|
5959
6047
|
* var has_opted_out = mixpanel.has_opted_out_tracking();
|
|
5960
6048
|
* // use has_opted_out value
|
|
@@ -5971,7 +6059,7 @@
|
|
|
5971
6059
|
/**
|
|
5972
6060
|
* Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
|
|
5973
6061
|
*
|
|
5974
|
-
* ### Usage
|
|
6062
|
+
* ### Usage:
|
|
5975
6063
|
*
|
|
5976
6064
|
* // clear user's opt-in/out status
|
|
5977
6065
|
* mixpanel.clear_opt_in_out_tracking();
|