add analytics

This commit is contained in:
2026-06-05 00:11:45 -03:00
parent a2947b3bf2
commit fd8e9049bf
35 changed files with 1540 additions and 30 deletions

View File

@@ -0,0 +1,30 @@
export class NetworkDetector {
constructor() {
this.isOnline = navigator.onLine;
this.listeners = [];
}
subscribe(listener) {
this.listeners.push(listener);
window.addEventListener('online', () => {
this.isOnline = true;
this.listeners.forEach(l => l(true));
});
window.addEventListener('offline', () => {
this.isOnline = false;
this.listeners.forEach(l => l(false));
});
return () => {
this.listeners = this.listeners.filter(l => l !== listener);
};
}
getStatus() {
return this.isOnline;
}
}
export const networkDetector = new NetworkDetector();