@rtcstats/rtcstats-js 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/trace-websocket.js +17 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtcstats/rtcstats-js",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "gather WebRTC API traces and statistics",
5
5
  "main": "rtcstats.js",
6
6
  "type": "module",
@@ -23,13 +23,29 @@ export function WebSocketTrace() {
23
23
  } else {
24
24
  buffer.push(args);
25
25
  }
26
- } else if (connection.readyState >= WebSocket.CLOSING) {
26
+ } else if (connection.readyState === WebSocket.CONNECTING) {
27
+ buffer.push(args);
28
+ } else if ([WebSocket.CLOSING, WebSocket.CLOSED].includes(connection.readyState)) {
27
29
  // no-op. Possibly log?
28
30
  }
29
31
  } else {
30
32
  buffer.push(args);
31
33
  }
32
34
  };
35
+ trace('create', null, {
36
+ hardwareConcurrency: navigator.hardwareConcurrency,
37
+ userAgentData: navigator.userAgentData,
38
+ deviceMemory: navigator.deviceMemory,
39
+ screen: {
40
+ width: window.screen.availWidth,
41
+ height: window.screen.availHeight,
42
+ devicePixelRatio: window.devicePixelRatio,
43
+ },
44
+ window: {
45
+ width: window.innerWidth,
46
+ height: window.innerHeight,
47
+ },
48
+ });
33
49
 
34
50
  trace.close = () => {
35
51
  connection.close();
@@ -48,20 +64,6 @@ export function WebSocketTrace() {
48
64
  });
49
65
 
50
66
  connection.addEventListener('open', () => {
51
- trace('create', null, {
52
- hardwareConcurrency: navigator.hardwareConcurrency,
53
- userAgentData: navigator.userAgentData,
54
- deviceMemory: navigator.deviceMemory,
55
- screen: {
56
- width: window.screen.availWidth,
57
- height: window.screen.availHeight,
58
- devicePixelRatio: window.devicePixelRatio,
59
- },
60
- window: {
61
- width: window.innerWidth,
62
- height: window.innerHeight,
63
- },
64
- });
65
67
  setTimeout(function flush() {
66
68
  if (!buffer.length) {
67
69
  return;