// Connection quality and network statistics
const connectionStats = agent.getConnectionStats();
console.log(connectionStats);
/*
{
quality: 'good', // Connection quality: excellent/good/poor/lost
connectionAttempts: 1, // Total connection attempts
reconnectionAttempts: 0, // Reconnection attempts
connectionEstablishedTime: 250, // Time to establish connection (ms)
isConnected: true // Current connection status
}
*/
// Audio levels and quality metrics
const audioLevels = agent.getAudioLevels();
console.log(audioLevels);
/*
{
userAudioLevel: 0.8, // Current user audio level
agentAudioLevel: 0.3, // Current agent audio level
userSpeakingTime: 30000, // User speaking duration (ms)
agentSpeakingTime: 20000, // Agent speaking duration (ms)
audioDropouts: 0, // Audio interruption count
echoCancellationActive: true,// Echo cancellation status
volume: 1.0, // Current volume setting
isPaused: false // Pause state
}
*/
// Performance metrics
const performance = agent.getPerformanceMetrics();
console.log(performance);
/*
{
responseTime: 1200, // Total response time
callDuration: 60000, // Current call duration (ms)
connectionEstablishedTime: 250, // Time to establish connection
reconnectionCount: 0, // Number of reconnections
averageResponseTime: 1200 // Average response time
}
*/
// Participant information
const participants = agent.getParticipants();
console.log(participants);
/*
[
{
identity: "agent",
sid: "participant-sid",
connectionTime: 1638360000000,
metadata: "agent-metadata"
}
]
*/
// Track statistics (audio/video streams)
const trackStats = agent.getTrackStats();
console.log(trackStats);
/*
{
totalTracks: 2,
activeTracks: 2,
audioElements: 1,
trackDetails: [
["track-id", { trackId: "track-id", kind: "audio", participant: "agent" }]
]
}
*/
// Complete analytics snapshot
const analytics = agent.getCallAnalytics();
console.log(analytics);
/*
{
connectionStats: { quality: 'good', connectionAttempts: 1, isConnected: true, ... },
audioMetrics: { userAudioLevel: 0.8, agentAudioLevel: 0.3, ... },
performanceMetrics: { callDuration: 60000, responseTime: 1200, ... },
participants: [{ identity: 'agent', sid: 'participant-sid', ... }],
trackStats: { totalTracks: 2, activeTracks: 2, ... },
callStats: { connectionAttempts: 1, packetsLost: 0, ... },
metadata: {
callStartTime: 1638360000000,
isConnected: true,
isPaused: false,
volume: 1.0
}
}
*/