snowplow / snowplow-python-tracker

Snowplow event tracker for Python. Add analytics to your Python and Django apps, webapps and games
Apache License 2.0
43 stars 67 forks source link

Use Requests session for sending events (close #221) #332

Closed Jack-Keene closed 1 year ago

Jack-Keene commented 1 year ago

This PR adds the ability for users to parse in a session object to the emitter, increasing efficiency of the tracker under heavy usage by pooling connections.

matus-tomlein commented 1 year ago

Sorry for coming back to this later, but I just realized that a side effect of always using a session object to make requests is that cookies will be maintained which will result in the network user ID being the same on all events from the app. This would be good if the Python tracker was used in a client side app, but on server side, we don't really want to have all events share the same network user ID since they are coming from different users event within the same server app.

I am thinking that it might be better to not use the Session object unless explicitly passed from the user. So in case, the user doesn't provide a session, maybe we should still be making requests using requests.post(...) and requests.get() instead of session.post() and session.get(). What do you think?