mixpanel-browser 2.62.0 → 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 CHANGED
@@ -1,3 +1,7 @@
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
+
1
5
  **2.62.0** (26 Mar 2025)
2
6
  - Replace UUID generator with UUIDv4 (using native API when available)
3
7
  - Consistently use native JSON serialization when available
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 -i src/loaders/loader-globals.js -f iife -o build/mixpanel.globals.js -n mixpanel -c rollup.config.js
12
- npx rollup -i src/recorder/index.js -f iife -n mixpanel -c src/recorder/rollup.config.js
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.62.0'
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
@@ -1238,7 +1238,7 @@ _.UUID = function() {
1238
1238
  uuid[i] = Math.floor(Math.random() * 16);
1239
1239
  }
1240
1240
  uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
1241
- uuid[19] = uuid[19] &= ~(1 << 2); // set bit 6 of clock-seq-and-reserved to zero
1241
+ uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
1242
1242
  uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
1243
1243
  uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
1244
1244
 
@@ -2131,6 +2131,8 @@ var isRecordingExpired = function(serializedRecording) {
2131
2131
  };
2132
2132
 
2133
2133
  // stateless utils
2134
+ // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
2135
+
2134
2136
 
2135
2137
  var EV_CHANGE = 'change';
2136
2138
  var EV_CLICK = 'click';
@@ -2977,6 +2979,7 @@ safewrapClass(Autocapture);
2977
2979
 
2978
2980
  /* eslint camelcase: "off" */
2979
2981
 
2982
+
2980
2983
  /**
2981
2984
  * DomTracker Object
2982
2985
  * @constructor
@@ -3280,7 +3283,7 @@ SharedLock.prototype.withLock = function(lockedCB, pid) {
3280
3283
  * @type {import('./wrapper').StorageWrapper}
3281
3284
  */
3282
3285
  var LocalStorageWrapper = function (storageOverride) {
3283
- this.storage = storageOverride || localStorage;
3286
+ this.storage = storageOverride || win.localStorage;
3284
3287
  };
3285
3288
 
3286
3289
  LocalStorageWrapper.prototype.init = function () {
@@ -4027,6 +4030,7 @@ RequestBatcher.prototype.reportError = function(msg, err) {
4027
4030
  * These functions are used internally by the SDK and are not intended to be publicly exposed.
4028
4031
  */
4029
4032
 
4033
+
4030
4034
  /**
4031
4035
  * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
4032
4036
  * @callback trackFunction
@@ -4315,6 +4319,7 @@ function _addOptOutCheck(method, getConfigValue) {
4315
4319
 
4316
4320
  /* eslint camelcase: "off" */
4317
4321
 
4322
+
4318
4323
  /** @const */ var SET_ACTION = '$set';
4319
4324
  /** @const */ var SET_ONCE_ACTION = '$set_once';
4320
4325
  /** @const */ var UNSET_ACTION = '$unset';
@@ -5074,6 +5079,7 @@ MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
5074
5079
 
5075
5080
  /* eslint camelcase: "off" */
5076
5081
 
5082
+
5077
5083
  /*
5078
5084
  * Constants
5079
5085
  */
@@ -7936,6 +7942,7 @@ function init_as_module(bundle_loader) {
7936
7942
  }
7937
7943
 
7938
7944
  // For loading separate bundles asynchronously via script tag
7945
+ // so that we don't load them until they are needed at runtime.
7939
7946
 
7940
7947
  // For builds that do NOT want any extra bundles (e.g. session recorder)
7941
7948
  // and just the main SDK, throw an error when trying to load a separate bundle.
@@ -1,5 +1,5 @@
1
- (function(d,c){if(!c.__SV){var e,g,b,a;window.mixpanel=c;c._i=[];c.init=function(i,g,d){function e(b,a){var d=a.split(".");2==d.length&&(b=b[d[0]],a=d[1]);b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,0)))}}var f=c;"undefined"!==typeof d?f=c[d]=[]:d="mixpanel";f.people=f.people||[];f.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};f.people.toString=function(){return f.toString(1)+".people (stub)"};b="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(a=0;a<b.length;a++)e(f,b[a]);var h="set set_once union unset remove delete".split(" ");f.get_group=function(){function a(c){b[c]=function(){var a=[c].concat(Array.prototype.slice.call(arguments,0));f.push([d,a])}}for(var b={},d=["get_group"].concat(Array.prototype.slice.call(arguments,0)),c=0;c<h.length;c++)a(h[c]);return b};c._i.push([i,g,d])};c.__SV=1.2;e=d.createElement("script");e.type="text/javascript";e.async=!0;e.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:
3
- "file:"===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";g=d.getElementsByTagName("script")[0];g.parentNode.insertBefore(e,g)}})(document,window.mixpanel||[]);
4
- (function(d,c){if(d.mixpanel&&"function"===typeof d.mixpanel.init){var e="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[c]=
5
- d[c]||function(){var d=[].slice.call(arguments,0),b=d.shift(),a=null,c=b.match(/^([^.]+)\.(.+)$/);c&&3===c.length&&!/people|group/.test(c[1])&&(a=c[1],b=c[2]);if((a=a?window.mixpanel[a]:window.mixpanel)&&-1!==e.indexOf(b))return/^people\./.test(b)?(b=b.split(".").pop(),a.people[b].apply(a.people,d),b=void 0):/^group\./.test(b)?(b=b.split(".").pop(),c=d.shift(),Array.isArray(c)&&2===c.length&&(a=a.get_group.apply(a,c),a[b].apply(a,d)),b=void 0):b=a.push.apply(a,[[b].concat(d)]),b}}})(window,"_mixpanel");
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(f,a){if(!a.__SV){var e,g,i,h;window.mixpanel=a;a._i=[];a.init=function(e,f,c){function g(b,d){var a=d.split(".");2==a.length&&(b=b[a[0]],d=a[1]);b[d]=function(){b.push([d].concat(Array.prototype.slice.call(arguments,0)))}}var b=a;"undefined"!==typeof c?b=a[c]=[]:c="mixpanel";b.people=b.people||[];b.toString=function(b){var d="mixpanel";"mixpanel"!==c&&(d+="."+c);b||(d+=" (stub)");return d};b.people.toString=function(){return b.toString(1)+".people (stub)"};i="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<i.length;h++)g(b,i[h]);var j="set set_once union unset remove delete".split(" ");b.get_group=function(){function a(c){d[c]=function(){var a=[c].concat(Array.prototype.slice.call(arguments,0));b.push([e,a])}}for(var d={},e=["get_group"].concat(Array.prototype.slice.call(arguments,0)),c=0;c<j.length;c++)a(j[c]);return d};a._i.push([e,f,c])};a.__SV=1.2;e=f.createElement("script");e.type="text/javascript";e.async=!0;e.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:
3
- "file:"===f.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";g=f.getElementsByTagName("script")[0];g.parentNode.insertBefore(e,g)}})(document,window.mixpanel||[]);
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(f,a){if(!a.__SV){var e,g,i,h;window.mixpanel=a;a._i=[];a.init=function(e,f,c){function g(b,d){var a=d.split(".");2==a.length&&(b=b[a[0]],d=a[1]);b[d]=function(){b.push([d].concat(Array.prototype.slice.call(arguments,0)))}}var b=a;"undefined"!==typeof c?b=a[c]=[]:c="mixpanel";b.people=b.people||[];b.toString=function(b){var d="mixpanel";"mixpanel"!==c&&(d+="."+c);b||(d+=" (stub)");return d};b.people.toString=function(){return b.toString(1)+".people (stub)"};i="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<i.length;h++)g(b,i[h]);var j="set set_once union unset remove delete".split(" ");b.get_group=function(){function a(c){d[c]=function(){var a=[c].concat(Array.prototype.slice.call(arguments,0));b.push([e,a])}}for(var d={},e=["get_group"].concat(Array.prototype.slice.call(arguments,0)),c=0;c<j.length;c++)a(j[c]);return d};a._i.push([e,f,c])};a.__SV=1.2;e=f.createElement("script");e.type="text/javascript";e.async=!0;e.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:
3
- "file:"===f.location.protocol&&"../build/mixpanel.min.js".match(/^\/\//)?"https:../build/mixpanel.min.js":"../build/mixpanel.min.js";g=f.getElementsByTagName("script")[0];g.parentNode.insertBefore(e,g)}})(document,window.mixpanel||[]);
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||[])