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

Mixpanel Server Error: 0

Open devshorts opened this issue 4 years ago • 5 comments

I am getting this error semi frequently on a consistent event type and I can't seem to tell if there is something in the payload that is causing this or if this is something else. Is there any insight to be found what server error 0 means?

devshorts avatar Sep 08 '21 18:09 devshorts

You can initialize the library with {verbose: true, debug: true} and that should give some console logging of error messages from the API.

tdumitrescu avatar Sep 08 '21 20:09 tdumitrescu

I see, thanks for that. Unfortunately, I can't really repo this local and I am seeing this in production. I'd rather not enable this in production, is there no information about what this error code could mean so I could try and dig a little further?

devshorts avatar Sep 08 '21 20:09 devshorts

Unfortunately not - in the non-verbose default API mode, "0" is a catch-all for any error.

tdumitrescu avatar Sep 08 '21 20:09 tdumitrescu

I was able to find the error in verbose mode, but for what its worth it would be much more helpful from an integration standpoint to just throw the error properly. Having 0 as a catch-all is useless and not helpful. I don't think there's a reason to hide the errors given this is a b2b integration

For anyone else who gets this, my issue was backdating an event older than 5 days. The error was

Mixpanel Server Error: time, 17.1 days in the past (max 5.0

devshorts avatar Sep 09 '21 22:09 devshorts

@devshorts

yes, this the design of the /track API ... nothing older than 5 days

should you wish to import events older than 5 days, you can init the library with an API secret and then use the .import() method to send an older timestamp:

const mixpanel = Mixpanel.init('{{token}}', {
    secret: ' {{api secret}}'
});

mixpanel.import('super old event', new Date(2019, 4, 20, 12, 34, 56), {
    distinct_id: 'ak',
});

if you don't know the 'age' of the event ahead of time, there is no downside to using .import() for everything.

ak--47 avatar Mar 11 '22 19:03 ak--47