mixpanel-browser 2.61.2 → 2.63.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/CHANGELOG.md +9 -0
- package/build.sh +4 -21
- package/dist/mixpanel-core.cjs.js +31 -67
- package/dist/mixpanel-js-wrapper.min.js +5 -5
- package/dist/mixpanel-jslib-snippet.min.js +3 -3
- package/dist/mixpanel-jslib-snippet.min.test.js +3 -3
- package/dist/mixpanel-recorder.js +13579 -4569
- package/dist/mixpanel-recorder.min.js +1 -38
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-with-async-recorder.cjs.js +30 -67
- package/dist/mixpanel-with-recorder.js +22218 -0
- package/dist/mixpanel-with-recorder.min.js +1 -0
- package/dist/mixpanel.amd.js +13586 -4569
- package/dist/mixpanel.cjs.js +13586 -4569
- package/dist/mixpanel.globals.js +30 -67
- package/dist/mixpanel.min.js +144 -145
- package/dist/mixpanel.module.js +13586 -4569
- package/dist/mixpanel.umd.js +13586 -4569
- package/dist/rrweb-compiled.js +18693 -0
- package/package.json +8 -4
- package/rollup.config.mjs +223 -0
- package/src/config.js +1 -1
- package/src/loaders/loader-globals-with-recorder.js +7 -0
- package/src/mixpanel-core.js +2 -2
- package/src/mixpanel-persistence.js +2 -2
- package/src/recorder/session-recording.js +7 -4
- package/src/storage/local-storage.js +2 -1
- package/src/utils.js +20 -64
- package/src/window.js +1 -0
- package/rollup.config.js +0 -11
- package/src/recorder/rollup.config.js +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
**2.63.0** (1 Apr 2025)
|
|
2
|
+
- Update rrweb to latest alpha version
|
|
3
|
+
- Refactor SDK build process to rely mainly on Rollup
|
|
4
|
+
|
|
5
|
+
**2.62.0** (26 Mar 2025)
|
|
6
|
+
- Replace UUID generator with UUIDv4 (using native API when available)
|
|
7
|
+
- Consistently use native JSON serialization when available
|
|
8
|
+
- Fix for session recording idle timeout race condition
|
|
9
|
+
|
|
1
10
|
**2.61.2** (14 Mar 2025)
|
|
2
11
|
- Revert 10ms throttle on enqueueing events to improve tracking reliability on page unload
|
|
3
12
|
|
package/build.sh
CHANGED
|
@@ -5,33 +5,16 @@ set -e
|
|
|
5
5
|
# building with $DIST=1 also implies $FULL=1
|
|
6
6
|
if [ ! -z "$DIST" ]; then
|
|
7
7
|
export FULL=1
|
|
8
|
+
rm -r -f build
|
|
9
|
+
npm install
|
|
8
10
|
fi
|
|
9
11
|
|
|
10
12
|
echo 'Building main bundles'
|
|
11
|
-
npx rollup -
|
|
12
|
-
|
|
13
|
+
npx rollup -c rollup.config.mjs
|
|
14
|
+
|
|
13
15
|
ln -sf mixpanel.globals.js build/mixpanel.js
|
|
14
16
|
|
|
15
17
|
if [ ! -z "$FULL" ]; then
|
|
16
|
-
echo 'Minifying main build and snippets'
|
|
17
|
-
java -jar vendor/closure-compiler/compiler.jar --js build/mixpanel.js --language_in ECMASCRIPT5 --externs src/externs.js --js_output_file build/mixpanel.min.js --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper "(function() {
|
|
18
|
-
%output%
|
|
19
|
-
})();"
|
|
20
|
-
java -jar vendor/closure-compiler/compiler.jar --js src/loaders/mixpanel-jslib-snippet.js --language_in ECMASCRIPT5 --js_output_file build/mixpanel-jslib-snippet.min.js --compilation_level ADVANCED_OPTIMIZATIONS
|
|
21
|
-
java -jar vendor/closure-compiler/compiler.jar --js src/loaders/mixpanel-jslib-snippet.js --language_in ECMASCRIPT5 --js_output_file build/mixpanel-jslib-snippet.min.test.js --compilation_level ADVANCED_OPTIMIZATIONS --define='MIXPANEL_LIB_URL="../build/mixpanel.min.js"'
|
|
22
|
-
|
|
23
|
-
echo 'Building mixpanel-js-wrapper'
|
|
24
|
-
npx rollup src/loaders/mixpanel-js-wrapper.js -o build/mixpanel-js-wrapper.js -c rollup.config.js
|
|
25
|
-
java -jar vendor/closure-compiler/compiler.jar --js build/mixpanel-js-wrapper.js --js_output_file build/mixpanel-js-wrapper.min.js --compilation_level ADVANCED_OPTIMIZATIONS
|
|
26
|
-
|
|
27
|
-
echo 'Building module bundles'
|
|
28
|
-
npx rollup -i src/loaders/loader-module.js -f amd -o build/mixpanel.amd.js -c rollup.config.js
|
|
29
|
-
npx rollup -i src/loaders/loader-module.js -f cjs -o build/mixpanel.cjs.js -c rollup.config.js
|
|
30
|
-
npx rollup -i src/loaders/loader-module.js -f es -o build/mixpanel.module.js -c rollup.config.js
|
|
31
|
-
npx rollup -i src/loaders/loader-module-core.js -f cjs -o build/mixpanel-core.cjs.js -c rollup.config.js
|
|
32
|
-
npx rollup -i src/loaders/loader-module-with-async-recorder.js -f cjs -o build/mixpanel-with-async-recorder.cjs.js -c rollup.config.js
|
|
33
|
-
npx rollup -i src/loaders/loader-module.js -f umd -o build/mixpanel.umd.js -n mixpanel -c rollup.config.js
|
|
34
|
-
|
|
35
18
|
echo 'Bundling module-loader test runners'
|
|
36
19
|
npx webpack tests/module-cjs.js tests/module-cjs.bundle.js
|
|
37
20
|
npx browserify tests/module-es2015.js -t [ babelify --compact false ] --outfile tests/module-es2015.bundle.js
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var Config = {
|
|
4
4
|
DEBUG: false,
|
|
5
|
-
LIB_VERSION: '2.
|
|
5
|
+
LIB_VERSION: '2.63.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
|
|
@@ -12,6 +12,7 @@ if (typeof(window) === 'undefined') {
|
|
|
12
12
|
hostname: ''
|
|
13
13
|
};
|
|
14
14
|
win = {
|
|
15
|
+
crypto: {randomUUID: function() {throw Error('unsupported');}},
|
|
15
16
|
navigator: { userAgent: '', onLine: true },
|
|
16
17
|
document: {
|
|
17
18
|
createElement: function() { return {}; },
|
|
@@ -1225,71 +1226,27 @@ _.utf8Encode = function(string) {
|
|
|
1225
1226
|
return utftext;
|
|
1226
1227
|
};
|
|
1227
1228
|
|
|
1228
|
-
_.UUID =
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
ticks = 0;
|
|
1239
|
-
|
|
1240
|
-
// this while loop figures how many browser ticks go by
|
|
1241
|
-
// before 1*new Date() returns a new number, ie the amount
|
|
1242
|
-
// of ticks that go by per millisecond
|
|
1243
|
-
while (time == 1 * new Date()) {
|
|
1244
|
-
ticks++;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
return time.toString(16) + Math.floor(ticks).toString(16);
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
|
-
// Math.Random entropy
|
|
1251
|
-
var R = function() {
|
|
1252
|
-
return Math.random().toString(16).replace('.', '');
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
// User agent entropy
|
|
1256
|
-
// This function takes the user agent string, and then xors
|
|
1257
|
-
// together each sequence of 8 bytes. This produces a final
|
|
1258
|
-
// sequence of 8 bytes which it returns as hex.
|
|
1259
|
-
var UA = function() {
|
|
1260
|
-
var ua = userAgent,
|
|
1261
|
-
i, ch, buffer = [],
|
|
1262
|
-
ret = 0;
|
|
1263
|
-
|
|
1264
|
-
function xor(result, byte_array) {
|
|
1265
|
-
var j, tmp = 0;
|
|
1266
|
-
for (j = 0; j < byte_array.length; j++) {
|
|
1267
|
-
tmp |= (buffer[j] << j * 8);
|
|
1268
|
-
}
|
|
1269
|
-
return result ^ tmp;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
for (i = 0; i < ua.length; i++) {
|
|
1273
|
-
ch = ua.charCodeAt(i);
|
|
1274
|
-
buffer.unshift(ch & 0xFF);
|
|
1275
|
-
if (buffer.length >= 4) {
|
|
1276
|
-
ret = xor(ret, buffer);
|
|
1277
|
-
buffer = [];
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
if (buffer.length > 0) {
|
|
1282
|
-
ret = xor(ret, buffer);
|
|
1229
|
+
_.UUID = function() {
|
|
1230
|
+
try {
|
|
1231
|
+
// use native Crypto API when available
|
|
1232
|
+
return win['crypto']['randomUUID']();
|
|
1233
|
+
} catch (err) {
|
|
1234
|
+
// fall back to generating our own UUID
|
|
1235
|
+
// based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
|
|
1236
|
+
var uuid = new Array(36);
|
|
1237
|
+
for (var i = 0; i < 36; i++) {
|
|
1238
|
+
uuid[i] = Math.floor(Math.random() * 16);
|
|
1283
1239
|
}
|
|
1240
|
+
uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
|
|
1241
|
+
uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
|
|
1242
|
+
uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
|
|
1243
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
1284
1244
|
|
|
1285
|
-
return
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
return (T() + '-' + R() + '-' + UA() + '-' + se + '-' + T());
|
|
1291
|
-
};
|
|
1292
|
-
})();
|
|
1245
|
+
return _.map(uuid, function(x) {
|
|
1246
|
+
return x.toString(16);
|
|
1247
|
+
}).join('');
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1293
1250
|
|
|
1294
1251
|
// _.isBlockedUA()
|
|
1295
1252
|
// This is to block various web spiders from executing our JS and
|
|
@@ -2174,6 +2131,8 @@ var isRecordingExpired = function(serializedRecording) {
|
|
|
2174
2131
|
};
|
|
2175
2132
|
|
|
2176
2133
|
// stateless utils
|
|
2134
|
+
// mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
|
|
2135
|
+
|
|
2177
2136
|
|
|
2178
2137
|
var EV_CHANGE = 'change';
|
|
2179
2138
|
var EV_CLICK = 'click';
|
|
@@ -3020,6 +2979,7 @@ safewrapClass(Autocapture);
|
|
|
3020
2979
|
|
|
3021
2980
|
/* eslint camelcase: "off" */
|
|
3022
2981
|
|
|
2982
|
+
|
|
3023
2983
|
/**
|
|
3024
2984
|
* DomTracker Object
|
|
3025
2985
|
* @constructor
|
|
@@ -3323,7 +3283,7 @@ SharedLock.prototype.withLock = function(lockedCB, pid) {
|
|
|
3323
3283
|
* @type {import('./wrapper').StorageWrapper}
|
|
3324
3284
|
*/
|
|
3325
3285
|
var LocalStorageWrapper = function (storageOverride) {
|
|
3326
|
-
this.storage = storageOverride || localStorage;
|
|
3286
|
+
this.storage = storageOverride || win.localStorage;
|
|
3327
3287
|
};
|
|
3328
3288
|
|
|
3329
3289
|
LocalStorageWrapper.prototype.init = function () {
|
|
@@ -4070,6 +4030,7 @@ RequestBatcher.prototype.reportError = function(msg, err) {
|
|
|
4070
4030
|
* These functions are used internally by the SDK and are not intended to be publicly exposed.
|
|
4071
4031
|
*/
|
|
4072
4032
|
|
|
4033
|
+
|
|
4073
4034
|
/**
|
|
4074
4035
|
* A function used to track a Mixpanel event (e.g. MixpanelLib.track)
|
|
4075
4036
|
* @callback trackFunction
|
|
@@ -4358,6 +4319,7 @@ function _addOptOutCheck(method, getConfigValue) {
|
|
|
4358
4319
|
|
|
4359
4320
|
/* eslint camelcase: "off" */
|
|
4360
4321
|
|
|
4322
|
+
|
|
4361
4323
|
/** @const */ var SET_ACTION = '$set';
|
|
4362
4324
|
/** @const */ var SET_ONCE_ACTION = '$set_once';
|
|
4363
4325
|
/** @const */ var UNSET_ACTION = '$unset';
|
|
@@ -5117,6 +5079,7 @@ MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
|
|
|
5117
5079
|
|
|
5118
5080
|
/* eslint camelcase: "off" */
|
|
5119
5081
|
|
|
5082
|
+
|
|
5120
5083
|
/*
|
|
5121
5084
|
* Constants
|
|
5122
5085
|
*/
|
|
@@ -5231,7 +5194,7 @@ MixpanelPersistence.prototype.save = function() {
|
|
|
5231
5194
|
|
|
5232
5195
|
this.storage.set(
|
|
5233
5196
|
this.name,
|
|
5234
|
-
|
|
5197
|
+
JSONStringify(this['props']),
|
|
5235
5198
|
this.expire_days,
|
|
5236
5199
|
this.cross_subdomain,
|
|
5237
5200
|
this.secure,
|
|
@@ -6575,7 +6538,7 @@ MixpanelLib.prototype.disable = function(events) {
|
|
|
6575
6538
|
};
|
|
6576
6539
|
|
|
6577
6540
|
MixpanelLib.prototype._encode_data_for_request = function(data) {
|
|
6578
|
-
var encoded_data =
|
|
6541
|
+
var encoded_data = JSONStringify(data);
|
|
6579
6542
|
if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
|
|
6580
6543
|
encoded_data = _.base64Encode(encoded_data);
|
|
6581
6544
|
}
|
|
@@ -7979,6 +7942,7 @@ function init_as_module(bundle_loader) {
|
|
|
7979
7942
|
}
|
|
7980
7943
|
|
|
7981
7944
|
// For loading separate bundles asynchronously via script tag
|
|
7945
|
+
// so that we don't load them until they are needed at runtime.
|
|
7982
7946
|
|
|
7983
7947
|
// For builds that do NOT want any extra bundles (e.g. session recorder)
|
|
7984
7948
|
// and just the main SDK, throw an error when trying to load a separate bundle.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(d,
|
|
2
|
-
for(
|
|
3
|
-
|
|
4
|
-
(function(d,
|
|
5
|
-
d[
|
|
1
|
+
(function(d,e){if(!e.__SV){var m,c;window.mixpanel=e;e._i=[];e.init=function(b,f,l){function t(k,g){var n=g.split(".");2==n.length&&(k=k[n[0]],g=n[1]);k[g]=function(){k.push([g].concat(Array.prototype.slice.call(arguments,0)))}}var h=e;"undefined"!==typeof l?h=e[l]=[]:l="mixpanel";h.people=h.people||[];h.toString=function(k){var g="mixpanel";"mixpanel"!==l&&(g+="."+l);k||(g+=" (stub)");return g};h.people.toString=function(){return h.toString(1)+".people (stub)"};m="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders start_session_recording stop_session_recording people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" ");
|
|
2
|
+
for(c=0;c<m.length;c++)t(h,m[c]);var q="set set_once union unset remove delete".split(" ");h.get_group=function(){function k(r){g[r]=function(){h.push([n,[r].concat(Array.prototype.slice.call(arguments,0))])}}for(var g={},n=["get_group"].concat(Array.prototype.slice.call(arguments,0)),p=0;p<q.length;p++)k(q[p]);return g};e._i.push([b,f,l])};e.__SV=1.2;var a=d.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===
|
|
3
|
+
d.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";d=d.getElementsByTagName("script")[0];d.parentNode.insertBefore(a,d)}})(document,window.mixpanel||[]);
|
|
4
|
+
(function(d,e){if(d.mixpanel&&"function"===typeof d.mixpanel.init){var m="add_group alias clear_opt_in_out_tracking disable identify opt_in_tracking opt_out_tracking register register_once remove_group reset set_config set_group start_session_recording stop_session_recording time_event track track_forms track_links track_pageview track_with_groups unregister people.append people.clear_charges people.delete_user people.increment people.remove people.set people.set_once people.track_charge people.union people.unset group.remove group.set group.set_once group.union group.unset".split(" ");d[e]=
|
|
5
|
+
d[e]||function(){var c=[].slice.call(arguments,0),a=c.shift(),b=null,f=a.match(/^([^.]+)\.(.+)$/);f&&3===f.length&&!/people|group/.test(f[1])&&(b=f[1],a=f[2]);if((b=b?window.mixpanel[b]:window.mixpanel)&&-1!==m.indexOf(a))return/^people\./.test(a)?(a=a.split(".").pop(),b.people[a].apply(b.people,c),c=void 0):/^group\./.test(a)?(a=a.split(".").pop(),f=c.shift(),Array.isArray(f)&&2===f.length&&(b=b.get_group.apply(b,f),b[a].apply(b,c)),c=void 0):c=b.push.apply(b,[[a].concat(c)]),c}}})(window,"_mixpanel")
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
for(h=0;h<
|
|
3
|
-
|
|
1
|
+
(function(e,c){if(!c.__SV){var l,h;window.mixpanel=c;c._i=[];c.init=function(q,r,f){function t(d,a){var g=a.split(".");2==g.length&&(d=d[g[0]],a=g[1]);d[a]=function(){d.push([a].concat(Array.prototype.slice.call(arguments,0)))}}var b=c;"undefined"!==typeof f?b=c[f]=[]:f="mixpanel";b.people=b.people||[];b.toString=function(d){var a="mixpanel";"mixpanel"!==f&&(a+="."+f);d||(a+=" (stub)");return a};b.people.toString=function(){return b.toString(1)+".people (stub)"};l="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders start_session_recording stop_session_recording people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" ");
|
|
2
|
+
for(h=0;h<l.length;h++)t(b,l[h]);var n="set set_once union unset remove delete".split(" ");b.get_group=function(){function d(p){a[p]=function(){b.push([g,[p].concat(Array.prototype.slice.call(arguments,0))])}}for(var a={},g=["get_group"].concat(Array.prototype.slice.call(arguments,0)),m=0;m<n.length;m++)d(n[m]);return a};c._i.push([q,r,f])};c.__SV=1.2;var k=e.createElement("script");k.type="text/javascript";k.async=!0;k.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===
|
|
3
|
+
e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";e=e.getElementsByTagName("script")[0];e.parentNode.insertBefore(k,e)}})(document,window.mixpanel||[])
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
for(h=0;h<
|
|
3
|
-
|
|
1
|
+
(function(e,c){if(!c.__SV){var l,h;window.mixpanel=c;c._i=[];c.init=function(q,r,f){function t(d,a){var g=a.split(".");2==g.length&&(d=d[g[0]],a=g[1]);d[a]=function(){d.push([a].concat(Array.prototype.slice.call(arguments,0)))}}var b=c;"undefined"!==typeof f?b=c[f]=[]:f="mixpanel";b.people=b.people||[];b.toString=function(d){var a="mixpanel";"mixpanel"!==f&&(a+="."+f);d||(a+=" (stub)");return a};b.people.toString=function(){return b.toString(1)+".people (stub)"};l="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders start_session_recording stop_session_recording people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" ");
|
|
2
|
+
for(h=0;h<l.length;h++)t(b,l[h]);var n="set set_once union unset remove delete".split(" ");b.get_group=function(){function d(p){a[p]=function(){b.push([g,[p].concat(Array.prototype.slice.call(arguments,0))])}}for(var a={},g=["get_group"].concat(Array.prototype.slice.call(arguments,0)),m=0;m<n.length;m++)d(n[m]);return a};c._i.push([q,r,f])};c.__SV=1.2;var k=e.createElement("script");k.type="text/javascript";k.async=!0;k.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===
|
|
3
|
+
e.location.protocol&&"../build/mixpanel.min.js".match(/^\/\//)?"https:../build/mixpanel.min.js":"../build/mixpanel.min.js";e=e.getElementsByTagName("script")[0];e.parentNode.insertBefore(k,e)}})(document,window.mixpanel||[])
|