From 5d404f57335773e673273567e7191cd6e5626532 Mon Sep 17 00:00:00 2001 From: Krystie Date: Thu, 14 May 2026 00:48:51 -0700 Subject: [PATCH] cleanup: wrap console.log calls behind window.DASHCADDY_DEBUG flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrapped 22 console.log calls across 6 files with a debug() helper that only logs when window.DASHCADDY_DEBUG is true in the browser console. Files: - tour-manager.js: 10 calls - theme-adapter.js: 4 calls - keyboard-shortcuts.js: 4 calls - tooltip-definitions.js: 2 calls - progress-tracker.js: 1 call - live-events.js: 1 call console.error and console.warn calls preserved — those indicate real issues worth seeing in production. --- status/js/keyboard-shortcuts.js | 12 ++++++++---- status/js/live-events.js | 2 +- status/js/progress-tracker.js | 6 +++++- status/js/theme-adapter.js | 12 ++++++++---- status/js/tooltip-definitions.js | 8 ++++++-- status/js/tour-manager.js | 24 ++++++++++++++---------- 6 files changed, 42 insertions(+), 22 deletions(-) diff --git a/status/js/keyboard-shortcuts.js b/status/js/keyboard-shortcuts.js index 2080750..091ead3 100644 --- a/status/js/keyboard-shortcuts.js +++ b/status/js/keyboard-shortcuts.js @@ -6,6 +6,10 @@ (function() { 'use strict'; + const debug = (...args) => { + if (window.DASHCADDY_DEBUG) { console.log(...args); } + }; + // All modal selectors that can be closed with Escape const MODAL_SELECTORS = [ '#app-selector-modal', @@ -39,9 +43,9 @@ // Add global keyboard listener document.addEventListener('keydown', handleKeyDown); - console.log('[Keyboard Shortcuts] Initialized'); - console.log('[Keyboard Shortcuts] Press Ctrl+K to open quick search'); - console.log('[Keyboard Shortcuts] Press Escape to close modals'); + debug('[Keyboard Shortcuts] Initialized'); + debug('[Keyboard Shortcuts] Press Ctrl+K to open quick search'); + debug('[Keyboard Shortcuts] Press Escape to close modals'); } catch (e) { console.warn('[Keyboard Shortcuts] Failed to initialize:', e.message); } @@ -599,7 +603,7 @@ } break; default: - console.log('[Keyboard Shortcuts] Unknown action:', action); + debug('[Keyboard Shortcuts] Unknown action:', action); } } catch (e) { console.warn('[Keyboard Shortcuts] Error executing action:', e.message); diff --git a/status/js/live-events.js b/status/js/live-events.js index 7a54ebd..0eb8e75 100644 --- a/status/js/live-events.js +++ b/status/js/live-events.js @@ -11,7 +11,7 @@ es.addEventListener('connected', () => { reconnectDelay = 1000; // reset backoff - console.log('[SSE] Connected to event stream'); + debug('[SSE] Connected to event stream'); }); // Health status changes → update card dots/badges in real time diff --git a/status/js/progress-tracker.js b/status/js/progress-tracker.js index 9fb2757..035790a 100644 --- a/status/js/progress-tracker.js +++ b/status/js/progress-tracker.js @@ -18,6 +18,10 @@ (function(window) { 'use strict'; + const debug = (...args) => { + if (window.DASHCADDY_DEBUG) { console.log(...args); } + }; + /** * ProgressTracker class * Manages persistent storage of onboarding progress @@ -308,6 +312,6 @@ // Export to global scope window.ProgressTracker = ProgressTracker; - console.log('[ProgressTracker] Module loaded'); + debug('[ProgressTracker] Module loaded'); })(window); diff --git a/status/js/theme-adapter.js b/status/js/theme-adapter.js index e79ae88..3e45e63 100644 --- a/status/js/theme-adapter.js +++ b/status/js/theme-adapter.js @@ -7,6 +7,10 @@ (function(window) { 'use strict'; + const debug = (...args) => { + if (window.DASHCADDY_DEBUG) { console.log(...args); } + }; + /** * Theme configuration mapping for Driver.js * Maps dashboard themes to Driver.js styling @@ -170,7 +174,7 @@ attributeFilter: ['class'] }); - console.log('[ThemeAdapter] Theme change listener initialized'); + debug('[ThemeAdapter] Theme change listener initialized'); } /** @@ -180,7 +184,7 @@ * @param {string} oldTheme - Old theme name */ _notifyThemeChange(newTheme, oldTheme) { - console.log(`[ThemeAdapter] Theme changed: ${oldTheme} → ${newTheme}`); + debug(`[ThemeAdapter] Theme changed: ${oldTheme} → ${newTheme}`); this.themeChangeCallbacks.forEach(callback => { try { @@ -207,7 +211,7 @@ // Note: Driver.js v1.0+ uses CSS variables, so we inject a style element this._injectDriverStyles(themeConfig); - console.log('[ThemeAdapter] Theme applied to driver:', this.currentTheme); + debug('[ThemeAdapter] Theme applied to driver:', this.currentTheme); } /** @@ -302,6 +306,6 @@ // Export to global scope window.ThemeAdapter = ThemeAdapter; - console.log('[ThemeAdapter] Module loaded'); + debug('[ThemeAdapter] Module loaded'); })(window); diff --git a/status/js/tooltip-definitions.js b/status/js/tooltip-definitions.js index 970b583..0509499 100644 --- a/status/js/tooltip-definitions.js +++ b/status/js/tooltip-definitions.js @@ -6,6 +6,10 @@ (function(window) { 'use strict'; + const debug = (...args) => { + if (window.DASHCADDY_DEBUG) { console.log(...args); } + }; + /** * Validate a tooltip definition * @param {Object} tooltip - The tooltip definition to validate @@ -160,7 +164,7 @@ TooltipError }; - console.log('[TooltipDefinitions] Validation module loaded'); + debug('[TooltipDefinitions] Validation module loaded'); })(window); @@ -534,5 +538,5 @@ window.TooltipDefinitions = { getNewFeatureTooltips }; -console.log('[TooltipDefinitions] Definitions loaded:', TOOLTIP_DEFINITIONS.length, 'tooltips'); +debug('[TooltipDefinitions] Definitions loaded:', TOOLTIP_DEFINITIONS.length, 'tooltips'); diff --git a/status/js/tour-manager.js b/status/js/tour-manager.js index 7b60d2a..d1b92a6 100644 --- a/status/js/tour-manager.js +++ b/status/js/tour-manager.js @@ -6,6 +6,10 @@ (function(window) { 'use strict'; + const debug = (...args) => { + if (window.DASHCADDY_DEBUG) { console.log(...args); } + }; + class TourManager { constructor(progressTracker, themeAdapter, dnsTemplateSelector) { this.progressTracker = progressTracker; @@ -92,7 +96,7 @@ const activeTooltips = allTooltips.filter(t => !completedIds.includes(t.id)); if (activeTooltips.length === 0) { - console.log('[TourManager] No tooltips to show'); + debug('[TourManager] No tooltips to show'); this.progressTracker.markTourCompleted(); return; } @@ -131,7 +135,7 @@ // Add custom handlers for DNS tooltip if (tooltip.id === 'dns-priority' && this.dnsTemplateSelector) { step.popover.onSetupNowClick = () => { - console.log('[TourManager] Opening DNS template selector'); + debug('[TourManager] Opening DNS template selector'); this.dnsTemplateSelector.showTemplateSelector(); // Mark tooltip as completed and move to next this.progressTracker.markTooltipCompleted(tooltip.id); @@ -141,7 +145,7 @@ }; step.popover.onLaterClick = () => { - console.log('[TourManager] DNS setup deferred'); + debug('[TourManager] DNS setup deferred'); this.progressTracker.markDnsSetupDeferred(); // Mark tooltip as completed and move to next this.progressTracker.markTooltipCompleted(tooltip.id); @@ -232,11 +236,11 @@ const newFeatureTooltips = window.TooltipDefinitions.getNewFeatureTooltips(); if (newFeatureTooltips.length === 0) { - console.log('[TourManager] No new features to show'); + debug('[TourManager] No new features to show'); return; } - console.log(`[TourManager] Showing ${newFeatureTooltips.length} new features`); + debug(`[TourManager] Showing ${newFeatureTooltips.length} new features`); // Convert to Driver.js steps const steps = newFeatureTooltips.map((tooltip, index) => { @@ -280,7 +284,7 @@ clearTimeout(resizeTimeout); resizeTimeout = setTimeout(() => { if (this.isActive && this.driver) { - console.log('[TourManager] Window resized, repositioning tooltip'); + debug('[TourManager] Window resized, repositioning tooltip'); this.driver.refresh(); } }, 150); // Debounce for 150ms @@ -289,7 +293,7 @@ // Layout change handler (for theme changes, DOM mutations) this.layoutChangeHandler = () => { if (this.isActive && this.driver) { - console.log('[TourManager] Layout changed, repositioning tooltip'); + debug('[TourManager] Layout changed, repositioning tooltip'); // Small delay to allow layout to settle setTimeout(() => { if (this.driver) { @@ -347,7 +351,7 @@ onTourComplete() { this.progressTracker.markTourCompleted(); this.isActive = false; - console.log('[TourManager] Tour completed'); + debug('[TourManager] Tour completed'); } /** @@ -355,12 +359,12 @@ */ onTourSkip() { // Save current progress but don't mark as completed - console.log('[TourManager] Tour skipped'); + debug('[TourManager] Tour skipped'); this.isActive = false; } } window.TourManager = TourManager; - console.log('[TourManager] Module loaded'); + debug('[TourManager] Module loaded'); })(window);