0

I am developing a flask Application, now the requirement is to log the time when the user closes a specific flask view (or exits a flask URL). Simple example would be suppose a user is working on '/home' and now closes the browser tab or the browser itself. Then how to record the time for this particular event?

Please help

abhi_47
  • 25
  • 6
  • What have you tried? How critical is this... such as browser crashes, power fail etc? – charlietfl Aug 17 '20 at 04:34
  • @charlietfl I have tried using SocketIO but it slows down the app very much. This is critical from analytics point of view because I want to track the time for which a user opened a URL, used it and then closed the URL. – abhi_47 Aug 17 '20 at 04:44
  • Take a look at `navigator.sendBeacon()` API. Google analytics or similar service might be another choice – charlietfl Aug 17 '20 at 04:57
  • @charlietfl Thank you so much, I'll try to implement it and get back to you in case I face any issues. appreciate your quick help! – abhi_47 Aug 17 '20 at 05:18

1 Answers1

0

This worked for me with similar use case as ajax calls cannot be made anymore so please use navigator.sendBeacon

https://stackoverflow.com/a/20322988/10738743

Sid
  • 9
  • 1
  • 3