From 31eb72fc0f20f3bcce15f1f96ca606060fca0cc0 Mon Sep 17 00:00:00 2001 From: MCleinman <9295855+mcleinman@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:59:29 -0800 Subject: [PATCH] VPN-6324: Telemetry for web based authentication (#10171) * VPN-6324 web based auth telemetry * PR feedback * add data review --- src/tasks/authenticate/taskauthenticate.cpp | 23 +++++++ src/tasks/authenticate/taskauthenticate.h | 3 + src/telemetry/metrics.yaml | 75 +++++++++++++++++++-- 3 files changed, 97 insertions(+), 4 deletions(-) diff --git a/src/tasks/authenticate/taskauthenticate.cpp b/src/tasks/authenticate/taskauthenticate.cpp index aad40eb798..5dd15744a0 100644 --- a/src/tasks/authenticate/taskauthenticate.cpp +++ b/src/tasks/authenticate/taskauthenticate.cpp @@ -13,6 +13,7 @@ #include "authenticationlistener.h" #include "constants.h" #include "errorhandler.h" +#include "glean/generated/metrics.h" #include "leakdetector.h" #include "logger.h" #include "networkrequest.h" @@ -52,6 +53,14 @@ void TaskAuthenticate::run() { logger.debug() << "Authentication completed with code:" << logger.sensitive(pkceCodeSuccess); + if (m_authenticationType == + AuthenticationListener::AuthenticationInBrowser) { + mozilla::glean::web_authentication::successful.record( + mozilla::glean::web_authentication::SuccessfulExtra{ + ._uuid = m_metricUuid.toString(QUuid::WithoutBraces), + }); + } + NetworkRequest* request = new NetworkRequest(this, 200); request->post( AuthenticationListener::createLoginVerifyUrl(), @@ -76,6 +85,13 @@ void TaskAuthenticate::run() { connect(m_authenticationListener, &AuthenticationListener::failed, this, [this](ErrorHandler::ErrorType error) { + if (m_authenticationType == + AuthenticationListener::AuthenticationInBrowser) { + mozilla::glean::web_authentication::failed.record( + mozilla::glean::web_authentication::FailedExtra{ + ._uuid = m_metricUuid.toString(QUuid::WithoutBraces), + }); + } REPORTERROR(error, name()); m_authenticationListener->aboutToFinish(); }); @@ -86,6 +102,13 @@ void TaskAuthenticate::run() { m_authenticationListener->aboutToFinish(); }); + m_metricUuid = QUuid::createUuid(); + if (m_authenticationType == AuthenticationListener::AuthenticationInBrowser) { + mozilla::glean::web_authentication::started.record( + mozilla::glean::web_authentication::StartedExtra{ + ._uuid = m_metricUuid.toString(QUuid::WithoutBraces), + }); + } m_authenticationListener->start(this, pkceCodeChallenge, CODE_CHALLENGE_METHOD, SettingsHolder::instance()->userEmail()); diff --git a/src/tasks/authenticate/taskauthenticate.h b/src/tasks/authenticate/taskauthenticate.h index 4119b5f912..511c00db04 100644 --- a/src/tasks/authenticate/taskauthenticate.h +++ b/src/tasks/authenticate/taskauthenticate.h @@ -5,6 +5,8 @@ #ifndef TASKAUTHENTICATE_H #define TASKAUTHENTICATE_H +#include + #include "authenticationlistener.h" #include "task.h" @@ -32,6 +34,7 @@ class TaskAuthenticate final : public Task { AuthenticationListener* m_authenticationListener = nullptr; AuthenticationListener::AuthenticationType m_authenticationType = AuthenticationListener::AuthenticationInBrowser; + QUuid m_metricUuid = QUuid::createUuid(); }; #endif // TASKAUTHENTICATE_H diff --git a/src/telemetry/metrics.yaml b/src/telemetry/metrics.yaml index d06f36669d..46a7eb4fb1 100644 --- a/src/telemetry/metrics.yaml +++ b/src/telemetry/metrics.yaml @@ -663,7 +663,7 @@ session: bugs: - https://mozilla-hub.atlassian.net/browse/VPN-6406 data_reviews: - - TBA + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/9593#issuecomment-2159109154 data_sensitivity: - technical notification_emails: @@ -839,7 +839,7 @@ connection_health: bugs: - https://mozilla-hub.atlassian.net/browse/VPN-6406 data_reviews: - - TBA + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/9593#issuecomment-2159109154 data_sensitivity: - technical notification_emails: @@ -945,7 +945,7 @@ connection_health: bugs: - https://mozilla-hub.atlassian.net/browse/VPN-6406 data_reviews: - - TBA + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/9593#issuecomment-2159109154 data_sensitivity: - technical notification_emails: @@ -1032,7 +1032,7 @@ connection_health: bugs: - https://mozilla-hub.atlassian.net/browse/VPN-6406 data_reviews: - - TBA + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/9593#issuecomment-2159109154 data_sensitivity: - technical notification_emails: @@ -1062,3 +1062,70 @@ connection_health: description: | Error type type: string + +web_authentication: + started: + type: event + lifetime: ping + send_in_pings: + - main + description: | + Web authentication was started. + bugs: + - https://mozilla-hub.atlassian.net/browse/VPN-6323 + data_reviews: + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/10171#pullrequestreview-2537047062 + data_sensitivity: + - interaction + notification_emails: + - mcleinman@mozilla.com + - vpn-telemetry@mozilla.com + expires: 2026-06-30 + extra_keys: + uuid: + description: UUID to match starting events to ending ones + type: string + + successful: + type: event + lifetime: ping + send_in_pings: + - main + description: | + Web authentication was successfully completed. + bugs: + - https://mozilla-hub.atlassian.net/browse/VPN-6323 + data_reviews: + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/10171#pullrequestreview-2537047062 + data_sensitivity: + - interaction + notification_emails: + - mcleinman@mozilla.com + - vpn-telemetry@mozilla.com + expires: 2026-06-30 + extra_keys: + uuid: + description: UUID to match ending event to starting one + type: string + + failed: + type: event + lifetime: ping + send_in_pings: + - main + description: | + Web authentication was unsuccessfully completed. + bugs: + - https://mozilla-hub.atlassian.net/browse/VPN-6323 + data_reviews: + - https://github.com/mozilla-mobile/mozilla-vpn-client/pull/10171#pullrequestreview-2537047062 + data_sensitivity: + - interaction + notification_emails: + - mcleinman@mozilla.com + - vpn-telemetry@mozilla.com + expires: 2026-06-30 + extra_keys: + uuid: + description: UUID to match ending event to starting one + type: string