(cdp, clientId)
| 898 | } |
| 899 | |
| 900 | async function collectReadinessDiagnostics(cdp, clientId) { |
| 901 | const page = await evaluate( |
| 902 | cdp, |
| 903 | ` |
| 904 | (() => { |
| 905 | const videos = [...document.querySelectorAll("video.stream-video")].map((video) => ({ |
| 906 | height: video.videoHeight || 0, |
| 907 | networkState: video.networkState, |
| 908 | paused: video.paused, |
| 909 | readyState: video.readyState, |
| 910 | width: video.videoWidth || 0, |
| 911 | })); |
| 912 | const peerConnections = (window.__simdeckPeerConnections || []).map((pc) => ({ |
| 913 | connectionState: pc.connectionState, |
| 914 | iceConnectionState: pc.iceConnectionState, |
| 915 | iceGatheringState: pc.iceGatheringState, |
| 916 | signalingState: pc.signalingState, |
| 917 | })); |
| 918 | return { |
| 919 | bodyText: (document.body?.innerText || "").slice(0, 1000), |
| 920 | canvases: document.querySelectorAll("canvas.stream-canvas").length, |
| 921 | location: window.location.href, |
| 922 | peerConnections, |
| 923 | sessionClientId: window.sessionStorage.getItem("simdeck.streamClientId") || "", |
| 924 | statusText: document.querySelector("[data-testid='stream-status']")?.textContent || "", |
| 925 | title: document.title, |
| 926 | videos, |
| 927 | }; |
| 928 | })() |
| 929 | `, |
| 930 | ); |
| 931 | const metrics = await fetchJson(endpoint("/api/metrics")).catch((error) => ({ |
| 932 | error: String(error?.message ?? error), |
| 933 | })); |
| 934 | return { |
| 935 | clientId, |
| 936 | page, |
| 937 | streams: Array.isArray(metrics?.client_streams) |
| 938 | ? findClientStreams(metrics, clientId).map((stream) => ({ |
| 939 | codec: stream.codec, |
| 940 | decodedFrames: stream.decodedFrames, |
| 941 | detail: stream.detail, |
| 942 | droppedFrames: stream.droppedFrames, |
| 943 | height: stream.height, |
| 944 | kind: stream.kind, |
| 945 | latestFrameGapMs: stream.latestFrameGapMs, |
| 946 | receivedPackets: stream.receivedPackets, |
| 947 | reconnects: stream.reconnects, |
| 948 | renderedFrames: stream.renderedFrames, |
| 949 | status: stream.status, |
| 950 | udid: stream.udid, |
| 951 | width: stream.width, |
| 952 | })) |
| 953 | : metrics, |
| 954 | }; |
| 955 | } |
| 956 | |
| 957 | async function createPageTarget(url) { |
no test coverage detected