commit 9bede6e77f089ef0e7bec4b2c3b165ec6728942c
parent 244ef0e5e7687be44e743d1c6f06e123a19b31df
Author: Rebecca King <rking@mozilla.com>
Date: Wed, 5 Nov 2025 14:13:18 +0000
Bug 1997331 - Add pref to count VPN panel open events - r=ip-protection-reviewers,kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D271081
Diffstat:
5 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
@@ -3508,6 +3508,8 @@ pref("browser.ipProtection.autoStartPrivateEnabled", false);
pref("browser.ipProtection.userEnabled", false);
// Pref to track which experiment version the user is enrolled in
pref("browser.ipProtection.variant", "");
+// Pref to track number of times the VPN panel is opened
+pref("browser.ipProtection.panelOpenCount", 0);
pref("browser.ipProtection.exceptionsMode", "all");
pref("browser.ipProtection.domainExclusions", "");
pref("browser.ipProtection.domainInclusions", "");
diff --git a/browser/components/ipprotection/IPProtectionPanel.sys.mjs b/browser/components/ipprotection/IPProtectionPanel.sys.mjs
@@ -208,6 +208,16 @@ export class IPProtectionPanel {
} else {
this.#createPanel(panelView);
}
+
+ // TODO: Stop counting after all onboarding messages have been shown - Bug 1997332
+ let currentCount = Services.prefs.getIntPref(
+ "browser.ipProtection.panelOpenCount"
+ );
+ let updatedCount = currentCount + 1;
+ Services.prefs.setIntPref(
+ "browser.ipProtection.panelOpenCount",
+ updatedCount
+ );
}
/**
diff --git a/browser/components/ipprotection/docs/Preferences.rst b/browser/components/ipprotection/docs/Preferences.rst
@@ -63,3 +63,6 @@ Diagnostics
``browser.ipProtection.log`` (boolean, default: ``false``)
Enable/disable logging.
+
+``browser.ipProtection.panelOpenCount`` (integer, default: ``0``)
+ Counts the number of times the VPN panel is opened.
diff --git a/browser/components/ipprotection/tests/browser/browser_ipprotection_panel.js b/browser/components/ipprotection/tests/browser/browser_ipprotection_panel.js
@@ -14,7 +14,8 @@ ChromeUtils.defineESModuleGetters(lazy, {
/**
* Tests that clicking toolbar button opens the panel,
- * and the panel contains a `<ipprotection-content>` element.
+ * the panel contains a `<ipprotection-content>` element,
+ * and the browser.ipProtection.panelOpenCount pref is set
*/
add_task(async function click_toolbar_button() {
let button = document.getElementById(lazy.IPProtectionWidget.WIDGET_ID);
@@ -23,11 +24,26 @@ add_task(async function click_toolbar_button() {
lazy.IPProtectionWidget.PANEL_ID
);
+ let panelOpenCount = Services.prefs.getIntPref(
+ "browser.ipProtection.panelOpenCount",
+ 0
+ );
+
let panelShownPromise = waitForPanelEvent(document, "popupshown");
// Open the panel
button.click();
await panelShownPromise;
+ let panelOpenCountAfter = Services.prefs.getIntPref(
+ "browser.ipProtection.panelOpenCount",
+ 0
+ );
+ Assert.equal(
+ panelOpenCountAfter,
+ panelOpenCount + 1,
+ "panelOpenCount should increase by 1 when the panel is opened"
+ );
+
let component = panelView.querySelector(
lazy.IPProtectionPanel.CONTENT_TAGNAME
);
@@ -48,6 +64,8 @@ add_task(async function click_toolbar_button() {
let panelHiddenPromise = waitForPanelEvent(document, "popuphidden");
EventUtils.synthesizeKey("KEY_Escape");
await panelHiddenPromise;
+
+ Services.prefs.clearUserPref("browser.ipProtection.panelOpenCount");
});
/**
diff --git a/browser/components/ipprotection/tests/browser/head.js b/browser/components/ipprotection/tests/browser/head.js
@@ -270,6 +270,10 @@ add_setup(async function setupVPN() {
cleanupExperiment();
CustomizableUI.reset();
Services.prefs.clearUserPref(IPProtectionWidget.ADDED_PREF);
+ Services.prefs.clearUserPref("browser.ipProtection.panelOpenCount");
+ Services.prefs.clearUserPref("browser.ipProtection.stateCache");
+ Services.prefs.clearUserPref("browser.ipProtection.entitlementCache");
+ Services.prefs.clearUserPref("browser.ipProtection.locationListCache");
});
});