QA/Telemetry/BrowserConsoleCommands: Difference between revisions

From MozillaWiki
< QA‎ | Telemetry
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 14: Line 14:
  Cu.import("resource:///modules/experiments/Experiments.jsm");
  Cu.import("resource:///modules/experiments/Experiments.jsm");
  Experiments.instance().updateManifest();
  Experiments.instance().updateManifest();
* '''Checking Telemetry Experiment Branch'''
Cu.import("resource:///modules/experiments/Experiments.jsm");
Experiments.instance()._getActiveExperiment().branch;


* '''Retrieve Telemetry Logs'''
* '''Retrieve Telemetry Logs'''
Line 20: Line 25:
  Cu.import("resource://gre/modules/TelemetryLog.jsm");
  Cu.import("resource://gre/modules/TelemetryLog.jsm");
  TelemetryLog.entries().toSource();
  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'''
* '''Extracting Telemetry Payload'''
Line 34: Line 47:


* '''Run Maintenance Task'''
* '''Run Maintenance Task'''
** force firefox to run the 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


<pre>
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/CrashManager.jsm");
let zero = new ctypes.intptr_t(8);
CrashManager.Singleton.runMaintenanceTasks();
let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
</pre>
badptr.contents;

Latest revision as of 20:06, 22 October 2015

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;