mixpanel-browser 2.49.0 → 2.51.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 +9 -10
- package/build.sh +2 -1
- package/dist/mixpanel-js-wrapper.js +3 -3
- package/dist/mixpanel-js-wrapper.min.js +1 -1
- package/dist/mixpanel-jslib-snippet.min.js +1 -1
- package/dist/mixpanel-jslib-snippet.min.test.js +1 -1
- package/dist/mixpanel-recorder.js +6499 -0
- package/dist/mixpanel-recorder.min.js +38 -0
- package/dist/mixpanel.amd.js +200 -143
- package/dist/mixpanel.cjs.js +199 -142
- package/dist/mixpanel.globals.js +200 -143
- package/dist/mixpanel.min.js +110 -108
- package/dist/mixpanel.umd.js +201 -144
- package/package.json +7 -2
- package/src/config.js +1 -1
- package/src/loaders/mixpanel-jslib-snippet.js +1 -1
- package/src/mixpanel-core.js +98 -39
- package/src/mixpanel-persistence.js +14 -43
- package/src/recorder/index.js +156 -0
- package/src/recorder/rollup.config.js +19 -0
- package/src/utils.js +4 -0
package/dist/mixpanel.globals.js
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
var Config = {
|
|
5
5
|
DEBUG: false,
|
|
6
|
-
LIB_VERSION: '2.
|
|
6
|
+
LIB_VERSION: '2.51.0'
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
10
|
+
|
|
9
11
|
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
10
|
-
var
|
|
12
|
+
var win;
|
|
11
13
|
if (typeof(window) === 'undefined') {
|
|
12
14
|
var loc = {
|
|
13
15
|
hostname: ''
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
win = {
|
|
16
18
|
navigator: { userAgent: '' },
|
|
17
19
|
document: {
|
|
18
20
|
location: loc,
|
|
@@ -22,32 +24,37 @@
|
|
|
22
24
|
location: loc
|
|
23
25
|
};
|
|
24
26
|
} else {
|
|
25
|
-
|
|
27
|
+
win = window;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
// Maximum allowed session recording length
|
|
31
|
+
var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
32
|
+
|
|
28
33
|
/*
|
|
29
34
|
* Saved references to long variable names, so that closure compiler can
|
|
30
35
|
* minimize file size.
|
|
31
36
|
*/
|
|
32
37
|
|
|
33
|
-
var ArrayProto = Array.prototype
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
var ArrayProto = Array.prototype,
|
|
39
|
+
FuncProto = Function.prototype,
|
|
40
|
+
ObjProto = Object.prototype,
|
|
41
|
+
slice = ArrayProto.slice,
|
|
42
|
+
toString = ObjProto.toString,
|
|
43
|
+
hasOwnProperty = ObjProto.hasOwnProperty,
|
|
44
|
+
windowConsole = win.console,
|
|
45
|
+
navigator = win.navigator,
|
|
46
|
+
document$1 = win.document,
|
|
47
|
+
windowOpera = win.opera,
|
|
48
|
+
screen = win.screen,
|
|
49
|
+
userAgent = navigator.userAgent;
|
|
50
|
+
|
|
51
|
+
var nativeBind = FuncProto.bind,
|
|
52
|
+
nativeForEach = ArrayProto.forEach,
|
|
53
|
+
nativeIndexOf = ArrayProto.indexOf,
|
|
54
|
+
nativeMap = ArrayProto.map,
|
|
55
|
+
nativeIsArray = Array.isArray,
|
|
56
|
+
breaker = {};
|
|
57
|
+
|
|
51
58
|
var _ = {
|
|
52
59
|
trim: function(str) {
|
|
53
60
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
@@ -837,8 +844,8 @@
|
|
|
837
844
|
var T = function() {
|
|
838
845
|
var time = 1 * new Date(); // cross-browser version of Date.now()
|
|
839
846
|
var ticks;
|
|
840
|
-
if (
|
|
841
|
-
ticks =
|
|
847
|
+
if (win.performance && win.performance.now) {
|
|
848
|
+
ticks = win.performance.now();
|
|
842
849
|
} else {
|
|
843
850
|
// fall back to busy loop
|
|
844
851
|
ticks = 0;
|
|
@@ -1624,7 +1631,7 @@
|
|
|
1624
1631
|
},
|
|
1625
1632
|
|
|
1626
1633
|
currentUrl: function() {
|
|
1627
|
-
return
|
|
1634
|
+
return win.location.href;
|
|
1628
1635
|
},
|
|
1629
1636
|
|
|
1630
1637
|
properties: function(extra_props) {
|
|
@@ -1661,10 +1668,10 @@
|
|
|
1661
1668
|
mpPageViewProperties: function() {
|
|
1662
1669
|
return _.strip_empty_properties({
|
|
1663
1670
|
'current_page_title': document$1.title,
|
|
1664
|
-
'current_domain':
|
|
1665
|
-
'current_url_path':
|
|
1666
|
-
'current_url_protocol':
|
|
1667
|
-
'current_url_search':
|
|
1671
|
+
'current_domain': win.location.hostname,
|
|
1672
|
+
'current_url_path': win.location.pathname,
|
|
1673
|
+
'current_url_protocol': win.location.protocol,
|
|
1674
|
+
'current_url_search': win.location.search
|
|
1668
1675
|
});
|
|
1669
1676
|
}
|
|
1670
1677
|
};
|
|
@@ -1702,8 +1709,7 @@
|
|
|
1702
1709
|
return matches ? matches[0] : '';
|
|
1703
1710
|
};
|
|
1704
1711
|
|
|
1705
|
-
var JSONStringify = null;
|
|
1706
|
-
var JSONParse = null;
|
|
1712
|
+
var JSONStringify = null, JSONParse = null;
|
|
1707
1713
|
if (typeof JSON !== 'undefined') {
|
|
1708
1714
|
JSONStringify = JSON.stringify;
|
|
1709
1715
|
JSONParse = JSON.parse;
|
|
@@ -1724,6 +1730,8 @@
|
|
|
1724
1730
|
_['info']['browserVersion'] = _.info.browserVersion;
|
|
1725
1731
|
_['info']['properties'] = _.info.properties;
|
|
1726
1732
|
|
|
1733
|
+
/* eslint camelcase: "off" */
|
|
1734
|
+
|
|
1727
1735
|
/**
|
|
1728
1736
|
* DomTracker Object
|
|
1729
1737
|
* @constructor
|
|
@@ -1873,8 +1881,6 @@
|
|
|
1873
1881
|
}, 0);
|
|
1874
1882
|
};
|
|
1875
1883
|
|
|
1876
|
-
// eslint-disable-line camelcase
|
|
1877
|
-
|
|
1878
1884
|
var logger$2 = console_with_prefix('lock');
|
|
1879
1885
|
|
|
1880
1886
|
/**
|
|
@@ -2021,8 +2027,6 @@
|
|
|
2021
2027
|
}
|
|
2022
2028
|
};
|
|
2023
2029
|
|
|
2024
|
-
// eslint-disable-line camelcase
|
|
2025
|
-
|
|
2026
2030
|
var logger$1 = console_with_prefix('batch');
|
|
2027
2031
|
|
|
2028
2032
|
/**
|
|
@@ -2300,8 +2304,6 @@
|
|
|
2300
2304
|
this.storage.removeItem(this.storageKey);
|
|
2301
2305
|
};
|
|
2302
2306
|
|
|
2303
|
-
// eslint-disable-line camelcase
|
|
2304
|
-
|
|
2305
2307
|
// maximum interval between request retries after exponential backoff
|
|
2306
2308
|
var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
|
|
2307
2309
|
|
|
@@ -2596,6 +2598,19 @@
|
|
|
2596
2598
|
}
|
|
2597
2599
|
};
|
|
2598
2600
|
|
|
2601
|
+
/**
|
|
2602
|
+
* GDPR utils
|
|
2603
|
+
*
|
|
2604
|
+
* The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
|
|
2605
|
+
* and privacy for all individuals within the European Union. It addresses the export of personal
|
|
2606
|
+
* data outside the EU. The GDPR aims primarily to give control back to citizens and residents
|
|
2607
|
+
* over their personal data and to simplify the regulatory environment for international business
|
|
2608
|
+
* by unifying the regulation within the EU.
|
|
2609
|
+
*
|
|
2610
|
+
* This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
|
|
2611
|
+
* These functions are used internally by the SDK and are not intended to be publicly exposed.
|
|
2612
|
+
*/
|
|
2613
|
+
|
|
2599
2614
|
/**
|
|
2600
2615
|
* A function used to track a Mixpanel event (e.g. MixpanelLib.track)
|
|
2601
2616
|
* @callback trackFunction
|
|
@@ -2781,14 +2796,14 @@
|
|
|
2781
2796
|
if (options && options.ignoreDnt) {
|
|
2782
2797
|
return false;
|
|
2783
2798
|
}
|
|
2784
|
-
var win = (options && options.window) ||
|
|
2785
|
-
var nav = win['navigator'] || {};
|
|
2799
|
+
var win$1 = (options && options.window) || win;
|
|
2800
|
+
var nav = win$1['navigator'] || {};
|
|
2786
2801
|
var hasDntOn = false;
|
|
2787
2802
|
|
|
2788
2803
|
_.each([
|
|
2789
2804
|
nav['doNotTrack'], // standard
|
|
2790
2805
|
nav['msDoNotTrack'],
|
|
2791
|
-
win['doNotTrack']
|
|
2806
|
+
win$1['doNotTrack']
|
|
2792
2807
|
], function(dntValue) {
|
|
2793
2808
|
if (_.includes([true, 1, '1', 'yes'], dntValue)) {
|
|
2794
2809
|
hasDntOn = true;
|
|
@@ -2882,6 +2897,8 @@
|
|
|
2882
2897
|
};
|
|
2883
2898
|
}
|
|
2884
2899
|
|
|
2900
|
+
/* eslint camelcase: "off" */
|
|
2901
|
+
|
|
2885
2902
|
/** @const */ var SET_ACTION = '$set';
|
|
2886
2903
|
/** @const */ var SET_ONCE_ACTION = '$set_once';
|
|
2887
2904
|
/** @const */ var UNSET_ACTION = '$unset';
|
|
@@ -2999,6 +3016,8 @@
|
|
|
2999
3016
|
}
|
|
3000
3017
|
};
|
|
3001
3018
|
|
|
3019
|
+
/* eslint camelcase: "off" */
|
|
3020
|
+
|
|
3002
3021
|
/**
|
|
3003
3022
|
* Mixpanel Group Object
|
|
3004
3023
|
* @constructor
|
|
@@ -3167,6 +3186,8 @@
|
|
|
3167
3186
|
MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
|
|
3168
3187
|
MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
|
|
3169
3188
|
|
|
3189
|
+
/* eslint camelcase: "off" */
|
|
3190
|
+
|
|
3170
3191
|
/**
|
|
3171
3192
|
* Mixpanel People Object
|
|
3172
3193
|
* @constructor
|
|
@@ -3635,6 +3656,8 @@
|
|
|
3635
3656
|
MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
|
|
3636
3657
|
MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
|
|
3637
3658
|
|
|
3659
|
+
/* eslint camelcase: "off" */
|
|
3660
|
+
|
|
3638
3661
|
/*
|
|
3639
3662
|
* Constants
|
|
3640
3663
|
*/
|
|
@@ -3690,7 +3713,7 @@
|
|
|
3690
3713
|
|
|
3691
3714
|
this.load();
|
|
3692
3715
|
this.update_config(config);
|
|
3693
|
-
this.upgrade(
|
|
3716
|
+
this.upgrade();
|
|
3694
3717
|
this.save();
|
|
3695
3718
|
};
|
|
3696
3719
|
|
|
@@ -3718,49 +3741,12 @@
|
|
|
3718
3741
|
}
|
|
3719
3742
|
};
|
|
3720
3743
|
|
|
3721
|
-
MixpanelPersistence.prototype.upgrade = function(
|
|
3722
|
-
var
|
|
3723
|
-
|
|
3724
|
-
old_cookie;
|
|
3725
|
-
|
|
3726
|
-
if (upgrade_from_old_lib) {
|
|
3727
|
-
old_cookie_name = 'mp_super_properties';
|
|
3728
|
-
// Case where they had a custom cookie name before.
|
|
3729
|
-
if (typeof(upgrade_from_old_lib) === 'string') {
|
|
3730
|
-
old_cookie_name = upgrade_from_old_lib;
|
|
3731
|
-
}
|
|
3732
|
-
|
|
3733
|
-
old_cookie = this.storage.parse(old_cookie_name);
|
|
3734
|
-
|
|
3735
|
-
// remove the cookie
|
|
3736
|
-
this.storage.remove(old_cookie_name);
|
|
3737
|
-
this.storage.remove(old_cookie_name, true);
|
|
3738
|
-
|
|
3739
|
-
if (old_cookie) {
|
|
3740
|
-
this['props'] = _.extend(
|
|
3741
|
-
this['props'],
|
|
3742
|
-
old_cookie['all'],
|
|
3743
|
-
old_cookie['events']
|
|
3744
|
-
);
|
|
3745
|
-
}
|
|
3746
|
-
}
|
|
3747
|
-
|
|
3748
|
-
if (!config['cookie_name'] && config['name'] !== 'mixpanel') {
|
|
3749
|
-
// special case to handle people with cookies of the form
|
|
3750
|
-
// mp_TOKEN_INSTANCENAME from the first release of this library
|
|
3751
|
-
old_cookie_name = 'mp_' + config['token'] + '_' + config['name'];
|
|
3752
|
-
old_cookie = this.storage.parse(old_cookie_name);
|
|
3753
|
-
|
|
3754
|
-
if (old_cookie) {
|
|
3755
|
-
this.storage.remove(old_cookie_name);
|
|
3756
|
-
this.storage.remove(old_cookie_name, true);
|
|
3757
|
-
|
|
3758
|
-
// Save the prop values that were in the cookie from before -
|
|
3759
|
-
// this should only happen once as we delete the old one.
|
|
3760
|
-
this.register_once(old_cookie);
|
|
3761
|
-
}
|
|
3762
|
-
}
|
|
3744
|
+
MixpanelPersistence.prototype.upgrade = function() {
|
|
3745
|
+
var old_cookie,
|
|
3746
|
+
old_localstorage;
|
|
3763
3747
|
|
|
3748
|
+
// if transferring from cookie to localStorage or vice-versa, copy existing
|
|
3749
|
+
// super properties over to new storage mode
|
|
3764
3750
|
if (this.storage === _.localStorage) {
|
|
3765
3751
|
old_cookie = _.cookie.parse(this.name);
|
|
3766
3752
|
|
|
@@ -3770,6 +3756,14 @@
|
|
|
3770
3756
|
if (old_cookie) {
|
|
3771
3757
|
this.register_once(old_cookie);
|
|
3772
3758
|
}
|
|
3759
|
+
} else if (this.storage === _.cookie) {
|
|
3760
|
+
old_localstorage = _.localStorage.parse(this.name);
|
|
3761
|
+
|
|
3762
|
+
_.localStorage.remove(this.name);
|
|
3763
|
+
|
|
3764
|
+
if (old_localstorage) {
|
|
3765
|
+
this.register_once(old_localstorage);
|
|
3766
|
+
}
|
|
3773
3767
|
}
|
|
3774
3768
|
};
|
|
3775
3769
|
|
|
@@ -4084,6 +4078,8 @@
|
|
|
4084
4078
|
return timestamp;
|
|
4085
4079
|
};
|
|
4086
4080
|
|
|
4081
|
+
/* eslint camelcase: "off" */
|
|
4082
|
+
|
|
4087
4083
|
/*
|
|
4088
4084
|
* Mixpanel JS Library
|
|
4089
4085
|
*
|
|
@@ -4130,7 +4126,7 @@
|
|
|
4130
4126
|
*/
|
|
4131
4127
|
// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
|
|
4132
4128
|
// https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
|
|
4133
|
-
var USE_XHR = (
|
|
4129
|
+
var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
|
|
4134
4130
|
|
|
4135
4131
|
// IE<10 does not support cross-origin XHR's but script tags
|
|
4136
4132
|
// with defer won't block window.onload; ENQUEUE_REQUESTS
|
|
@@ -4149,7 +4145,8 @@
|
|
|
4149
4145
|
var DEFAULT_API_ROUTES = {
|
|
4150
4146
|
'track': 'track/',
|
|
4151
4147
|
'engage': 'engage/',
|
|
4152
|
-
'groups': 'groups/'
|
|
4148
|
+
'groups': 'groups/',
|
|
4149
|
+
'record': 'record/'
|
|
4153
4150
|
};
|
|
4154
4151
|
|
|
4155
4152
|
/*
|
|
@@ -4176,7 +4173,7 @@
|
|
|
4176
4173
|
'track_pageview': false,
|
|
4177
4174
|
'skip_first_touch_marketing': false,
|
|
4178
4175
|
'store_google': true,
|
|
4179
|
-
'stop_utm_persistence':
|
|
4176
|
+
'stop_utm_persistence': true,
|
|
4180
4177
|
'save_referrer': true,
|
|
4181
4178
|
'test': false,
|
|
4182
4179
|
'verbose': false,
|
|
@@ -4201,7 +4198,15 @@
|
|
|
4201
4198
|
'batch_flush_interval_ms': 5000,
|
|
4202
4199
|
'batch_request_timeout_ms': 90000,
|
|
4203
4200
|
'batch_autostart': true,
|
|
4204
|
-
'hooks': {}
|
|
4201
|
+
'hooks': {},
|
|
4202
|
+
'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
|
|
4203
|
+
'record_block_selector': 'img, video',
|
|
4204
|
+
'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
|
|
4205
|
+
'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
|
|
4206
|
+
'record_mask_text_selector': '*',
|
|
4207
|
+
'record_max_ms': MAX_RECORDING_MS,
|
|
4208
|
+
'record_sessions_percent': 0,
|
|
4209
|
+
'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
|
|
4205
4210
|
};
|
|
4206
4211
|
|
|
4207
4212
|
var DOM_LOADED = false;
|
|
@@ -4364,7 +4369,7 @@
|
|
|
4364
4369
|
});
|
|
4365
4370
|
} else {
|
|
4366
4371
|
this.init_batchers();
|
|
4367
|
-
if (sendBeacon &&
|
|
4372
|
+
if (sendBeacon && win.addEventListener) {
|
|
4368
4373
|
// Before page closes or hides (user tabs away etc), attempt to flush any events
|
|
4369
4374
|
// queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
|
|
4370
4375
|
// events will not be removed from the persistent store; if the site is loaded again,
|
|
@@ -4381,12 +4386,12 @@
|
|
|
4381
4386
|
this.request_batchers.events.flush({unloading: true});
|
|
4382
4387
|
}
|
|
4383
4388
|
}, this);
|
|
4384
|
-
|
|
4389
|
+
win.addEventListener('pagehide', function(ev) {
|
|
4385
4390
|
if (ev['persisted']) {
|
|
4386
4391
|
flush_on_unload();
|
|
4387
4392
|
}
|
|
4388
4393
|
});
|
|
4389
|
-
|
|
4394
|
+
win.addEventListener('visibilitychange', function() {
|
|
4390
4395
|
if (document$1['visibilityState'] === 'hidden') {
|
|
4391
4396
|
flush_on_unload();
|
|
4392
4397
|
}
|
|
@@ -4414,6 +4419,52 @@
|
|
|
4414
4419
|
if (track_pageview_option) {
|
|
4415
4420
|
this._init_url_change_tracking(track_pageview_option);
|
|
4416
4421
|
}
|
|
4422
|
+
|
|
4423
|
+
if (this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent')) {
|
|
4424
|
+
this.start_session_recording();
|
|
4425
|
+
}
|
|
4426
|
+
};
|
|
4427
|
+
|
|
4428
|
+
MixpanelLib.prototype.start_session_recording = addOptOutCheckMixpanelLib(function () {
|
|
4429
|
+
if (!win['MutationObserver']) {
|
|
4430
|
+
console.critical('Browser does not support MutationObserver; skipping session recording');
|
|
4431
|
+
return;
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
var handleLoadedRecorder = _.bind(function() {
|
|
4435
|
+
this._recorder = this._recorder || new win['__mp_recorder'](this);
|
|
4436
|
+
this._recorder['startRecording']();
|
|
4437
|
+
}, this);
|
|
4438
|
+
|
|
4439
|
+
if (_.isUndefined(win['__mp_recorder'])) {
|
|
4440
|
+
var scriptEl = document$1.createElement('script');
|
|
4441
|
+
scriptEl.type = 'text/javascript';
|
|
4442
|
+
scriptEl.async = true;
|
|
4443
|
+
scriptEl.onload = handleLoadedRecorder;
|
|
4444
|
+
scriptEl.src = this.get_config('recorder_src');
|
|
4445
|
+
document$1.head.appendChild(scriptEl);
|
|
4446
|
+
} else {
|
|
4447
|
+
handleLoadedRecorder();
|
|
4448
|
+
}
|
|
4449
|
+
});
|
|
4450
|
+
|
|
4451
|
+
MixpanelLib.prototype.stop_session_recording = function () {
|
|
4452
|
+
if (this._recorder) {
|
|
4453
|
+
this._recorder['stopRecording']();
|
|
4454
|
+
} else {
|
|
4455
|
+
console.critical('Session recorder module not loaded');
|
|
4456
|
+
}
|
|
4457
|
+
};
|
|
4458
|
+
|
|
4459
|
+
MixpanelLib.prototype.get_session_recording_properties = function () {
|
|
4460
|
+
var props = {};
|
|
4461
|
+
if (this._recorder) {
|
|
4462
|
+
var replay_id = this._recorder['replayId'];
|
|
4463
|
+
if (replay_id) {
|
|
4464
|
+
props['$mp_replay_id'] = replay_id;
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
return props;
|
|
4417
4468
|
};
|
|
4418
4469
|
|
|
4419
4470
|
// Private methods
|
|
@@ -4423,9 +4474,8 @@
|
|
|
4423
4474
|
this._set_default_superprops();
|
|
4424
4475
|
this['people'].set_once(this['persistence'].get_referrer_info());
|
|
4425
4476
|
|
|
4426
|
-
//
|
|
4427
|
-
//
|
|
4428
|
-
// stop_utm_persistence is `false` by default now but will be default `true` in the future.
|
|
4477
|
+
// `store_google` is now deprecated and previously stored UTM parameters are cleared
|
|
4478
|
+
// from persistence by default.
|
|
4429
4479
|
if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
|
|
4430
4480
|
var utm_params = _.info.campaignParams(null);
|
|
4431
4481
|
_.each(utm_params, function(_utm_value, utm_key) {
|
|
@@ -4439,6 +4489,7 @@
|
|
|
4439
4489
|
// update persistence with info on referrer, UTM params, etc
|
|
4440
4490
|
MixpanelLib.prototype._set_default_superprops = function() {
|
|
4441
4491
|
this['persistence'].update_search_keyword(document$1.referrer);
|
|
4492
|
+
// Registering super properties for UTM persistence by 'store_google' is deprecated.
|
|
4442
4493
|
if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
|
|
4443
4494
|
this.register(_.info.campaignParams());
|
|
4444
4495
|
}
|
|
@@ -4485,27 +4536,27 @@
|
|
|
4485
4536
|
}
|
|
4486
4537
|
|
|
4487
4538
|
if (_.include(['full-url', 'url-with-path-and-query-string', 'url-with-path'], track_pageview_option)) {
|
|
4488
|
-
|
|
4489
|
-
|
|
4539
|
+
win.addEventListener('popstate', function() {
|
|
4540
|
+
win.dispatchEvent(new Event('mp_locationchange'));
|
|
4490
4541
|
});
|
|
4491
|
-
|
|
4492
|
-
|
|
4542
|
+
win.addEventListener('hashchange', function() {
|
|
4543
|
+
win.dispatchEvent(new Event('mp_locationchange'));
|
|
4493
4544
|
});
|
|
4494
|
-
var nativePushState =
|
|
4545
|
+
var nativePushState = win.history.pushState;
|
|
4495
4546
|
if (typeof nativePushState === 'function') {
|
|
4496
|
-
|
|
4497
|
-
nativePushState.call(
|
|
4498
|
-
|
|
4547
|
+
win.history.pushState = function(state, unused, url) {
|
|
4548
|
+
nativePushState.call(win.history, state, unused, url);
|
|
4549
|
+
win.dispatchEvent(new Event('mp_locationchange'));
|
|
4499
4550
|
};
|
|
4500
4551
|
}
|
|
4501
|
-
var nativeReplaceState =
|
|
4552
|
+
var nativeReplaceState = win.history.replaceState;
|
|
4502
4553
|
if (typeof nativeReplaceState === 'function') {
|
|
4503
|
-
|
|
4504
|
-
nativeReplaceState.call(
|
|
4505
|
-
|
|
4554
|
+
win.history.replaceState = function(state, unused, url) {
|
|
4555
|
+
nativeReplaceState.call(win.history, state, unused, url);
|
|
4556
|
+
win.dispatchEvent(new Event('mp_locationchange'));
|
|
4506
4557
|
};
|
|
4507
4558
|
}
|
|
4508
|
-
|
|
4559
|
+
win.addEventListener('mp_locationchange', function() {
|
|
4509
4560
|
var current_url = _.info.currentUrl();
|
|
4510
4561
|
var should_track = false;
|
|
4511
4562
|
if (track_pageview_option === 'full-url') {
|
|
@@ -4998,6 +5049,7 @@
|
|
|
4998
5049
|
marketing_properties,
|
|
4999
5050
|
this['persistence'].properties(),
|
|
5000
5051
|
this.unpersisted_superprops,
|
|
5052
|
+
this.get_session_recording_properties(),
|
|
5001
5053
|
properties
|
|
5002
5054
|
);
|
|
5003
5055
|
|
|
@@ -6105,38 +6157,41 @@
|
|
|
6105
6157
|
// EXPORTS (for closure compiler)
|
|
6106
6158
|
|
|
6107
6159
|
// MixpanelLib Exports
|
|
6108
|
-
MixpanelLib.prototype['init']
|
|
6109
|
-
MixpanelLib.prototype['reset']
|
|
6110
|
-
MixpanelLib.prototype['disable']
|
|
6111
|
-
MixpanelLib.prototype['time_event']
|
|
6112
|
-
MixpanelLib.prototype['track']
|
|
6113
|
-
MixpanelLib.prototype['track_links']
|
|
6114
|
-
MixpanelLib.prototype['track_forms']
|
|
6115
|
-
MixpanelLib.prototype['track_pageview']
|
|
6116
|
-
MixpanelLib.prototype['register']
|
|
6117
|
-
MixpanelLib.prototype['register_once']
|
|
6118
|
-
MixpanelLib.prototype['unregister']
|
|
6119
|
-
MixpanelLib.prototype['identify']
|
|
6120
|
-
MixpanelLib.prototype['alias']
|
|
6121
|
-
MixpanelLib.prototype['name_tag']
|
|
6122
|
-
MixpanelLib.prototype['set_config']
|
|
6123
|
-
MixpanelLib.prototype['get_config']
|
|
6124
|
-
MixpanelLib.prototype['get_property']
|
|
6125
|
-
MixpanelLib.prototype['get_distinct_id']
|
|
6126
|
-
MixpanelLib.prototype['toString']
|
|
6127
|
-
MixpanelLib.prototype['opt_out_tracking']
|
|
6128
|
-
MixpanelLib.prototype['opt_in_tracking']
|
|
6129
|
-
MixpanelLib.prototype['has_opted_out_tracking']
|
|
6130
|
-
MixpanelLib.prototype['has_opted_in_tracking']
|
|
6131
|
-
MixpanelLib.prototype['clear_opt_in_out_tracking']
|
|
6132
|
-
MixpanelLib.prototype['get_group']
|
|
6133
|
-
MixpanelLib.prototype['set_group']
|
|
6134
|
-
MixpanelLib.prototype['add_group']
|
|
6135
|
-
MixpanelLib.prototype['remove_group']
|
|
6136
|
-
MixpanelLib.prototype['track_with_groups']
|
|
6137
|
-
MixpanelLib.prototype['start_batch_senders']
|
|
6138
|
-
MixpanelLib.prototype['stop_batch_senders']
|
|
6139
|
-
MixpanelLib.prototype['
|
|
6160
|
+
MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
|
|
6161
|
+
MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
|
|
6162
|
+
MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
|
|
6163
|
+
MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
|
|
6164
|
+
MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
|
|
6165
|
+
MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
|
|
6166
|
+
MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
|
|
6167
|
+
MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
|
|
6168
|
+
MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
|
|
6169
|
+
MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
|
|
6170
|
+
MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
|
|
6171
|
+
MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
|
|
6172
|
+
MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
|
|
6173
|
+
MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
|
|
6174
|
+
MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
|
|
6175
|
+
MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
|
|
6176
|
+
MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
|
|
6177
|
+
MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
|
|
6178
|
+
MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
|
|
6179
|
+
MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
|
|
6180
|
+
MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
|
|
6181
|
+
MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
|
|
6182
|
+
MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
|
|
6183
|
+
MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
|
|
6184
|
+
MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
|
|
6185
|
+
MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
|
|
6186
|
+
MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
|
|
6187
|
+
MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
|
|
6188
|
+
MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
|
|
6189
|
+
MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
|
|
6190
|
+
MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
|
|
6191
|
+
MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
|
|
6192
|
+
MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
|
|
6193
|
+
MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
|
|
6194
|
+
MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
|
|
6140
6195
|
|
|
6141
6196
|
// MixpanelPersistence Exports
|
|
6142
6197
|
MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
|
|
@@ -6183,7 +6238,7 @@
|
|
|
6183
6238
|
|
|
6184
6239
|
mixpanel_master = instance;
|
|
6185
6240
|
if (init_type === INIT_SNIPPET) {
|
|
6186
|
-
|
|
6241
|
+
win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
|
|
6187
6242
|
}
|
|
6188
6243
|
extend_mp();
|
|
6189
6244
|
}
|
|
@@ -6233,7 +6288,7 @@
|
|
|
6233
6288
|
// check to make sure we arn't in a frame
|
|
6234
6289
|
var toplevel = false;
|
|
6235
6290
|
try {
|
|
6236
|
-
toplevel =
|
|
6291
|
+
toplevel = win.frameElement === null;
|
|
6237
6292
|
} catch(e) {
|
|
6238
6293
|
// noop
|
|
6239
6294
|
}
|
|
@@ -6244,12 +6299,12 @@
|
|
|
6244
6299
|
}
|
|
6245
6300
|
|
|
6246
6301
|
// fallback handler, always will work
|
|
6247
|
-
_.register_event(
|
|
6302
|
+
_.register_event(win, 'load', dom_loaded_handler, true);
|
|
6248
6303
|
};
|
|
6249
6304
|
|
|
6250
6305
|
function init_from_snippet() {
|
|
6251
6306
|
init_type = INIT_SNIPPET;
|
|
6252
|
-
mixpanel_master =
|
|
6307
|
+
mixpanel_master = win[PRIMARY_INSTANCE_NAME];
|
|
6253
6308
|
|
|
6254
6309
|
// Initialization
|
|
6255
6310
|
if (_.isUndefined(mixpanel_master)) {
|
|
@@ -6287,6 +6342,8 @@
|
|
|
6287
6342
|
add_dom_loaded_handler();
|
|
6288
6343
|
}
|
|
6289
6344
|
|
|
6345
|
+
/* eslint camelcase: "off" */
|
|
6346
|
+
|
|
6290
6347
|
init_from_snippet();
|
|
6291
6348
|
|
|
6292
|
-
}()
|
|
6349
|
+
})();
|