SB2055
SB2055

Reputation: 12862

Enable users of a WebRtc app to download webrtc logs via javascript

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.

Upvotes: 16

Views: 2021

Answers (3)

SB2055
SB2055

Reputation: 12862

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.

Upvotes: 3

Philipp Hancke
Philipp Hancke

Reputation: 17305

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.

Upvotes: 3

Nima Hakimi
Nima Hakimi

Reputation: 1392

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

Upvotes: 0

Related Questions