ploner / RMixpanel

RMixpanel - Mixpanel API client package for R
Other
18 stars 6 forks source link

Error: lexical error: invalid character inside string #8

Open oriolcosp opened 4 years ago

oriolcosp commented 4 years ago

Hi, When running:

tmp = mixpanelGetEvents(account, from = date, to = date, daysPerBlock = 10,
                          select = vars, verbose = TRUE, df = TRUE, encoding="UTF-8")

I was getting the error:

Error: lexical error: invalid character inside string.
          amsung","$carrier":"DAIS-Virgi ",
                    (right here) ------^

Apparently, Mixpanel was putting some invalid json character on the data we were getting and that was causing the error.

I managed to fix it by going into the function eventsJson2RMatrix and adding at the start:

jsonData = gsub('\x06','',jsonData)

I hope this helps improve the package. Thanks!

christerwi commented 4 years ago

Hi, we have the same issue sometimes – note that it is not an error on the mixpanel side: they are sending you the data as it was ingested from the SDK (the carrier has a funky name...) The core problem is that the used package jsonlite has become very strict about throwing errors when the json is improper since package version 0.9.12 –– so if it is feasible for you, you can install the specific previous version (0.9.11) just for getting the data you need. Other than that, it might go better with jsonlite::streamin, since mixpanel sends line-complete json... reference: https://github.com/jeroen/jsonlite/issues/59

dlazarou commented 3 years ago

the solution from @oriolcosp doesn't work anymore unfortunately. Any other idea to circumvent the issue? Using R 4.0 and the most updated package of Rmixpanel.