Skip to content
Daniel Raeder edited this page Mar 6, 2022 · 1 revision

Here is the W3C standards compliant way to gather statistics from a WebRTC connection. This should work in all modern browsers.

// The async function allows using "await". You can also do pc.getStats().then(callback) in a non-async context.
(async () => {
  const report = await pc.getStats();
  for (let dictionary of report.values()) {
    console.log(dictionary.type);
    console.log('  id: ' + dictionary.id);
    console.log('  timestamp: ' + dictionary.timestamp);
    Object.keys(dictionary).forEach(key => {
      if (key != 'type' && key != 'id' && key != 'timestamp')
        console.log('  ' + key + ': ' + dictionary[key]);
    });
  }
})();

The list of statistics that will be returned can be found here.

This wiki is where all the GUN website documentation comes from.

You can read it here or on the website, but the website has some special features like rendering some markdown extensions to create interactive coding tutorials.

Please feel free to improve the docs itself, we need contributions!

Clone this wiki locally