Bug 1177246 - Implement metrics for OS search query parsing. r=gfritzsche
authorJared Wein <jwein@mozilla.com>
Wed, 26 Aug 2015 13:28:13 -0400
changeset 288091 73713a40e0ffcf7d3b8987d60ab6e84760d263a3
parent 288090 bee8a1b9f47a95c5162458ac6c346d90d122dbd9
child 288092 719b74e30b3ef93dfaf54d5bada3f7f269dfce97
push id4798
push userbgrinstead@mozilla.com
push dateWed, 26 Aug 2015 20:54:36 +0000
reviewersgfritzsche
bugs1177246
milestone43.0a1
Bug 1177246 - Implement metrics for OS search query parsing. r=gfritzsche
browser/components/nsBrowserContentHandler.js
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -262,21 +262,30 @@ function openPreferences() {
 }
 
 function getMostRecentWindow(aType) {
   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                      .getService(nsIWindowMediator);
   return wm.getMostRecentWindow(aType);
 }
 
+function logSystemBasedSearch(engine) {
+  var countId = (engine.identifier || ("other-" + engine.name)) + ".system";
+  var count = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS");
+  count.add(countId);
+}
+
 function doSearch(searchTerm, cmdLine) {
   var ss = Components.classes["@mozilla.org/browser/search-service;1"]
                      .getService(nsIBrowserSearchService);
 
-  var submission = ss.defaultEngine.getSubmission(searchTerm, null, "system");
+  var engine = ss.defaultEngine;
+  logSystemBasedSearch(engine);
+
+  var submission = engine.getSubmission(searchTerm, null, "system");
 
   // fill our nsISupportsArray with uri-as-wstring, null, null, postData
   var sa = Components.classes["@mozilla.org/supports-array;1"]
                      .createInstance(Components.interfaces.nsISupportsArray);
 
   var wuri = Components.classes["@mozilla.org/supports-string;1"]
                        .createInstance(Components.interfaces.nsISupportsString);
   wuri.data = submission.uri.spec;
@@ -784,17 +793,19 @@ nsDefaultCommandLineHandler.prototype = 
             var formParam = params.get("form");
             if (!formParam) {
               formParam = params.get("FORM");
             }
             if (formParam == "WNSGPH" || formParam == "WNSBOX" || formParam == "WNSFC2") {
               var term = params.get("q");
               var ss = Components.classes["@mozilla.org/browser/search-service;1"]
                                  .getService(nsIBrowserSearchService);
-              var submission = ss.defaultEngine.getSubmission(term, null, "system");
+              var engine = ss.defaultEngine;
+              logSystemBasedSearch(engine);
+              var submission = engine.getSubmission(term, null, "system");
               uri = submission.uri;
             }
           } catch (e) {
             Components.utils.reportError("Couldn't redirect Windows search: " + e);
           }
         }
 
         urilist.push(uri);