From a710f11ca3c429d6aa31058b452f40997b3f0cdb Mon Sep 17 00:00:00 2001 From: Akshita-2307 Date: Thu, 4 Jun 2026 13:02:47 +0530 Subject: [PATCH] fix: remove debug console logs and standardize logging Removes all console.log, console.debug, and console.info statements that were cluttering the console with unnecessary runtime information. Keeps all console.warn and console.error for meaningful diagnostics. Files cleaned: - src/offline-sync.js: removed 5 console.log + 1 console.info - src/cloud-sync.js: removed 4 console.log + 3 console.debug - src/conflict-resolver.js: removed 3 console.debug - src/app.js: removed 2 console.info + 1 console.debug Closes #637 --- src/app.js | 5 ----- src/cloud-sync.js | 8 -------- src/conflict-resolver.js | 3 --- src/offline-sync.js | 6 ------ 4 files changed, 22 deletions(-) diff --git a/src/app.js b/src/app.js index 5883ebf..593b5a0 100644 --- a/src/app.js +++ b/src/app.js @@ -24,8 +24,6 @@ const QUALITY_LEDGER_KEY = STORAGE_KEY_PREFIX + "quality-ledger"; const AUTOMATION_PIPELINE_KEY = STORAGE_KEY_PREFIX + "automation-pipeline"; const SESSION_STATE_KEY = STORAGE_KEY_PREFIX + 'active-session'; -console.debug('APP JS loaded'); - function saveActiveSession(accountId, viewId) { try { const payload = { accountId, lastView: viewId || '', timestamp: Date.now() }; @@ -71,7 +69,6 @@ function isViewValidForRole(viewId, role) { if ('serviceWorker' in navigator) { navigator.serviceWorker.register('service-worker.js') .then(reg => { - console.info('☁️ ReGenX SW v3 Registered'); window._swReg = reg; // Listen for Background Sync completion messages from SW @@ -5345,8 +5342,6 @@ if ('serviceWorker' in navigator) { window.addEventListener('load', async () => { try { const registration = await navigator.serviceWorker.register('/service-worker.js'); - - console.info('Service Worker registered:', registration.scope); } catch (error) { console.error('Service Worker registration failed:', error); } diff --git a/src/cloud-sync.js b/src/cloud-sync.js index d7180c1..0d3dd38 100644 --- a/src/cloud-sync.js +++ b/src/cloud-sync.js @@ -215,11 +215,9 @@ export const CloudSync = { if (!CloudSync.client || !CloudSync.config) return; const channel = `databases.${CloudSync.config.databaseId}.collections.${CloudSync.config.ordersCollectionId}.documents`; - console.debug(`📡 Subscribed to Appwrite Realtime: ${channel}`); try { CloudSync.unsubscribe = CloudSync.client.subscribe(channel, response => { - console.debug("⚡ Appwrite Realtime Event Received:", response); const syncedOrder = response.payload; if (!syncedOrder || !syncedOrder.id) return; @@ -235,7 +233,6 @@ export const CloudSync = { localOrder.riderName !== syncedOrder.riderName; if (hasChanged) { - console.log(`🔄 Synced order [${syncedOrder.id}] has changes. Saving locally.`); const originalLive = CloudSync.isLive; CloudSync.isLive = false; @@ -325,7 +322,6 @@ export const CloudSync = { payload.id, sanitizedDoc ); - console.log(`☁️ Synced to Appwrite (Updated) -> Collection [${ordersCollectionId}]`, sanitizedDoc); } catch (updateErr) { if (updateErr.code === 404) { await CloudSync.databases.createDocument( @@ -334,7 +330,6 @@ export const CloudSync = { payload.id, sanitizedDoc ); - console.log(`☁️ Synced to Appwrite (Created) -> Collection [${ordersCollectionId}]`, sanitizedDoc); } else { throw updateErr; } @@ -461,7 +456,6 @@ export const CloudSync = { const filtered = queue.filter(item => item.key !== key); filtered.push({ key, data, ts: Date.now() }); localStorage.setItem('regenx-offline-queue', JSON.stringify(filtered)); - console.debug(`[CloudSync] Queued offline write for key: ${key}`); } catch (e) { console.warn('[CloudSync] Failed to queue offline write:', e); } @@ -482,7 +476,6 @@ export const CloudSync = { try { const queue = JSON.parse(localStorage.getItem('regenx-offline-queue') || '[]'); if (queue.length === 0) return; - console.log(`[CloudSync] Flushing ${queue.length} offline queued writes...`); const failed = []; for (const item of queue) { try { @@ -547,7 +540,6 @@ export const CloudSync = { } CloudSync.renderSyncBadge('live', 'Cloud Live'); - console.log(`☁️ Hydrated from cloud: account + ${cloudOrders.length} orders`); // Refresh the current dashboard view with fresh data window.refreshCurrentView?.(true); diff --git a/src/conflict-resolver.js b/src/conflict-resolver.js index 83964c7..4210049 100644 --- a/src/conflict-resolver.js +++ b/src/conflict-resolver.js @@ -20,7 +20,6 @@ export function resolveConflict(localAction, serverData) { // If no server data exists, local action wins if (!serverData) { - console.debug(`[ConflictResolver] No server data — local action applied: ${localAction.id}`); return localAction; } @@ -36,7 +35,6 @@ export function resolveConflict(localAction, serverData) { return null; } - console.debug(`[ConflictResolver] Local action is newer — applying: ${localAction.id}`); return localAction; } @@ -85,7 +83,6 @@ export function mergeGPSUpdates(actions) { current.timestamp > latest.timestamp ? current : latest ); - console.debug(`[ConflictResolver] Merged ${gpsActions.length} GPS actions → 1 kept`); return [...otherActions, latestGPS]; } diff --git a/src/offline-sync.js b/src/offline-sync.js index f41f2b1..14b7b12 100644 --- a/src/offline-sync.js +++ b/src/offline-sync.js @@ -33,7 +33,6 @@ export function initOfflineDB() { request.onsuccess = (event) => { db = event.target.result; - console.info('[OfflineSync] IndexedDB initialized'); resolve(db); }; @@ -87,7 +86,6 @@ export function queueOfflineAction(type, payload) { const request = store.add(action); request.onsuccess = () => { - console.log(`[OfflineSync] Action queued: ${type} (${action.id})`); updateSyncUI('pending'); resolve(action.id); }; @@ -147,14 +145,12 @@ export async function syncPendingActions() { return; } - console.log(`[OfflineSync] Syncing ${actions.length} pending actions...`); updateSyncUI('syncing'); for (const action of actions) { try { await processAction(action); await removeAction(action.id); - console.log(`[OfflineSync] Synced: ${action.type} (${action.id})`); } catch (error) { console.warn(`[OfflineSync] Failed to sync: ${action.id}`, error); await handleRetry(action); @@ -260,13 +256,11 @@ export function updateSyncUI(status) { */ export function setupNetworkListeners() { window.addEventListener('online', async () => { - console.log('[OfflineSync] Back online — starting sync...'); showOfflineBanner(false); await syncPendingActions(); }); window.addEventListener('offline', () => { - console.log('[OfflineSync] Gone offline'); showOfflineBanner(true); updateSyncUI('pending'); });