Bug 1655946 - Add X-Target-URL header to top site attribution requests. r=mikedeboer
authorDão Gottwald <dao@mozilla.com>
Thu, 30 Jul 2020 11:39:08 +0000
changeset 542599 f77bb89f9def6eb02dd1752607a47bf075377b0f
parent 542598 d8415effc555031ea67179152c6de9aa5f25b407
child 542600 07f5cb328a100e491c7681534d85ef85653f2a6f
push id37653
push userbtara@mozilla.com
push dateThu, 30 Jul 2020 21:54:52 +0000
treeherdermozilla-central@c34351a5fd6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1655946
milestone81.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1655946 - Add X-Target-URL header to top site attribution requests. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D85272
browser/components/newtab/content-src/components/TopSites/TopSite.jsx
browser/components/newtab/data/content/activity-stream.bundle.js
browser/components/urlbar/UrlbarInput.jsm
browser/modules/TopSiteAttribution.jsm
--- a/browser/components/newtab/content-src/components/TopSites/TopSite.jsx
+++ b/browser/components/newtab/content-src/components/TopSites/TopSite.jsx
@@ -370,17 +370,17 @@ export class TopSite extends React.PureC
           })
         );
       }
       if (this.props.link.overriddenSearchTopSite) {
         this.props.dispatch(
           ac.OnlyToMain({
             type: at.TOP_SITES_ATTRIBUTION,
             data: {
-              searchProvider: this.props.link.hostname,
+              targetURL: this.props.link.url,
               source: "newtab",
             },
           })
         );
       }
     } else {
       this.props.dispatch(
         ac.OnlyToMain({
--- a/browser/components/newtab/data/content/activity-stream.bundle.js
+++ b/browser/components/newtab/data/content/activity-stream.bundle.js
@@ -10321,17 +10321,17 @@ class TopSite extends react__WEBPACK_IMP
           }]
         }));
       }
 
       if (this.props.link.overriddenSearchTopSite) {
         this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].OnlyToMain({
           type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].TOP_SITES_ATTRIBUTION,
           data: {
-            searchProvider: this.props.link.hostname,
+            targetURL: this.props.link.url,
             source: "newtab"
           }
         }));
       }
     } else {
       this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].OnlyToMain({
         type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].FILL_SEARCH_TERM,
         data: {
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -605,19 +605,17 @@ class UrlbarInput {
     let selIndex = result.rowIndex;
     if (!result.payload.keywordOffer) {
       this.view.close(/* elementPicked */ true);
     }
 
     this.controller.recordSelectedResult(event, result);
     if (result.payload.overriddenSearchTopSite) {
       TopSiteAttribution.makeRequest({
-        searchProvider: result.payload.url.match(
-          /^https?:\/\/(?:www.)?([^.]*)/
-        )[1],
+        targetURL: result.payload.url,
         source: "urlbar",
       });
     }
 
     if (isCanonized) {
       this.controller.engagementEvent.record(event, {
         searchString: this._lastSearchString,
         selIndex,
--- a/browser/modules/TopSiteAttribution.jsm
+++ b/browser/modules/TopSiteAttribution.jsm
@@ -16,17 +16,19 @@ ChromeUtils.defineModuleGetter(
 
 ChromeUtils.defineModuleGetter(
   this,
   "Region",
   "resource://gre/modules/Region.jsm"
 );
 
 var TopSiteAttribution = {
-  async makeRequest({ searchProvider, source }) {
+  async makeRequest({ targetURL, source }) {
+    let searchProvider = targetURL.match(/^https?:\/\/(?:www.)?([^.]*)/)[1];
+
     function record(objectString, value = "") {
       recordTelemetryEvent("search_override_exp", objectString, value, {
         searchProvider,
         source,
       });
     }
     record("click");
 
@@ -36,16 +38,17 @@ var TopSiteAttribution = {
     );
     if (!attributionUrl) {
       record("attribution", "abort");
       return;
     }
     const request = new Request(attributionUrl);
     request.headers.set("X-Region", Region.home);
     request.headers.set("X-Source", source);
+    request.headers.set("X-Target-URL", targetURL);
     const response = await fetch(request);
     record("attribution", response.ok ? "success" : "failure");
   },
 };
 
 function recordTelemetryEvent(method, objectString, value, extra) {
   Services.telemetry.setEventRecordingEnabled("top_sites", true);
   Services.telemetry.recordEvent(