Bug 1802207 - Wait to send component_init-reason "newtab" ping until newtab has been categorized r=nanj

Differential Revision: https://phabricator.services.mozilla.com/D162906
This commit is contained in:
Chris H-C 2022-11-24 14:52:30 +00:00
parent 7b1106d400
commit 89d89d40f5
3 changed files with 12 additions and 14 deletions

View File

@ -1059,6 +1059,9 @@ class TelemetryFeed {
}
Glean.newtab.newtabCategory.set(newtabCategory);
Glean.newtab.homepageCategory.set(homePageCategory);
if (lazy.NimbusFeatures.glean.getVariable("newtabPingEnabled") ?? true) {
GleanPings.newtab.submit("component_init");
}
}
}
@ -1275,12 +1278,6 @@ class TelemetryFeed {
}
setNewtabPrefMetrics();
Glean.pocket.isSignedIn.set(lazy.pktApi.isUserLoggedIn());
if (
this.telemetryEnabled &&
(lazy.NimbusFeatures.glean.getVariable("newtabPingEnabled") ?? true)
) {
GleanPings.newtab.submit("component_init");
}
}
uninit() {

View File

@ -15,7 +15,8 @@ newtab:
The newtab visit ended.
Could be by navigation, being closed, etc.
component_init: |
The newtab component init'd.
The newtab component init'd,
and the newtab and homepage settings have been categorized.
This is mostly to ensure we hear at least once from clients configured to
not show a newtab UI.
include_client_id: true

View File

@ -181,13 +181,6 @@ describe("TelemetryFeed", () => {
assert.calledWithExactly(stub, "unload", instance.handleEvent);
assert.calledWithExactly(stub, "TabPinned", instance.handleEvent);
});
it("should send a 'newtab' ping", () => {
instance._prefs.set(TELEMETRY_PREF, true);
sandbox.spy(GleanPings.newtab, "submit");
instance.init();
assert.calledOnce(GleanPings.newtab.submit);
assert.calledWithExactly(GleanPings.newtab.submit, "component_init");
});
describe("telemetry pref changes from false to true", () => {
beforeEach(() => {
FakePrefs.prototype.prefs = {};
@ -1725,6 +1718,13 @@ describe("TelemetryFeed", () => {
assert.calledOnce(Glean.newtab.homepageCategory.set);
assert.calledWith(Glean.newtab.homepageCategory.set, "disabled");
});
it("should send a 'newtab' ping", () => {
instance._prefs.set(TELEMETRY_PREF, true);
sandbox.spy(GleanPings.newtab, "submit");
await instance.sendPageTakeoverData();
assert.calledOnce(GleanPings.newtab.submit);
assert.calledWithExactly(GleanPings.newtab.submit, "component_init");
});
});
describe("#sendDiscoveryStreamImpressions", () => {
it("should not send impression pings if there is no impression data", () => {