Bug 1312881 - Add a telemetry probe to track the max scrollY of a page. r=jaws data-review=bsmedberg
This commit is contained in:
@@ -1764,18 +1764,22 @@ DateTimePickerListener.init();
|
||||
|
||||
/*
|
||||
* Telemetry probe to track the amount of scrolling a user does up and down the root frame
|
||||
* of a page. This doesn't include scrolling sub frames, but does include scrolling from JavaScript.
|
||||
* See bug 1297867 for more details.
|
||||
* of a page, and also the maximum distance a user scrolls down the root frame of a page.
|
||||
* This doesn't include scrolling sub frames, but does include scrolling from JavaScript.
|
||||
* See bug 1312881 and bug 1297867 for more details.
|
||||
*/
|
||||
let TelemetryScrollTracker = {
|
||||
init: function() {
|
||||
this._ignore = false;
|
||||
this._prevScrollY = 0;
|
||||
this._maxScrollY = 0;
|
||||
this._amountHistogram = Services.telemetry.getHistogramById("TOTAL_SCROLL_Y");
|
||||
this._maxHistogram = Services.telemetry.getHistogramById("PAGE_MAX_SCROLL_Y");
|
||||
|
||||
addEventListener("DOMWindowCreated", this, { passive: true });
|
||||
addEventListener("pageshow", this, { passive: true });
|
||||
addEventListener("scroll", this, { passive: true });
|
||||
addEventListener("pagehide", this, { passive: true });
|
||||
},
|
||||
|
||||
handleEvent: function(aEvent) {
|
||||
@@ -1787,11 +1791,13 @@ let TelemetryScrollTracker = {
|
||||
case "DOMWindowCreated": {
|
||||
this._ignore = this.shouldIgnorePage();
|
||||
this._prevScrollY = 0;
|
||||
this._maxScrollY = 0;
|
||||
break;
|
||||
}
|
||||
case "pageshow": {
|
||||
this._ignore = this.shouldIgnorePage();
|
||||
this._prevScrollY = content.scrollY;
|
||||
this._maxScrollY = content.scrollY;
|
||||
break;
|
||||
}
|
||||
case "scroll": {
|
||||
@@ -1802,6 +1808,15 @@ let TelemetryScrollTracker = {
|
||||
let amount = Math.abs(content.scrollY - this._prevScrollY);
|
||||
this._amountHistogram.add(amount);
|
||||
this._prevScrollY = content.scrollY;
|
||||
this._maxScrollY = Math.max(content.scrollY, this._maxScrollY);
|
||||
break;
|
||||
}
|
||||
case "pagehide": {
|
||||
if (this._ignore) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._maxHistogram.add(this._maxScrollY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user