You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flagon.apache.org by GitBox <gi...@apache.org> on 2021/03/19 02:44:01 UTC

[GitHub] [incubator-flagon-useralejs] poorejc commented on issue #50: sendOnClose function broken -- logs dropped when users navigate away from page

poorejc commented on issue #50:
URL: https://github.com/apache/incubator-flagon-useralejs/issues/50#issuecomment-802497782


   Updated sendOnClose to flush logs queue:
   
   ```
   export function sendOnClose(logs, config) {
     document.addEventListener('visibilitychange', function () {
       if (document.visibilityState === 'hidden' && logs.length > 0) {
         navigator.sendBeacon(config.url, JSON.stringify(logs));
         logs.splice(0); // Clear array reference (no reassignment)
     }
   });
   ```
   resolves issue that any visibility change to 'hidden' state will send duplicate logs (e.g., switching tabs). This is desired behavior/intent for this function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org