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:
[email protected]


Reply via email to