mixpanel / mixpanel-js

Official Mixpanel JavaScript Client Library
https://mixpanel.com/help/reference/javascript
Other
867 stars 309 forks source link

JSON Encoder breaks unicode characters on emojis 🌳 #385

Open 1oglop1 opened 10 months ago

1oglop1 commented 10 months ago

Hi, I'm working on Mixpanel proxy for further analytics and my code is failing to reconstruct input data which contain UTF-8 emojis.

I suspect the root cause is the custom JSON Encoder https://github.com/mixpanel/mixpanel-js/blob/8ac526e5cb8563d11e2206046ab986c6491ac6d7/src/utils.js#L393-L416

which corrupts unicode characters Input

{"event": "🌳"}

Expected output:

{\"event\": \"\xf0\x9f\x8c\xb3\"}

actual SDK output:

{\"event\": \"\xed\xa0\xbc\xed\xbc\xb3\"}