OdyseeTeam / odysee-frontend

The code that runs odysee.com
https://odysee.com
MIT License
214 stars 68 forks source link

Persist clickstream data for send after tab close #1318

Closed jbn closed 2 years ago

jbn commented 2 years ago

We tried using beacons, but they get blocked too often, making it hard to get some (or any!) information on some user preferences. Now we are back to doing normal fetches. However, this is a problem because it means the video watched before the last tab close doesn't get sent. This is a surprisingly large set of plays.

If possible, I'd like the clickstream data to be stored in state, but get cleared when finalized. That is,

  1. When the user is done with a stream, send it and clear that state entry;
  2. If it is playing and loaded, periodically flush the information to state, and on the next visit, do (2)

IDK react well enough to know if this is too expensive (cpu/battery) or slow. But even flushing for every 30 seconds of play would be a large improvement for me.

tzarebczan commented 2 years ago

@infinite-persistence wanna take a stab in some of your "spare" time? The idea would be to save the recsys object in redux at some interval, and clear out once sent. If it's not sent, on subsequent start-up, send it, and clear from redux.

I asked @jbn to see if we should send some additional flag to tag these.

infinite-persistence commented 2 years ago

Sure, will try!