From aa73212e5ba274741672b619ab77fa78dcd9aa41 Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Wed, 5 Apr 2017 17:51:41 +0300 Subject: [PATCH] Add an index-per-type histogram for awesomebar results (bug 1345834). data-review=bsmedberg r=adw,bsmedberg MozReview-Commit-ID: HxqENFSYcJy --HG-- extra : rebase_source : b7bdbc6cdd6d67ed633b19b36418e3272a3f96e5 --- browser/modules/BrowserUsageTelemetry.jsm | 7 ++--- .../browser/browser_UsageTelemetry_urlbar.js | 28 +++++++++++++++++++ toolkit/components/telemetry/Histograms.json | 10 +++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/browser/modules/BrowserUsageTelemetry.jsm b/browser/modules/BrowserUsageTelemetry.jsm index 3928bcd305a1..528f9f47e1cf 100644 --- a/browser/modules/BrowserUsageTelemetry.jsm +++ b/browser/modules/BrowserUsageTelemetry.jsm @@ -259,16 +259,15 @@ let urlbarListener = { .getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX") .add(idx); - // Ideally this would be a keyed histogram and we'd just add(actionType), - // but keyed histograms aren't currently shown on the telemetry dashboard - // (bug 1151756). - // // You can add values but don't change any of the existing values. // Otherwise you'll break our data. if (actionType in URLBAR_SELECTED_RESULT_TYPES) { Services.telemetry .getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE") .add(URLBAR_SELECTED_RESULT_TYPES[actionType]); + Services.telemetry + .getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE") + .add(actionType, idx); } else { Cu.reportError("Unknown FX_URLBAR_SELECTED_RESULT_TYPE type: " + actionType); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js index 402ce1899b44..34e10ee42776 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js @@ -102,6 +102,8 @@ add_task(function* test_simpleQuery() { Services.telemetry.clearEvents(); let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX"); let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + resultIndexByTypeHist.clear(); resultIndexHist.clear(); resultTypeHist.clear(); @@ -138,6 +140,11 @@ add_task(function* test_simpleQuery() { URLBAR_SELECTED_RESULT_TYPES.searchengine, "FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByType = resultIndexByTypeHist.snapshot("searchengine"); + checkHistogramResults(resultIndexByType, + 0, + "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + yield BrowserTestUtils.removeTab(tab); }); @@ -147,6 +154,8 @@ add_task(function* test_searchAlias() { Services.telemetry.clearEvents(); let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX"); let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + resultIndexByTypeHist.clear(); resultIndexHist.clear(); resultTypeHist.clear(); @@ -183,6 +192,11 @@ add_task(function* test_searchAlias() { URLBAR_SELECTED_RESULT_TYPES.searchengine, "FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByType = resultIndexByTypeHist.snapshot("searchengine"); + checkHistogramResults(resultIndexByType, + 0, + "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + yield BrowserTestUtils.removeTab(tab); }); @@ -192,6 +206,8 @@ add_task(function* test_oneOff() { Services.telemetry.clearEvents(); let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX"); let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + resultIndexByTypeHist.clear(); resultIndexHist.clear(); resultTypeHist.clear(); @@ -231,6 +247,11 @@ add_task(function* test_oneOff() { URLBAR_SELECTED_RESULT_TYPES.searchengine, "FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByType = resultIndexByTypeHist.snapshot("searchengine"); + checkHistogramResults(resultIndexByType, + 0, + "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + yield BrowserTestUtils.removeTab(tab); }); @@ -240,6 +261,8 @@ add_task(function* test_suggestion() { Services.telemetry.clearEvents(); let resultIndexHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX"); let resultTypeHist = Services.telemetry.getHistogramById("FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByTypeHist = Services.telemetry.getKeyedHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + resultIndexByTypeHist.clear(); resultIndexHist.clear(); resultTypeHist.clear(); @@ -291,6 +314,11 @@ add_task(function* test_suggestion() { URLBAR_SELECTED_RESULT_TYPES.searchsuggestion, "FX_URLBAR_SELECTED_RESULT_TYPE"); + let resultIndexByType = resultIndexByTypeHist.snapshot("searchsuggestion"); + checkHistogramResults(resultIndexByType, + 3, + "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE"); + Services.search.currentEngine = previousEngine; Services.search.removeEngine(suggestionEngine); yield BrowserTestUtils.removeTab(tab); diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 37fc72401d89..16d312c006c3 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -5916,6 +5916,16 @@ "bug_numbers": [775825], "description": "Firefox: The type of the selected result in the URL bar popup. See BrowserUsageTelemetry.jsm:URLBAR_SELECTED_RESULT_TYPES for the result types." }, + "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE": { + "alert_emails": ["firefox-dev@mozilla.org"], + "expires_in_version": "never", + "kind": "enumerated", + "n_values": 14, + "keyed": true, + "releaseChannelCollection": "opt-out", + "bug_numbers": [1345834], + "description": "Firefox: The index of the selected result in the URL bar popup by the type of the selected result in the URL bar popup. See BrowserUsageTelemetry.jsm:URLBAR_SELECTED_RESULT_TYPES for the result types." + }, "INNERWINDOWS_WITH_MUTATION_LISTENERS": { "expires_in_version": "never", "kind": "boolean",