Bug 1962774 - Remove newtabPingEnabled variable from glean feature r=TravisLong,chutten,home-newtab-reviewers,mconley

The glean feature can control any ping via the gleanMetricConfiguration
now, so there is no need to have this variable any more. It is still
possible to disable the ping with a pref, so the test has been updated
to set that pref instead of doing a Nimbus enrollment.

Differential Revision: https://phabricator.services.mozilla.com/D246792
This commit is contained in:
Beth Rennie
2025-04-28 18:30:18 +00:00
parent 1bf8c095ed
commit 8325687e5d
4 changed files with 9 additions and 16 deletions

View File

@@ -34,7 +34,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
ExtensionSettingsStore:
"resource://gre/modules/ExtensionSettingsStore.sys.mjs",
HomePage: "resource:///modules/HomePage.sys.mjs",
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
UTEventReporting: "resource://newtab/lib/UTEventReporting.sys.mjs",
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
@@ -61,6 +60,7 @@ const PREF_SHOW_SPONSORED_TOPSITES = "showSponsoredTopSites";
const BLANK_HOMEPAGE_URL = "chrome://browser/content/blanktab.html";
const PREF_PRIVATE_PING_ENABLED = "telemetry.privatePing.enabled";
const PREF_FOLLOWED_SECTIONS = "discoverystream.sections.following";
const PREF_NEWTAB_PING_ENABLED = "browser.newtabpage.ping.enabled";
// This is a mapping table between the user preferences and its encoding code
export const USER_PREFS_ENCODING = {
@@ -373,7 +373,7 @@ export class TelemetryFeed {
Glean.newtab.closed.record({ newtab_visit_id: session.session_id });
if (
this.telemetryEnabled &&
(lazy.NimbusFeatures.glean.getVariable("newtabPingEnabled") ?? true)
Services.prefs.getBoolPref(PREF_NEWTAB_PING_ENABLED, true)
) {
GleanPings.newtab.submit("newtab_session_end");
if (this.privatePingEnabled) {
@@ -919,7 +919,7 @@ export class TelemetryFeed {
Glean.newtab.newtabCategory.set(newtabCategory);
Glean.newtab.homepageCategory.set(homePageCategory);
if (lazy.NimbusFeatures.glean.getVariable("newtabPingEnabled") ?? true) {
if (Services.prefs.getBoolPref(PREF_NEWTAB_PING_ENABLED, true)) {
if (this.privatePingEnabled) {
this.configureContentPing("component_init");
}

View File

@@ -143,15 +143,14 @@ add_task(async function test_newtab_tab_nav_sends_ping() {
await SpecialPowers.popPrefEnv();
});
add_task(async function test_newtab_doesnt_send_nimbus() {
add_task(async function test_newtab_doesnt_send_pref() {
await SpecialPowers.pushPrefEnv({
set: [["browser.newtabpage.activity-stream.telemetry", true]],
set: [
["browser.newtabpage.activity-stream.telemetry", true],
["browser.newtabpage.ping.enabled", false],
],
});
let doEnrollmentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
featureId: "glean",
value: { newtabPingEnabled: false },
});
Services.fog.testResetFOG();
let TelemetryFeed =
AboutNewTab.activityStream.store.feeds.get("feeds.telemetry");
@@ -191,7 +190,6 @@ add_task(async function test_newtab_doesnt_send_nimbus() {
).length;
}, "Waiting for sessions to clean up.");
// Session ended without a ping being sent. Success!
doEnrollmentCleanup();
await SpecialPowers.popPrefEnv();
});