mixpanel-js icon indicating copy to clipboard operation
mixpanel-js copied to clipboard

LocalStorage `_mpq_` flush queue accumulate events

Open JonLev opened this issue 2 years ago • 11 comments

Hi guys, I noticed a strange behaviour with Mixpanel events localStorage usage: I have some of my user that have in their local storage a key that just accumulate elements of tracking: mixpanel-flush-queue-blurred

From my investigation this element is a kind of batch accumulation to flush to mixpanel with some debounce. But for some reason I don't know yet, they accumulate within the storage instead. My deeper problem is that other services that are based on storage are failing because there's so much elements that the storage limit is reached 😅.

My config is:

  • version 2.47.0
  • on Vue3

Let me know if you need more information

JonLev avatar Jul 25 '23 13:07 JonLev

Hi @JonLev, yes, it would be very useful to get more info on your specific setup and the monitoring you have on users who hit this condition (it's likely specific to some combo of browser version, extensions, os etc). Can you email me at [email protected]? Thanks

tdumitrescu avatar Jul 25 '23 17:07 tdumitrescu

Just did ! 🙏🏽

JonLev avatar Jul 26 '23 08:07 JonLev

I've got the same problem. Would love to know if you find out why this is happening.

hrvbernardic avatar Aug 03 '23 06:08 hrvbernardic

Same problem here. Will write some code to flush those localstorage keys during app start, but would be nice to not have to do that.

Current guess is that ublock is blocking the request that would flush the queue, which causes events to accumulate.

EDIT: Upgrading from mixpanel-browser 2.41 to 2.49 seems to have fixed the issue.

tomlagier avatar Feb 20 '24 00:02 tomlagier

Happening to us as well. My guess is that adblockers are preventing mixpanel events so they never get sent (or flushed). We will update to 2.49 and hope that fixes it

hussain-nz avatar Mar 01 '24 10:03 hussain-nz

@hussain-s6 did you solve it? I couldn't

Colombo97 avatar May 08 '24 16:05 Colombo97

@hussain-s6 did you solve it? I couldn't

No idea. It happened to my colleague and I was hoping it would fix the issue. I will try and check with him to see if it's still there. I didn't find any difficulty in upgrading to the newer version, did you try it? It's quite easy to diagnose, you can look for "mpq" items and see if they are getting big or not (100-500kb or greater), just run this script below, it is sorting in ascending order:

var _lsTotal=0,_xLen,_x,_lsData=[];for(_x in localStorage){if(localStorage.hasOwnProperty(_x)){_xLen=((localStorage[_x].length+_x.length)*2);_lsTotal+=_xLen;_lsData.push({key:_x,size:_xLen});}}_lsData.sort((a,b)=>a.size-b.size).forEach(item=>console.log(item.key.substr(0,50)+" = "+(item.size/1024).toFixed(2)+" KB"));console.log("Total = "+(_lsTotal/1024).toFixed(2)+" KB");

goamn avatar May 14 '24 01:05 goamn

Yes I tried to update but it didn't solve. About the script, yes, I've added one to check the storage size, almost the same that you've shared.

Colombo97 avatar May 14 '24 01:05 Colombo97

I'm thinking about making a workaround to solve this deleting the mpq from the localstorage

Colombo97 avatar May 14 '24 01:05 Colombo97

I'm thinking about making a workaround to solve this deleting the mpq from the localstorage

I think it's valid to use a workaround, otherwise users will have a crashed app with no way to recover. Thanks for letting me know, we will probably implement the workaroudn as well :)

goamn avatar May 14 '24 01:05 goamn

Hey , is this fixed? in 2.59

pranshu26 avatar Jan 21 '25 19:01 pranshu26