mixpanel / mixpanel-node

A node.js API for mixpanel
http://www.mixpanel.com
MIT License
476 stars 159 forks source link

import function sends as a GET request #187

Open penfold45 opened 3 years ago

penfold45 commented 3 years ago

I feel like I am missing something. It looks to me as though import() sends the request as a GET request when it should be a POST request according to the docs

The import function calls send_event_request() which is always a get request as it does this metrics.send_request({ method: "GET", endpoint: endpoint, data: data }, callback);

Can someone point me in the right direct on what I am doing wrong?

Thanks

tdumitrescu commented 3 years ago

The API will accept either GET or POST. For importing a single event with mixpanel.import(), the GET should work fine. If you want to send very large payloads or multiple events at once, you can use import_batch() which uses POST under the hood.

penfold45 commented 3 years ago

Is this not bad from a data leakage point of view as posting data with a GET request will mean the data is more likely to end up in log files.

tdumitrescu commented 3 years ago

That's a concern if you run your own tracking proxy and log all query params and are worried about your event payloads ending up in your internal logs. For Mixpanel's official ingestion API (api.mixpanel.com), we don't do that kind of logging.

That said, at this point there's no downside to converting this whole lib to use POST, pull requests welcome.