diff --git a/app/metrics.yaml b/app/metrics.yaml index a7cfaacb4..9c142345a 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1840,6 +1840,32 @@ preferences: tags: - TrackingProtection - Settings + etp_custom_cookies_selection: + type: string + description: | + The option user has selected in the "Custom" mode of the + Enhanced Tracking Protection settings. + Possible values: + - total-protection for “Isolate cross-site cookies” + - social for “Cross-site and social media trackers” + - unvisited for “Cookies from unvisited sites” + - third-party for “All third-party cookies..” + - all for “All cookies..” + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/18175 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/26449#issuecomment-1225765591 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: 119 + metadata: + tags: + - TrackingProtection + - Settings bookmarks_suggestion: type: boolean description: | diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index 848ec3a1f..cc88c295c 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -758,6 +758,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider { else -> "" } ) + etpCustomCookiesSelection.set(settings.blockCookiesSelectionInCustomTrackingProtection) val accessibilitySelection = mutableListOf() diff --git a/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt b/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt index 6d94f8759..62a57fa99 100644 --- a/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt +++ b/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt @@ -203,4 +203,17 @@ class FenixApplicationTest { assertEquals(contextId, TopSites.contextId.testGetValue()!!.toString()) assertEquals(contextId, settings.contileContextId) } + + @Test + fun `GIVEN the current etp mode is custom WHEN tracking the etp metric THEN track also the cookies option`() { + val settings: Settings = mockk(relaxed = true) { + every { shouldUseTrackingProtection } returns true + every { useCustomTrackingProtection } returns true + every { blockCookiesSelectionInCustomTrackingProtection } returns "Test" + } + + application.setStartupMetrics(browserStore, settings, browsersCache, mozillaProductDetector) + + assertEquals("Test", Preferences.etpCustomCookiesSelection.testGetValue()) + } }