snowplow / snowplow-java-tracker

Snowplow event tracker for Java. Add analytics to your Java desktop and server apps, servlets and games. (See also: snowplow-android-tracker)
http://snowplowanalytics.com
Apache License 2.0
23 stars 36 forks source link

Add support for storing cookies in OkHttpClientAdapter (close #336) #342

Closed mscwilson closed 2 years ago

mscwilson commented 2 years ago

For issue #336.

This change brings a new feature of the Android tracker (issue 519), released in v3.2.0 to the Java tracker. OkHTTP's CookieJar interface is used to store cookies from the event collector. The cookie can then be added to subsequent requests - the events will then all have the same network_userid.

There are some differences in implementation between Android and Java trackers. For Android, Shared Preferences is used to persistently store tracker state in the user's device. By storing cookies there too, they can be shared across instances of the CollectorCookieJar.

For the Java tracker, we currently only store things in memory. Cookies are stored in a static Set in memory here. Also, the architecture/naming around the HTTP clients is slightly different, e.g. Android has NetworkConnection while Java has HttpClientAdapter.

mscwilson commented 2 years ago

Having it off by default seemed like a good idea, I've changed it. We could do with improving the docs for client-side users in general - it assumes server-side. Plus the tracker doesn't have sessions.