Skip to content

Commit

Permalink
Add logging for connection loss
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielrindlaub committed Jan 23, 2024
1 parent d30b6dd commit b9e6e77
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ const App = () => {
// });
// }, [dispatch]);

// Monitor connection loss
useEffect(() => {
const handleOffline = (e) => {
const now = new Date();
console.log(`Lost internet connection at ${now.toISOString()}`);
}
window.addEventListener('offline', handleOffline);
return () => { window.removeEventListener('offline', handleOffline) }
}, []);

useEffect(() => {
const handleOnline = (e) => {
const now = new Date();
console.log(`Regained internet connection at ${now.toISOString()}`);
}
window.addEventListener('online', handleOnline);
return () => { window.removeEventListener('online', handleOnline) }
}, []);

useEffect(() => {
dispatch(initTracking(GA_CONFIG));
}, [ dispatch ]);
Expand Down

0 comments on commit b9e6e77

Please sign in to comment.