tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1f5159b8a86c99264df78993bba5c931949f0880
parent a7daa8148837c6f74578f5743242e16d031ae2bc
Author: Rebecca King <rking@mozilla.com>
Date:   Tue, 18 Nov 2025 19:27:44 +0000

Bug 1998500 - Add metric for error message views - r=ip-protection-reviewers,fchasen

Differential Revision: https://phabricator.services.mozilla.com/D272924

Diffstat:
Mbrowser/components/ipprotection/IPPProxyManager.sys.mjs | 1+
Mbrowser/components/ipprotection/metrics.yaml | 18++++++++++++++++++
Mbrowser/components/ipprotection/tests/browser/browser_ipprotection_telemetry.js | 30++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/browser/components/ipprotection/IPPProxyManager.sys.mjs b/browser/components/ipprotection/IPPProxyManager.sys.mjs @@ -450,6 +450,7 @@ class IPPProxyManagerSingleton extends EventTarget { this.#setState(IPPProxyStates.ERROR); lazy.logConsole.error(errorContext || error); + Glean.ipprotection.error.record({ source: "ProxyManager" }); } #setState(state) { diff --git a/browser/components/ipprotection/metrics.yaml b/browser/components/ipprotection/metrics.yaml @@ -90,3 +90,21 @@ ipprotection: - sstreich@mozilla.com - vpn-telemetry@mozilla.com expires: never + error: + type: event + description: > + Recorded when the in-panel error message is triggered. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1998500 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1998500 + data_sensitivity: + - interaction + notification_emails: + - rking@mozilla.com + expires: never + extra_keys: + source: + type: string + description: > + Module where the error originated. diff --git a/browser/components/ipprotection/tests/browser/browser_ipprotection_telemetry.js b/browser/components/ipprotection/tests/browser/browser_ipprotection_telemetry.js @@ -12,6 +12,10 @@ ChromeUtils.defineESModuleGetters(lazy, { "resource:///modules/ipprotection/IPProtectionService.sys.mjs", }); +const { ERRORS } = ChromeUtils.importESModule( + "chrome://browser/content/ipprotection/ipprotection-constants.mjs" +); + async function resetStateToObj(content, originalState) { content.state = originalState; content.requestUpdate(); @@ -243,3 +247,29 @@ add_task(async function click_upgrade_button() { BrowserTestUtils.removeTab(newTab); }); + +/** + * Tests that the error event is recorded when an error is triggered + */ +add_task(async function test_error_state() { + Services.fog.testResetFOG(); + let button = document.getElementById(IPProtectionWidget.WIDGET_ID); + Assert.ok( + BrowserTestUtils.isVisible(button), + "IP Protection widget should be added to the navbar" + ); + + let panelShownPromise = waitForPanelEvent(document, "popupshown"); + let panelInitPromise = BrowserTestUtils.waitForEvent( + document, + "IPProtection:Init" + ); + button.click(); + await Promise.all([panelShownPromise, panelInitPromise]); + + lazy.IPPProxyManager.setErrorState(ERRORS.GENERIC, ERRORS.GENERIC); + let errorEvent = Glean.ipprotection.error.testGetValue(); + Assert.equal(errorEvent.length, 1, "should have recorded an error"); + Services.fog.testResetFOG(); + await closePanel(); +});