Open sachinmour opened 4 years ago
Sorry it's not as clear as it should be. The HTTP doc you linked says "The Mixpanel HTTP tracking API accepts POST and GET requests" - and what that means is that either one can be used for the exact same types of requests, the only difference being whether the payload is encoded as a URL param or in the request body. Either one will work for any number of events. The only difference between tracking a single event vs multiple events is that you can send a single event without putting it in a JSON array, but that's basically a shorthand for the sake of convenience.
This library will soon support batching multiple events into a single request, but that happens behind the scenes. You'll still need to make a .track()
call for each event.
ah ok. Is there a specific reason as to why we prefer POST
request over GET
.
I am assuming because of payload
limit on GET
.
Also in the documentation it's not clear how the retry mechanism work or if it works. If you can elaborate, i can make a pull request to update the documentation.
The most compelling reason is indeed that you can send a much larger payload in the request body, pretty much a necessity if you're going to send event batches at once.
The SDK currently doesn't have any built-in retries. This is something we're releasing soon as part of a batching/queueing infrastructure, but it should be basically transparent to the developer. You'll still simply be calling mixpanel.track()
, and the SDK will do its best to make sure the data makes it to our API servers even if there's a temporary problem, device is currently offline etc.
According to https://developer.mixpanel.com/docs/http
GET
requests are used for single event tracking andPOST
requests are used for multiple event tracking which will send an array of events.But the
mixpanel-js
library itself usesPOST
request by default to send asingle
event. Also there is no way to send multiple events directly usingmixpanel-js
.It would be nice to have some clarification on this.