Socket
Socket
Sign inDemoInstall

mixpanel-browser

Package Overview
Dependencies
Maintainers
0
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixpanel-browser - npm Package Compare versions

Comparing version 2.52.0 to 2.53.0

16

CHANGELOG.md

@@ -0,1 +1,17 @@

**2.53.0** (21 Jun 2024)
- Switch to new session-recording network payload format, utilizing client-side compression when available
- Session-recording methods are now available through Google Tag Manager wrapper
**2.52.0** (7 Jun 2024)
- Reverted UTM param persistence change from 2.51.0: UTM parameters are again persisted by default
**2.51.0** (30 May 2024)
- UTM parameter properties are no longer persisted by default
- Existing superproperties persisted in localStorage are now copied back to cookie storage if the library is initialized with cookie persistence (support migrations from localStorage->cookie)
- Added session-recording options `record_block_class`, `record_block_selector`, and `record_mask_text_class`
- Added method `mixpanel.get_session_recording_properties()` for interop with other client-side SDKs
**2.50.0** (26 Apr 2024)
- Initial support for session recording
**2.49.0** (5 Feb 2024)

@@ -2,0 +18,0 @@ - SPA support in pageview-tracking

2

dist/mixpanel-js-wrapper.js

@@ -144,2 +144,4 @@ // ==ClosureCompiler==

'set_group',
'start_session_recording',
'stop_session_recording',
'time_event',

@@ -146,0 +148,0 @@ 'track',

2

dist/mixpanel-js-wrapper.min.js
(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(" ");
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:
"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||[]);
(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,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]=
(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]=
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");

@@ -42,3 +42,3 @@ (function() {

/(iPhone|iPad|iPod)/.test(z)?"iOS":/Android/.test(z)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(z)?"BlackBerry":/Mac/i.test(z)?"Mac OS X":/Linux/.test(z)?"Linux":/CrOS/.test(z)?"Chrome OS":""},Bb:function(a){return/Windows Phone/i.test(a)||/WPDesktop/.test(a)?"Windows Phone":/iPad/.test(a)?"iPad":/iPod/.test(a)?"iPod Touch":/iPhone/.test(a)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(a)?"BlackBerry":/Android/.test(a)?"Android":""},Sb:function(a){a=a.split("/");return 3<=a.length?a[2]:""},La:function(){return n.location.href},
aa:function(a){"object"!==typeof a&&(a={});return c.extend(c.fa({$os:c.info.Nb(),$browser:c.info.ma(z,I.vendor,Y),$referrer:t.referrer,$referring_domain:c.info.Sb(t.referrer),$device:c.info.Bb(z)}),{$current_url:c.info.La(),$browser_version:c.info.Ia(z,I.vendor,Y),$screen_height:Z.height,$screen_width:Z.width,mp_lib:"web",$lib_version:"2.52.0",$insert_id:ea(),time:c.timestamp()/1E3},c.fa(a))},Sc:function(){return c.extend(c.fa({$os:c.info.Nb(),$browser:c.info.ma(z,I.vendor,Y)}),{$browser_version:c.info.Ia(z,
aa:function(a){"object"!==typeof a&&(a={});return c.extend(c.fa({$os:c.info.Nb(),$browser:c.info.ma(z,I.vendor,Y),$referrer:t.referrer,$referring_domain:c.info.Sb(t.referrer),$device:c.info.Bb(z)}),{$current_url:c.info.La(),$browser_version:c.info.Ia(z,I.vendor,Y),$screen_height:Z.height,$screen_width:Z.width,mp_lib:"web",$lib_version:"2.53.0",$insert_id:ea(),time:c.timestamp()/1E3},c.fa(a))},Sc:function(){return c.extend(c.fa({$os:c.info.Nb(),$browser:c.info.ma(z,I.vendor,Y)}),{$browser_version:c.info.Ia(z,
I.vendor,Y)})},Pc:function(){return c.fa({current_page_title:t.title,current_domain:n.location.hostname,current_url_path:n.location.pathname,current_url_protocol:n.location.protocol,current_url_search:n.location.search})}};var Ga=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,Fa=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,$=r,aa=r;if("undefined"!==typeof JSON)$=JSON.stringify,aa=JSON.parse;$=$||c.ha;aa=aa||c.S;c.toArray=c.O;c.isObject=c.e;c.JSONEncode=c.ha;c.JSONDecode=c.S;c.isBlockedUA=c.Ib;c.isEmptyObject=c.ra;c.info=

@@ -54,3 +54,3 @@ c.info;c.info.device=c.info.Bb;c.info.browser=c.info.ma;c.info.browserVersion=c.info.Ia;c.info.properties=c.info.aa;E.prototype.oa=function(){};E.prototype.Oa=function(){};E.prototype.Ga=function(){};E.prototype.Ua=function(a){this.Kb=a;return this};E.prototype.o=function(a,b,d,f){var h=this,g=c.Cc(a);if(0===g.length)o.error("The DOM query ("+a+") returned 0 elements");else return c.a(g,function(a){c.Tb(a,this.Ob,function(a){var c={},g=h.oa(d,this),e=h.Kb.c("track_links_timeout");h.Oa(a,this,c);window.setTimeout(h.gc(f,

b){this.ba.Na(a,this.pa,b)};C.prototype.start=function(){this.va=D;this.Ja=0;this.flush()};C.prototype.stop=function(){this.va=m;if(this.cb)clearTimeout(this.cb),this.cb=r};C.prototype.clear=function(){this.ba.clear()};C.prototype.Wb=function(){this.D=this.B.batch_size};C.prototype.ea=function(){this.Xb(this.B.batch_flush_interval_ms)};C.prototype.Xb=function(a){this.pa=a;if(!this.va)this.cb=setTimeout(c.bind(this.flush,this),this.pa)};C.prototype.flush=function(a){try{if(this.Vb)R.log("Flush: Request already in progress");
else{var a=a||{},b=this.B.batch_request_timeout_ms,d=(new Date).getTime(),f=this.D,h=this.ba.Ec(f),e=[],v={};c.a(h,function(a){var b=a.payload;this.la&&!a.Rc&&(b=this.la(b));if(b){b.event&&b.properties&&(b.properties=c.extend({},b.properties,{mp_sent_by_lib_version:"2.52.0"}));var d=m,f=a.id;if(f){if(5<(this.G[f]||0))this.h("[dupe] item ID sent too many times, not sending",{item:a,D:h.length,od:this.G[f]}),d=D}else this.h("[dupe] found item with no ID",{item:a});d&&e.push(b)}v[a.id]=b},this);if(1>
else{var a=a||{},b=this.B.batch_request_timeout_ms,d=(new Date).getTime(),f=this.D,h=this.ba.Ec(f),e=[],v={};c.a(h,function(a){var b=a.payload;this.la&&!a.Rc&&(b=this.la(b));if(b){b.event&&b.properties&&(b.properties=c.extend({},b.properties,{mp_sent_by_lib_version:"2.53.0"}));var d=m,f=a.id;if(f){if(5<(this.G[f]||0))this.h("[dupe] item ID sent too many times, not sending",{item:a,D:h.length,od:this.G[f]}),d=D}else this.h("[dupe] found item with no ID",{item:a});d&&e.push(b)}v[a.id]=b},this);if(1>
e.length)this.ea();else{this.Vb=m;var i=c.bind(function(e){this.Vb=D;try{var g=D;if(a.ic)this.ba.vd(v);else if(c.e(e)&&"timeout"===e.error&&(new Date).getTime()-d>=b)this.h("Network timeout; retrying"),this.flush();else if(c.e(e)&&e.R&&(500<=e.R.status||429===e.R.status||"timeout"===e.error)){var i=2*this.pa,k=e.R.responseHeaders;if(k){var j=k["Retry-After"];j&&(i=1E3*parseInt(j,10)||i)}i=Math.min(6E5,i);this.h("Error; retry in "+i+" ms");this.Xb(i)}else if(c.e(e)&&e.R&&413===e.R.status)if(1<h.length){var p=

@@ -57,0 +57,0 @@ Math.max(1,Math.floor(f/2));this.D=Math.min(this.D,p,h.length-1);this.h("413 response; reducing batch size to "+this.D);this.ea()}else this.h("Single-event request too large; dropping",h),this.Wb(),g=m;else g=m;g&&(this.ba.Tc(c.map(h,function(a){return a.id}),c.bind(function(a){a?(this.Ja=0,this.flush()):(this.h("Failed to remove items from queue"),5<++this.Ja?(this.h("Too many queue failures; disabling batching system."),this.jd()):this.ea())},this)),c.a(h,c.bind(function(a){var b=a.id;b?(this.G[b]=

{
"name": "mixpanel-browser",
"version": "2.52.0",
"version": "2.53.0",
"description": "The official Mixpanel JavaScript browser client library",

@@ -5,0 +5,0 @@ "main": "dist/mixpanel.cjs.js",

var Config = {
DEBUG: false,
LIB_VERSION: '2.52.0'
LIB_VERSION: '2.53.0'
};
export default Config;

@@ -40,2 +40,4 @@ import './mixpanel-jslib-snippet';

'set_group',
'start_session_recording',
'stop_session_recording',
'time_event',

@@ -42,0 +44,0 @@ 'track',

@@ -7,2 +7,3 @@ import {default as record} from 'rrweb/es/rrweb/packages/rrweb/src/record/index.js';

var logger = console_with_prefix('recorder');
var CompressionStream = window['CompressionStream'];

@@ -117,2 +118,13 @@ var MixpanelRecorder = function(mixpanelInstance) {

MixpanelRecorder.prototype._sendRequest = function(reqParams, reqBody) {
window['fetch'](this.get_config('api_host') + '/' + this.get_config('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
'method': 'POST',
'headers': {
'Authorization': 'Basic ' + btoa(this.get_config('token') + ':'),
'Content-Type': 'application/octet-stream'
},
'body': reqBody
});
};
/**

@@ -125,5 +137,4 @@ * @api private

if (numEvents > 0) {
var reqBody = {
var reqParams = {
'distinct_id': String(this._mixpanel.get_distinct_id()),
'events': this.recEvents,
'seq': this.seqNo++,

@@ -135,2 +146,3 @@ 'batch_start_time': this.batchStartTime / 1000,

};
var eventsJson = _.JSONEncode(this.recEvents);

@@ -140,19 +152,24 @@ // send ID management props if they exist

if (deviceId) {
reqBody['$device_id'] = deviceId;
reqParams['$device_id'] = deviceId;
}
var userId = this._mixpanel.get_property('$user_id');
if (userId) {
reqBody['$user_id'] = userId;
reqParams['$user_id'] = userId;
}
window['fetch'](this.get_config('api_host') + '/' + this.get_config('api_routes')['record'], {
'method': 'POST',
'headers': {
'Authorization': 'Basic ' + btoa(this.get_config('token') + ':'),
'Content-Type': 'application/json'
},
'body': _.JSONEncode(reqBody)
});
this.recEvents = this.recEvents.slice(numEvents);
this.batchStartTime = new Date().getTime();
if (CompressionStream) {
var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
new Response(gzipStream)
.blob()
.then(_.bind(function(compressedBlob) {
reqParams['format'] = 'gzip';
this._sendRequest(reqParams, compressedBlob);
}, this));
} else {
reqParams['format'] = 'body';
this._sendRequest(reqParams, eventsJson);
}
}

@@ -159,0 +176,0 @@ });

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc