Bug 1314650 - Fix the "Unknown source for one-off search: urlbar" error when doing one-off searches. r=mak
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Thu, 03 Nov 2016 11:21:00 +0800
changeset 347701 43b69e748e78b45983a5d8df6c0f9a77ccfed026
parent 347700 fa1f25d45d8e3f6b15e2d8ea8ef98ee9b339f2c0
child 347702 c9308740eeb796ca1b534751c94ed5b2cb51e1fb
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1314650
milestone52.0a1
Bug 1314650 - Fix the "Unknown source for one-off search: urlbar" error when doing one-off searches. r=mak MozReview-Commit-ID: 1N6q98hki4n
browser/modules/BrowserUsageTelemetry.jsm
--- a/browser/modules/BrowserUsageTelemetry.jsm
+++ b/browser/modules/BrowserUsageTelemetry.jsm
@@ -268,16 +268,23 @@ let BrowserUsageTelemetry = {
    *        The object describing the event that triggered the search.
    * @throws if source is not in the known sources list.
    */
   recordSearch(engine, source, details={}) {
     const isOneOff = !!details.isOneOff;
 
     if (isOneOff) {
       if (!KNOWN_ONEOFF_SOURCES.includes(source)) {
+        // Silently drop the error if this bogus call
+        // came from 'urlbar' or 'searchbar'. They're
+        // calling |recordSearch| twice from two different
+        // code paths.
+        if (['urlbar', 'searchbar'].includes(source)) {
+          return;
+        }
         throw new Error("Unknown source for one-off search: " + source);
       }
     } else {
       if (!KNOWN_SEARCH_SOURCES.includes(source)) {
         throw new Error("Unknown source for search: " + source);
       }
       let countId = getSearchEngineId(engine) + "." + source;
       Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS").add(countId);