Bug: 'token' property added to objects sent to track() on Safari / Firefox
Closed this issue · 3 comments
Hi
when tracking events with mixpanel, I noticed a weird bug happening in safari and firefox (doesn't happen in chrome).
when I'm calling mixpanel's track
method and pass an object to be logged with the message (as the second argument), this object is being mutated and added a property token
(with the value of my mixpanel token).
screenshot from safari console after printing the object:
this is unexpected and unwanted behaviour as I sometimes pass an object to track
that is also used in other places in the code, and for users using safari / firefox the object is being mutated and sometimes saved / sent to 3rd parties (i.e. local storage, api calls) with this property, which is obviously a risk.
relevant code:
track('obj will be mutated on safari', obj);
versions:
mixpanel-browser: 2.46.0
safari: 16.5 (18615.2.9.11.4)
firefox: 116.0.3 (64-bit)
expected behaviour:
objects passed to track
shouldn't be mutated by mixpanel
possible workaround:
using the deconstructing syntax
track('obj will not be mutated', { ...obj });
Duplicate of #183. Haven't heard about Chrome behaving differently before, though.
Ohh, I didn't see the previous issues.
I see the first issue is from 2016, is it going to be fixed at any point? just so I know for next times I use mixpanel.
about Chrome, I found it weird too, but it didn't reproduce there.
This should be fixed as of https://github.com/mixpanel/mixpanel-js/releases/tag/v2.48.0