Created
October 28, 2020 09:15
-
-
Save codebubb/b8bde70a9aa8be792973dedd436b9193 to your computer and use it in GitHub Desktop.
Beacon and PageVisibility API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener('visibilitychange', () => { | |
| if (document.visibilityState === 'hidden') { | |
| window.navigator.sendBeacon('/log', 'session ended'); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment