diff --git a/browser/components/newtab/test/browser/browser_topsites_annotation.js b/browser/components/newtab/test/browser/browser_topsites_annotation.js index 89e913d4cafe91df7b97414943523f5970d6b0ab..874290b99d1b0c532f9bd87db86285e20fe30d3b 100644 --- a/browser/components/newtab/test/browser/browser_topsites_annotation.js +++ b/browser/components/newtab/test/browser/browser_topsites_annotation.js @@ -17,6 +17,7 @@ const { XPCOMUtils } = ChromeUtils.import( XPCOMUtils.defineLazyModuleGetters(this, { NewTabUtils: "resource://gre/modules/NewTabUtils.jsm", PlacesTestUtils: "resource://testing-common/PlacesTestUtils.jsm", + TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.jsm", UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.jsm", }); @@ -910,6 +911,8 @@ add_task(async function fixup() { add_task(async function noTriggeringURL() { await BrowserTestUtils.withNewTab("about:home", async browser => { + Services.telemetry.clearScalars(); + const dummyTriggeringSponsoredURL = "http://example.com/dummyTriggeringSponsoredURL"; const targetURL = "http://example.com/"; @@ -941,6 +944,14 @@ add_task(async function noTriggeringURL() { }, }); + info("Check telemetry"); + const scalars = TelemetryTestUtils.getProcessScalars("parent", false, true); + TelemetryTestUtils.assertScalar( + scalars, + "places.sponsored_visit_no_triggering_url", + 1 + ); + await clearHistoryAndBookmarks(); }); }); diff --git a/browser/components/urlbar/docs/telemetry.rst b/browser/components/urlbar/docs/telemetry.rst index 8a57aaf90932ff8af184481abce081d18039376b..61f827446f3900a54c229b8ecb5594d23bd19c88 100644 --- a/browser/components/urlbar/docs/telemetry.rst +++ b/browser/components/urlbar/docs/telemetry.rst @@ -354,6 +354,16 @@ urlbar.tabtosearch.* Due to the potentially sensitive nature of these data, they are currently collected only on pre-release version of Firefox. See bug 1686330. +places.* + This is places related telemetry. + + Valid result types are: + + - ``sponsored_visit_no_triggering_url`` + Number of sponsored visits that could not find their triggering URL in + history. We expect this to be a small number just due to the navigation layer + manipulating URLs. A large or growing value may be a concern. + Event Telemetry --------------- diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 6977a848a35627af08a03ebe55e164103d5e0343..698b7fb2dd1589a557ea69240f5db840689f2bbc 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -1262,6 +1262,9 @@ class InsertVisitedURIs final : public Runnable { if (exists) { rv = stmt->GetInt64(0, &aPlace.triggeringPlaceId); NS_ENSURE_SUCCESS(rv, rv); + } else { + Telemetry::ScalarAdd( + Telemetry::ScalarID::PLACES_SPONSORED_VISIT_NO_TRIGGERING_URL, 1); } aPlace.source = nsINavHistoryService::VISIT_SOURCE_SPONSORED; diff --git a/toolkit/components/telemetry/Scalars.yaml b/toolkit/components/telemetry/Scalars.yaml index 4e36a1da7ff5a241b19147b0f342cd8356a7824b..013b69904679a06e24e650f5447e2377c1214efa 100644 --- a/toolkit/components/telemetry/Scalars.yaml +++ b/toolkit/components/telemetry/Scalars.yaml @@ -8616,6 +8616,25 @@ opaque.response.blocking: - 'main' release_channel_collection: opt-out +places: + sponsored_visit_no_triggering_url: + bug_numbers: + - 1787961 + description: > + Number of sponsored visits that could not find their triggering URL in + history. We expect this to be a small number just due to the navigation + layer manipulating URLs. A large or growing value may be a concern. + + expires: never + kind: uint + notification_emails: + - fx-search-telemetry@mozilla.com + release_channel_collection: opt-out + products: + - 'firefox' + record_in_processes: + - main + # NOTE: Please don't add new definitions below this point. Consider adding # them earlier in the file and leave the telemetry.test category as the last # one for readability.