Commit e010ccc5 authored by Rob Wu's avatar Rob Wu Committed by Rob Wu
Browse files

Bug 1966935 - Record whether the user prefers a hidden Extensions button r=willdurand

This allows us to measure how many % of the users have configured the
button to be hidden.

Differential Revision: https://phabricator.services.mozilla.com/D249917
parent f4ee1cd9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2013,6 +2013,8 @@ var gUnifiedExtensions = {
    CustomizableUI.addListener(this);
    AddonManager.addManagerListener(this);

    Glean.extensionsButton.prefersHiddenButton.set(!this.buttonAlwaysVisible);

    this._initialized = true;
  },

@@ -3005,9 +3007,10 @@ XPCOMUtils.defineLazyPreferenceGetter(
  "buttonAlwaysVisible",
  "extensions.unifiedExtensions.button.always_visible",
  true,
  () => {
  (prefName, oldValue, newValue) => {
    if (gUnifiedExtensions._initialized) {
      gUnifiedExtensions.updateButtonVisibility();
      Glean.extensionsButton.prefersHiddenButton.set(!newValue);
    }
  }
);
+29 −0
Original line number Diff line number Diff line
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html

---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
  - 'WebExtensions :: General'

extensions_button:
  prefers_hidden_button:
    type: boolean
    description: >
      Records whether the user prefers the Extensions Button to be hidden.
      Corresponds to the inverse value of the
      `exceptions.unifiedExtensions.button.always_visible` pref.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1966935
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1966935
    data_sensitivity:
      - technical
    notification_emails:
      - addons-dev-internal@mozilla.com
      - rwu@mozilla.com
    expires: 150
+19 −0
Original line number Diff line number Diff line
@@ -22,6 +22,14 @@ function resetButtonVisibilityToDefault() {
  Services.prefs.clearUserPref(PREF_ALWAYS_VISIBLE);
}

function assertTelemetryValueMatchesAlwaysVisiblePref() {
  is(
    Glean.extensionsButton.prefersHiddenButton.testGetValue(),
    !Services.prefs.getBoolPref(PREF_ALWAYS_VISIBLE),
    "extensions_button.prefers_hidden_button is inverse of pref value"
  );
}

async function checkAndDismissPostHideNotification(win) {
  // After hiding the extensions button, a notification is displayed for 3
  // seconds, notifying the user of "Move to menu". Check that it is shown and
@@ -51,14 +59,23 @@ registerCleanupFunction(resetButtonVisibilityToDefault);

add_task(async function test_default_button_visibility() {
  assertExtensionsButtonVisible();
  // assertTelemetryValueMatchesAlwaysVisiblePref() cannot be used because the
  // pref is unset by default.
  is(
    Glean.extensionsButton.prefersHiddenButton.testGetValue(),
    false,
    "extensions_button.prefers_hidden_button is false by default"
  );
});

add_task(async function test_hide_button_before_new_window() {
  hideButtonWithPref();
  assertTelemetryValueMatchesAlwaysVisiblePref();
  const win = await BrowserTestUtils.openNewBrowserWindow();
  assertExtensionsButtonHidden(win);

  showButtonWithPref();
  assertTelemetryValueMatchesAlwaysVisiblePref();
  assertExtensionsButtonVisible(win);

  await BrowserTestUtils.closeWindow(win);
@@ -67,10 +84,12 @@ add_task(async function test_hide_button_before_new_window() {

add_task(async function test_show_button_before_new_window() {
  showButtonWithPref();
  assertTelemetryValueMatchesAlwaysVisiblePref();
  const win = await BrowserTestUtils.openNewBrowserWindow();
  assertExtensionsButtonVisible(win);

  hideButtonWithPref();
  assertTelemetryValueMatchesAlwaysVisiblePref();
  assertExtensionsButtonHidden(win);

  await BrowserTestUtils.closeWindow(win);
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ firefox_desktop_metrics = [
    "browser/components/attribution/metrics.yaml",
    "browser/components/backup/metrics.yaml",
    "browser/components/downloads/metrics.yaml",
    "browser/components/extensions/metrics.yaml",
    "browser/components/firefoxview/metrics.yaml",
    "browser/components/genai/metrics.yaml",
    "browser/components/metrics.yaml",