Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scmmmh committed Dec 18, 2023
1 parent 6113063 commit d046fa0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions museum_map/server/frontend/src/store/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export function track(action: LogAction) {
}
}

/**
* Send the tracking data to the server and exit.
*/
function sendTracking() {
async () => {
window.fetch('/api/tracking/track/' + userId, {
Expand All @@ -70,6 +73,9 @@ function sendTracking() {
}
}

/**
* Listen to visibilitychange events and send tracking data when hiding.
*/
window.addEventListener("visibilitychange", () => {
if (document.visibilityState === "hidden") {
window.clearTimeout(trackTimeout);
Expand Down

0 comments on commit d046fa0

Please sign in to comment.