16

I've seen the following:

chrome://webrtc-internals 

However I'm looking for a way to let users click a button from within the web app to either download or - preferably - POST WebRtc logs to an endpoint baked into the app. The idea is that I can enable non-technical users to share technical logs with me through the click of a UI button.

How can this be achieved?

Note: This should not be dependent on Chrome; Chromium will also be used as the app will be wrapped up in Electron.

SB2055
  • 12,272
  • 32
  • 97
  • 202
  • 1
    Perhaps this answer should help: [Is there an API for the `chrome://webrtc-internals/` variables in JavaScript?](https://stackoverflow.com/a/24070353/165674) – Dheeraj Vepakomma Jul 09 '17 at 09:35
  • 1
    @DheerajV.S. thanks - using that I built a little stats extractor posted below. – SB2055 Jul 09 '17 at 15:49

3 Answers3

3

This is what I ended up using (replace knockout with underscore or whatever):

            connectionReport.signalingState = connection.signalingState;
            connectionReport.stats = [];
            connection.getStats(function (stats) {
                const reportCollection = stats.result();
                ko.utils.arrayForEach(reportCollection, function (innerReport) {
                    const statReport = {};
                    statReport.id = innerReport.id;
                    statReport.type = innerReport.type;
                    const keys = innerReport.names();
                    ko.utils.arrayForEach(keys, function (reportKey) {
                        statReport[reportKey] = innerReport.stat(reportKey);
                    })
                    connectionReport.stats.push(statReport);
                });
                connectionStats.push(connectionReport);
            });

UPDATE:

It appears that this getStats mechanism is soon-to-be-deprecated.

SB2055
  • 12,272
  • 32
  • 97
  • 202
3

You need to write a javascript equivalent that captures all RTCPeerConnection API calls. rtcstats.js does that but sends all data to a server. If you replace that behaviour with storing it in memory you should be good.

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31
  • What are your thoughts on the solution I posted? Would this give the insights needed to debug the majority of WebRTC issues? – SB2055 Jul 10 '17 at 19:55
  • In most cases I have seen the API trace was more helpful than the getStats result -- see https://testrtc.com/webrtc-api-trace/. Also you're using the legacy chrome stats api which should be avoided. – Philipp Hancke Jul 11 '17 at 05:46
  • Do you have an example that demonstrates how to dump these logs clientside (or even how to use that at all - I'm not seeing much documented around configuration there)? I think that would be most helpful for future readers. – SB2055 Jul 11 '17 at 12:17
  • I pushed a commit [here](https://github.com/opentok/rtcstats/tree/clientside) -- essentially build the bundled version using npm run dist, then create a peerconnection on the included test page and inspect window.rtcstats.connections – Philipp Hancke Jul 11 '17 at 15:01
  • I hate to be a pain - but I'm still not clear. I think having a self-contained example of how to `require` this and use it without a dependency on building node (or some external server) would help more people; as would having any relevant code in the answer. Totally get it if you don't have time for this - I can try to figure it out and post up if that's the case. I think the most common use case here would be "Allow me to log these (or access these) logs clientside so I can decide what to do with them." A clear example of setting that up would surely help anyone else looking for this. – SB2055 Jul 11 '17 at 15:31
0

Reading through js source of chrome://webrtc-internals, I noticed that the web page is using a method called chrome.send() to send messages like chrome.send('enableEventLogRecordings');, to execute logging commands. According to here:

chrome.send() is a private function only available to internal chrome pages.

so the function is sandboxed which makes accessing to it not possible

Nima Hakimi
  • 1,382
  • 1
  • 8
  • 23