Bug 1817196: Record preference value that affects the number of results showing in the urlbar r=mak
Differential Revision: https://phabricator.services.mozilla.com/D170317
This commit is contained in:
@@ -741,6 +741,7 @@ class TelemetryEvent {
|
||||
this._controller = controller;
|
||||
this._category = category;
|
||||
this._isPrivate = controller.input.isPrivate;
|
||||
this.#beginObservingPingPrefs();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1327,5 +1328,39 @@ class TelemetryEvent {
|
||||
this.#previousSearchWordsSet = null;
|
||||
}
|
||||
|
||||
#PING_PREFS = {
|
||||
maxRichResults: Glean.urlbar.prefMaxResults,
|
||||
"suggest.topsites": Glean.urlbar.prefSuggestTopsites,
|
||||
};
|
||||
|
||||
#beginObservingPingPrefs() {
|
||||
this.onPrefChanged("searchEngagementTelemetry.enabled");
|
||||
lazy.UrlbarPrefs.addObserver(this);
|
||||
}
|
||||
|
||||
onPrefChanged(pref) {
|
||||
if (pref === "searchEngagementTelemetry.enabled") {
|
||||
for (const p of Object.keys(this.#PING_PREFS)) {
|
||||
this.onPrefChanged(p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lazy.UrlbarPrefs.get("searchEngagementTelemetryEnabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const metric = this.#PING_PREFS[pref];
|
||||
if (metric) {
|
||||
metric.set(lazy.UrlbarPrefs.get(pref));
|
||||
}
|
||||
}
|
||||
|
||||
onNimbusChanged(variable) {
|
||||
if (variable === "searchEngagementTelemetryEnabled") {
|
||||
this.onPrefChanged("searchEngagementTelemetry.enabled");
|
||||
}
|
||||
}
|
||||
|
||||
#previousSearchWordsSet = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user