Improve call recording functionality with better debugging and Call SID detection

## Recording Issues Fixed
- Enhanced Call SID detection for browser phone calls
- Try multiple methods to get Call SID: parameters.CallSid, customParameters.CallSid, outgoingConnectionId, sid
- Added comprehensive console logging for debugging recording issues
- Better error handling and user feedback

## Backend Improvements
- Verify call exists and is in-progress before attempting recording
- Enhanced error logging with call status and details
- Improved AJAX error responses with specific error messages
- Database insert error checking and logging

## Frontend Improvements
- Multiple Call SID detection methods for browser phone compatibility
- Console logging of call object and Call SID for debugging
- Enhanced error handling with xhr response details
- Validation of active call before recording attempt

## Debugging Features
- Detailed error logs in PHP error log
- Console logging in browser for JavaScript debugging
- Specific error messages for different failure scenarios
- Call status validation to ensure recording is possible

These changes should resolve the "recording not working" issue by properly detecting the Call SID for browser phone calls and providing detailed debugging information.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-08-30 15:49:31 -07:00
parent 0bbc499878
commit e6e177a114
2 changed files with 75 additions and 10 deletions

View File

@@ -1668,6 +1668,25 @@
* Start recording the current call
*/
function startRecording() {
if (!currentCall || currentCall.status() !== 'open') {
showMessage('No active call to record', 'error');
return;
}
// Try multiple ways to get the call SID
const callSid = currentCall.parameters.CallSid ||
currentCall.customParameters.CallSid ||
currentCall.outgoingConnectionId ||
currentCall.sid;
console.log('Frontend currentCall object:', currentCall);
console.log('Frontend attempting to record call SID:', callSid);
if (!callSid) {
showMessage('Could not determine call SID for recording', 'error');
return;
}
const $recordBtn = $('#twp-record-btn');
$.ajax({
@@ -1675,7 +1694,7 @@
method: 'POST',
data: {
action: 'twp_start_recording',
call_sid: currentCall.parameters.CallSid,
call_sid: callSid,
nonce: twp_frontend_ajax.nonce
},
success: function(response) {
@@ -1688,8 +1707,9 @@
showMessage('Failed to start recording: ' + (response.data || 'Unknown error'), 'error');
}
},
error: function() {
showMessage('Failed to start recording', 'error');
error: function(xhr, status, error) {
console.error('Frontend recording start failed:', xhr.responseText);
showMessage('Failed to start recording: ' + error, 'error');
}
});
}