From b95d1dc46125a93830d105be0f207103b4c8fe3b Mon Sep 17 00:00:00 2001 From: jknapp Date: Fri, 23 Jan 2026 19:27:26 -0800 Subject: [PATCH] Remove debug logging from browser phone Debug code was added to diagnose mobile connection issues. The fix (polling for SDK instead of waiting for window.load) is now working, so removing the temporary debug output. Co-Authored-By: Claude Opus 4.5 --- admin/class-twp-admin.php | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/admin/class-twp-admin.php b/admin/class-twp-admin.php index 7c278ba..bdaf9ab 100644 --- a/admin/class-twp-admin.php +++ b/admin/class-twp-admin.php @@ -7017,7 +7017,6 @@ class TWP_Admin {
Ready
Loading...
-
@@ -7675,7 +7674,6 @@ class TWP_Admin { // Initialize the browser phone function initializeBrowserPhone() { - debugLog('initializeBrowserPhone called'); $('#phone-status').text('Initializing...'); updateConnectionStatus('connecting'); @@ -7753,16 +7751,13 @@ class TWP_Admin { } async function setupTwilioDevice(token) { - debugLog('setupTwilioDevice called'); try { // Check if Twilio SDK is available - debugLog('Twilio check: ' + (typeof Twilio) + ', Device: ' + (typeof Twilio !== 'undefined' ? typeof Twilio.Device : 'N/A')); if (typeof Twilio === 'undefined' || !Twilio.Device) { throw new Error('Twilio Voice SDK not loaded'); } console.log('Setting up Twilio Device...'); - debugLog('Creating Twilio.Device...'); updateConnectionStatus('connecting'); // Request media permissions before setting up device @@ -7812,13 +7807,11 @@ class TWP_Admin { }); console.log('Twilio Device created with audio constraints:', audioConstraints); - debugLog('Device created, setting up handlers...'); // Set up event handlers BEFORE registering // Device registered and ready device.on('registered', function() { console.log('Device registered successfully'); - debugLog('Device REGISTERED!'); $('#phone-status').text('Ready').css('color', '#4CAF50'); $('#call-btn').prop('disabled', false); updateConnectionStatus('connected'); @@ -7900,13 +7893,10 @@ class TWP_Admin { }); // Register device AFTER setting up event handlers - debugLog('Calling device.register()...'); await device.register(); - debugLog('device.register() completed'); } catch (error) { console.error('Error setting up Twilio Device:', error); - debugLog('ERROR: ' + error.message); showError('Failed to setup device: ' + error.message); } } @@ -8242,30 +8232,16 @@ class TWP_Admin { } }); - // Debug helper - function debugLog(msg) { - console.log('TWP Debug: ' + msg); - var debugEl = $('#twp-debug-info'); - if (debugEl.length) { - debugEl.append(msg + '
'); - } - } - // Check if SDK loaded and initialize - debugLog('jQuery ready'); - - // Don't wait for window.load - it may not fire on mobile - // Instead, poll for Twilio SDK availability + // Poll for Twilio SDK availability (window.load may not fire on mobile) var sdkCheckAttempts = 0; var maxSdkCheckAttempts = 50; // 5 seconds max function checkAndInitialize() { sdkCheckAttempts++; - debugLog('SDK check #' + sdkCheckAttempts + ': ' + (typeof Twilio)); if (typeof Twilio !== 'undefined' && Twilio.Device) { console.log('Twilio SDK loaded successfully'); - debugLog('SDK OK, initializing...'); initializeBrowserPhone(); } else if (sdkCheckAttempts < maxSdkCheckAttempts) { // Keep checking every 100ms @@ -8273,7 +8249,6 @@ class TWP_Admin { } else { showError('Twilio Voice SDK failed to load. Please check your internet connection and try refreshing the page.'); console.error('Twilio SDK not found after ' + sdkCheckAttempts + ' attempts.'); - debugLog('SDK FAILED after ' + sdkCheckAttempts + ' attempts'); } } @@ -8282,9 +8257,7 @@ class TWP_Admin { // Also keep the window.load as backup for desktop $(window).on('load', function() { - debugLog('Window loaded (backup)'); if (typeof Twilio !== 'undefined' && !device) { - debugLog('Backup init triggered'); initializeBrowserPhone(); } });