Guard all the vaules in the Metrics for undefined. (#891)
				
					
				
			We've seen a few cases where the WebRTC metrics report contains
undefined values when the stream hasn't started yet. JavaScript, when we
send to the backend, drops `undefined` members of the object, for
example:
```
> JSON.stringify({rtc_frames_dropped: undefined})
< '{}'
```
This will fail the backend validation logic and cause an error to get
emitted to the front-end reporting the missing key. I don't think this
does anything to the session, but it's an error we can avoid by guarding
more of the statistics with a || 0.
Some of the values had this already, this just adds a few more.
Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io>
			
			
This commit is contained in:
		@ -450,18 +450,18 @@ export class EngineConnection {
 | 
			
		||||
            videoTrackStats.forEach((videoTrackReport) => {
 | 
			
		||||
              if (videoTrackReport.type === 'inbound-rtp') {
 | 
			
		||||
                client_metrics.rtc_frames_decoded =
 | 
			
		||||
                  videoTrackReport.framesDecoded
 | 
			
		||||
                  videoTrackReport.framesDecoded || 0
 | 
			
		||||
                client_metrics.rtc_frames_dropped =
 | 
			
		||||
                  videoTrackReport.framesDropped
 | 
			
		||||
                  videoTrackReport.framesDropped || 0
 | 
			
		||||
                client_metrics.rtc_frames_received =
 | 
			
		||||
                  videoTrackReport.framesReceived
 | 
			
		||||
                  videoTrackReport.framesReceived || 0
 | 
			
		||||
                client_metrics.rtc_frames_per_second =
 | 
			
		||||
                  videoTrackReport.framesPerSecond || 0
 | 
			
		||||
                client_metrics.rtc_freeze_count =
 | 
			
		||||
                  videoTrackReport.freezeCount || 0
 | 
			
		||||
                client_metrics.rtc_jitter_sec = videoTrackReport.jitter
 | 
			
		||||
                client_metrics.rtc_jitter_sec = videoTrackReport.jitter || 0.0
 | 
			
		||||
                client_metrics.rtc_keyframes_decoded =
 | 
			
		||||
                  videoTrackReport.keyFramesDecoded
 | 
			
		||||
                  videoTrackReport.keyFramesDecoded || 0
 | 
			
		||||
                client_metrics.rtc_total_freezes_duration_sec =
 | 
			
		||||
                  videoTrackReport.totalFreezesDuration || 0
 | 
			
		||||
              } else if (videoTrackReport.type === 'transport') {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user