From b36e793f6d871ad2896f8c828e820fdaabad00d9 Mon Sep 17 00:00:00 2001 From: Stefan Vladut Date: Mon, 20 Jan 2025 22:05:29 +0200 Subject: [PATCH 1/2] Add FXIOS-9203 enhanced tracking protection panel telemetry (#20371) --- firefox-ios/Client.xcodeproj/project.pbxproj | 4 + .../TrackingProtectionMiddleware.swift | 8 ++ ...ckingProtectionDetailsViewController.swift | 2 + .../TrackingProtectionTelemetry.swift | 34 ++++++++ firefox-ios/Client/metrics.yaml | 77 +++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionTelemetry.swift diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index f6701a565d46..49b34734edc3 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -1217,6 +1217,7 @@ AB9CBC082C53B7CD00102610 /* TrackingProtectionStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB9CBC062C53B76400102610 /* TrackingProtectionStateTests.swift */; }; ABB184EB2CB807B300F0689D /* CertificatesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABB184EA2CB807B200F0689D /* CertificatesModel.swift */; }; ABB507CF2A136FB2009CAA67 /* UserConversionMetricsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABB507CD2A136FB2009CAA67 /* UserConversionMetricsTests.swift */; }; + ABCEC0292D3DE2C80040F40D /* TrackingProtectionTelemetry.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABCEC0282D3DE2C30040F40D /* TrackingProtectionTelemetry.swift */; }; ABE4393E2AC432040074FFE1 /* PartnerWebsites.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABE4393D2AC432040074FFE1 /* PartnerWebsites.swift */; }; ABE856AD2C75029F00C56F47 /* TrackingProtectionStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABE856AC2C75029F00C56F47 /* TrackingProtectionStatusView.swift */; }; ABEF80D12A24D2BE003F52C4 /* CreditCardBottomSheetViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABEF80D02A24D2BE003F52C4 /* CreditCardBottomSheetViewModel.swift */; }; @@ -8300,6 +8301,7 @@ AB9CBC062C53B76400102610 /* TrackingProtectionStateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackingProtectionStateTests.swift; sourceTree = ""; }; ABB184EA2CB807B200F0689D /* CertificatesModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CertificatesModel.swift; sourceTree = ""; }; ABB507CD2A136FB2009CAA67 /* UserConversionMetricsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserConversionMetricsTests.swift; sourceTree = ""; }; + ABCEC0282D3DE2C30040F40D /* TrackingProtectionTelemetry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackingProtectionTelemetry.swift; sourceTree = ""; }; ABE4393D2AC432040074FFE1 /* PartnerWebsites.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartnerWebsites.swift; sourceTree = ""; }; ABE856AC2C75029F00C56F47 /* TrackingProtectionStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackingProtectionStatusView.swift; sourceTree = ""; }; ABEF80D02A24D2BE003F52C4 /* CreditCardBottomSheetViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreditCardBottomSheetViewModel.swift; sourceTree = ""; }; @@ -12617,6 +12619,7 @@ isa = PBXGroup; children = ( 0A4978492C53E63200B1E82A /* TrackingProtectionViewController.swift */, + ABCEC0282D3DE2C30040F40D /* TrackingProtectionTelemetry.swift */, AB11407B2CAC0CA8005080CE /* TrackigProtectionRedux */, AB11407D2CAC0D60005080CE /* TrackingProtectionHelpers */, AB9A0C002C6CBC9100BFA22A /* TrackingProtectionDetailsViewController.swift */, @@ -16433,6 +16436,7 @@ 3BCE6D3C1CEB9E4D0080928C /* ThirdPartySearchAlerts.swift in Sources */, 5AD3B6742CF625B000AFA1FE /* DefaultBrowserUtil.swift in Sources */, 8A93F86229D36F0F004159D9 /* NavigationController.swift in Sources */, + ABCEC0292D3DE2C80040F40D /* TrackingProtectionTelemetry.swift in Sources */, E13F8C342928194800BDC8B4 /* PhotonActionSheetSiteHeaderView.swift in Sources */, C2D71B9B2A3850B4003DEC7A /* ThemedTableViewCellViewModel.swift in Sources */, C869912F28917688007ACC5C /* WallpaperMetadataLoader.swift in Sources */, diff --git a/firefox-ios/Client/Frontend/TrackingProtection/TrackigProtectionRedux/TrackingProtectionMiddleware.swift b/firefox-ios/Client/Frontend/TrackingProtection/TrackigProtectionRedux/TrackingProtectionMiddleware.swift index 63b30c453934..9646dfc3407a 100644 --- a/firefox-ios/Client/Frontend/TrackingProtection/TrackigProtectionRedux/TrackingProtectionMiddleware.swift +++ b/firefox-ios/Client/Frontend/TrackingProtection/TrackigProtectionRedux/TrackingProtectionMiddleware.swift @@ -8,6 +8,8 @@ import Common import Shared final class TrackingProtectionMiddleware { + private let telemetryWrapper = TrackingProtectionTelemetry() + lazy var trackingProtectionProvider: Middleware = { state, action in let windowUUID = action.windowUUID switch action.actionType { @@ -44,6 +46,7 @@ final class TrackingProtectionMiddleware { actionType: TrackingProtectionMiddlewareActionType.clearCookies ) store.dispatch(newAction) + telemetryWrapper.clearCookiesAndSiteData() } private func tappedShowClearCookiesAndSiteDataAlert(windowUUID: WindowUUID) { @@ -52,6 +55,7 @@ final class TrackingProtectionMiddleware { actionType: TrackingProtectionMiddlewareActionType.showAlert ) store.dispatch(newAction) + telemetryWrapper.showClearCookiesAlert() } private func dismissScreen(windowUUID: WindowUUID) { @@ -60,6 +64,7 @@ final class TrackingProtectionMiddleware { actionType: TrackingProtectionMiddlewareActionType.dismissTrackingProtection ) store.dispatch(newAction) + telemetryWrapper.dismissTrackingProtection() } private func showTrackingProtectionDetails(windowUUID: WindowUUID) { @@ -68,6 +73,7 @@ final class TrackingProtectionMiddleware { actionType: TrackingProtectionMiddlewareActionType.showTrackingProtectionDetails ) store.dispatch(newAction) + telemetryWrapper.showTrackingProtectionDetails() } private func showBlockedTrackersDetails(windowUUID: WindowUUID) { @@ -76,6 +82,7 @@ final class TrackingProtectionMiddleware { actionType: TrackingProtectionMiddlewareActionType.showBlockedTrackersDetails ) store.dispatch(newAction) + telemetryWrapper.showBlockedTrackersDetails() } private func showTrackingProtectionSettings(windowUUID: WindowUUID) { @@ -84,5 +91,6 @@ final class TrackingProtectionMiddleware { actionType: TrackingProtectionMiddlewareActionType.navigateToSettings ) store.dispatch(newAction) + telemetryWrapper.tappedShowSettings() } } diff --git a/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionDetailsViewController.swift b/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionDetailsViewController.swift index 7bf4ce3646df..9bb0e709fd45 100644 --- a/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionDetailsViewController.swift +++ b/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionDetailsViewController.swift @@ -36,6 +36,7 @@ class TrackingProtectionDetailsViewController: UIViewController, Themeable { static let baseCellHeight: CGFloat = 44 static let baseDistance: CGFloat = 20 } + private let telemetryWrapper = TrackingProtectionTelemetry() // MARK: - UI private let scrollView: UIScrollView = .build { scrollView in } @@ -245,6 +246,7 @@ class TrackingProtectionDetailsViewController: UIViewController, Themeable { let certificatesController = CertificatesViewController(with: model.getCertificatesModel(), windowUUID: windowUUID) self.navigationController?.pushViewController(certificatesController, animated: true) + telemetryWrapper.trackShowCertificates() } private func currentTheme() -> Theme { diff --git a/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionTelemetry.swift b/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionTelemetry.swift new file mode 100644 index 000000000000..13ebbcd30a01 --- /dev/null +++ b/firefox-ios/Client/Frontend/TrackingProtection/TrackingProtectionTelemetry.swift @@ -0,0 +1,34 @@ +// 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/ +import Glean + +struct TrackingProtectionTelemetry { + func showClearCookiesAlert() { + GleanMetrics.TrackingProtection.showClearCookiesAlert.record() + } + + func clearCookiesAndSiteData() { + GleanMetrics.TrackingProtection.tappedClearCookies.record() + } + + func showTrackingProtectionDetails() { + GleanMetrics.TrackingProtection.showEtpDetails.record() + } + + func showBlockedTrackersDetails() { + GleanMetrics.TrackingProtection.showEtpBlockedTrackersDetails.record() + } + + func tappedShowSettings() { + GleanMetrics.TrackingProtection.showEtpSettings.record() + } + + func dismissTrackingProtection() { + GleanMetrics.TrackingProtection.dismissEtpPanel.record() + } + + func trackShowCertificates() { + GleanMetrics.TrackingProtection.showCertificates.record() + } +} diff --git a/firefox-ios/Client/metrics.yaml b/firefox-ios/Client/metrics.yaml index 87faaeb29387..3ca683ecd929 100755 --- a/firefox-ios/Client/metrics.yaml +++ b/firefox-ios/Client/metrics.yaml @@ -4353,6 +4353,83 @@ tracking_protection: notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" + show_clear_cookies_alert: + type: event + description: | + Records when the clear cookies alert is shown + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" + show_etp_details: + type: event + description: | + Records when the enhanced tracking protection details screen is shown + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" + show_etp_blocked_trackers_details: + type: event + description: | + Records when the enhanced tracking protection blocked trackers details screen is shown + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" + show_etp_settings: + type: event + description: | + Records when the enhanced tracking protection settings screen is shown + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" + tapped_clear_cookies: + type: event + description: | + Records when the clear cookies button from the etp alert is tapped. + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" + dismiss_etp_panel: + type: event + description: | + Records when the enhanced tracking protection panel is dismissed + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" + show_certificates: + type: event + description: | + Records when the certificates screen from the enhanced tracking protection panel is shown + bugs: + - https://github.com/mozilla-mobile/firefox-ios/issues/20371 + data_reviews: + - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + notification_emails: + - fx-ios-data-stewards@mozilla.com + expires: "2025-07-01" # iOS 14 widget metrics # m: medium, s: small, l: large widget: From 209df3c6c520711065a193107c632232fc540000 Mon Sep 17 00:00:00 2001 From: Stefan Vladut Date: Tue, 21 Jan 2025 14:03:27 +0200 Subject: [PATCH 2/2] updated PR links --- firefox-ios/Client/metrics.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/firefox-ios/Client/metrics.yaml b/firefox-ios/Client/metrics.yaml index 3ca683ecd929..361d63b9adb3 100755 --- a/firefox-ios/Client/metrics.yaml +++ b/firefox-ios/Client/metrics.yaml @@ -4360,7 +4360,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" @@ -4371,7 +4371,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" @@ -4382,7 +4382,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" @@ -4393,7 +4393,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" @@ -4404,7 +4404,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" @@ -4415,7 +4415,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01" @@ -4426,7 +4426,7 @@ tracking_protection: bugs: - https://github.com/mozilla-mobile/firefox-ios/issues/20371 data_reviews: - - https://github.com/mozilla-mobile/firefox-ios/pull/14102 + - https://github.com/mozilla-mobile/firefox-ios/pull/24252 notification_emails: - fx-ios-data-stewards@mozilla.com expires: "2025-07-01"