QA/Telemetry/BrowserConsoleCommands

From MozillaWiki
Jump to navigation Jump to search

Quick Summary

The following document will list several commands and pieces of code that you can insert into the browser console to extract more information from the experiment system. With this information, you'll be able to take a deeper look at the data and debug/test more reliably.

Enabling Logging

Please visit and review the following document:

Browser Console Commands

  • Refresh Experiment Manifest Manually
    • automatically update/refresh the current experiment manifest
Cu.import("resource:///modules/experiments/Experiments.jsm");
Experiments.instance().updateManifest();
  • Retrieve Telemetry Logs
    • retrieves the current telemetry log entries and displays them in the browser console
Cu.import("resource://gre/modules/TelemetryLog.jsm");
TelemetryLog.entries().toSource();
  • Extracting Telemetry Payload
    • extract the current telemetry payload and add it into the clipboard (paste into a text editor)
(function() {
 function copyStringToClipboard(s) {
   var ch = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
   ch.copyString(s);
 }
 Cu.import("resource://gre/modules/TelemetryPing.jsm");
 copyStringToClipboard(JSON.stringify(TelemetryPing.getPayload(), null, " "));
})();