Bug 1465694 - Add tab event telemetry for Savant Shield study; r=dao

These probes will register and record (for the duration of the study only):
* When a tab opens.
* When a tab closes.
* When a tab is selected.

MozReview-Commit-ID: BvknEH0ofS0

--HG--
extra : rebase_source : fecb98743781823f9fd08001b88d13f5c094b461
This commit is contained in:
Bianca Danforth 2018-06-06 03:44:48 -07:00
Родитель dd385305f3
Коммит ea4aa07dab
3 изменённых файлов: 32 добавлений и 5 удалений

Просмотреть файл

@ -1040,6 +1040,7 @@ window._gBrowser = {
}
});
newTab.dispatchEvent(event);
Services.telemetry.recordEvent("savant", "tab", "select", null, { subcategory: "frame" });
this._tabAttrModified(oldTab, ["selected"]);
this._tabAttrModified(newTab, ["selected"]);
@ -2460,6 +2461,7 @@ window._gBrowser = {
var detail = aEventDetail || {};
var evt = new CustomEvent("TabOpen", { bubbles: true, detail });
t.dispatchEvent(evt);
Services.telemetry.recordEvent("savant", "tab", "open", null, { subcategory: "frame" });
if (!usingPreloadedContent && aOriginPrincipal && aURI) {
let { URI_INHERITS_SECURITY_CONTEXT } = Ci.nsIProtocolHandler;
@ -2847,6 +2849,7 @@ window._gBrowser = {
// inspect the tab that's about to close.
var evt = new CustomEvent("TabClose", { bubbles: true, detail: { adoptedBy: aAdoptedByTab } });
aTab.dispatchEvent(evt);
Services.telemetry.recordEvent("savant", "tab", "close", null, { subcategory: "frame" });
if (aTab.linkedPanel) {
if (!aAdoptedByTab && !gMultiProcessBrowser) {

Просмотреть файл

@ -39,6 +39,9 @@ class SavantShieldStudyClass {
// ms = 'x' weeks * 7 days/week * 24 hours/day * 60 minutes/hour
// * 60 seconds/minute * 1000 milliseconds/second
this.DEFAULT_STUDY_DURATION_MS = 4 * 7 * 24 * 60 * 60 * 1000;
// If on startupStudy(), user is ineligible or study has expired,
// no probe listeners from this module have been added yet
this.shouldRemoveListeners = true;
}
init() {
@ -73,6 +76,7 @@ class SavantShieldStudyClass {
this.telemetryEvents.enableCollection();
if (!this.isEligible()) {
this.shouldRemoveListeners = false;
this.endStudy("ineligible");
return;
}
@ -81,6 +85,7 @@ class SavantShieldStudyClass {
if (this.isStudyExpired()) {
log.debug("Study expired in between this and the previous session.");
this.shouldRemoveListeners = false;
this.endStudy("expired");
}
@ -254,7 +259,9 @@ class AddonListener {
}
uninit() {
this.removeListeners();
if (SavantShieldStudy.shouldRemoveListeners) {
this.removeListeners();
}
}
}
@ -280,11 +287,11 @@ class BookmarkObserver {
}
onItemAdded(itemID, parentID, index, itemType, uri, title, dateAdded, guid, parentGUID, source) {
this.handleBookmarkSaveRemove(itemType, uri, source, "save");
this.handleItemAddRemove(itemType, uri, source, "save");
}
onItemRemoved(itemID, parentID, index, itemType, uri, guid, parentGUID, source) {
this.handleBookmarkSaveRemove(itemType, uri, source, "remove");
this.handleItemAddRemove(itemType, uri, source, "remove");
}
handleItemAddRemove(itemType, uri, source, event) {
@ -319,7 +326,9 @@ class BookmarkObserver {
}
uninit() {
this.removeObservers();
if (SavantShieldStudy.shouldRemoveListeners) {
this.removeObservers();
}
}
}
@ -418,7 +427,9 @@ class MenuListener {
}
uninit() {
this.windowWatcher.uninit();
if (SavantShieldStudy.shouldRemoveListeners) {
this.windowWatcher.uninit();
}
}
}

Просмотреть файл

@ -271,6 +271,19 @@ savant:
subcategory: The broad event category for this probe. E.g. navigation
flow_id: A tab identifier to associate events occuring in the same tab
canRecordSubmit: True if a login form loads in a non-private window with Password Manager enabled.
tab:
objects: ["open", "close", "select"]
release_channel_collection: opt-out
record_in_processes: ["main"]
description: >
This is recorded any time a tab is opened, closed or selected.
bug_numbers: [1457226, 1465694]
notification_emails:
- "bdanforth@mozilla.com"
- "shong@mozilla.com"
expiry_version: "65"
extra_keys:
subcategory: The broad event category for this probe. E.g. navigation
# This category contains event entries used for Telemetry tests.
# They will not be sent out with any pings.