QA/Telemetry/BrowserConsoleCommands

From MozillaWiki
< QA‎ | Telemetry
Jump to: navigation, 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();
  • Checking Telemetry Experiment Branch
Cu.import("resource:///modules/experiments/Experiments.jsm");
Experiments.instance()._getActiveExperiment().branch;
  • 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();

Once retrieved, you should see something similar in the Browser Console:

["EXPERIMENT_ACTIVATION", 52487, "ACTIVATED", "tile-switcher@experiments.mozilla.org"]
["EXPERIMENT_TERMINATION", 389463, "ADDON_UNINSTALLED", "tile-switcher@experiments.mozilla.org"]
["EXPERIMENT_ACTIVATION", 400009, "ACTIVATED", "tile-switcher@experiments.mozilla.org #2"]
["EXPERIMENT_TERMINATION", 692040, "ADDON_UNINSTALLED", "tile-switcher@experiments.mozilla.org #2"]
["EXPERIMENT_ACTIVATION", 731416, "ACTIVATED", "tile-switcher@experiments.mozilla.org #3"]
  • 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, " "));
})(); 
  • Run Maintenance Task
    • force Firefox to run the maintenance task
Cu.import("resource://gre/modules/CrashManager.jsm");
CrashManager.Singleton.runMaintenanceTasks();
  • Crash Firefox
    • force Firefox to crash through the browser console
Cu.import("resource://gre/modules/ctypes.jsm");
let zero = new ctypes.intptr_t(8);
let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
badptr.contents;