最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google chrome devtools - Enable users of a WebRtc app to download webrtc logs via javascript - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Jul 5, 2017 at 21:45 SB2055 asked Jul 5, 2017 at 20:59 SB2055SB2055 12.9k37 gold badges104 silver badges205 bronze badges 2
  • 1 Perhaps this answer should help: Is there an API for the chrome://webrtc-internals/ variables in JavaScript? – Dheeraj Vepakomma Commented Jul 9, 2017 at 9:35
  • 1 @DheerajV.S. thanks - using that I built a little stats extractor posted below. – SB2055 Commented Jul 9, 2017 at 15:49
Add a ment  | 

3 Answers 3

Reset to default 3 +50

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.

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.

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 mands. 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

发布评论

评论列表(0)

  1. 暂无评论